14 Replies Latest reply on May 26, 2009 12:25 PM by viciNoHart

    How to use  LineChart  in SDK4.0

    viciNoHart

      in sdk3.0 I can use the LineChart,but when I change to SDK4.0,it get  error.

      so how can I use the LineChart in SDK4.0;

       

      thanks for your concern ,

        • 1. Re: How to use  LineChart  in SDK4.0
          Gregory Lafrance Level 6

          What is the error you are getting, and please post simplified yet "complete" code with small data set.

          • 2. Re: How to use  LineChart  in SDK4.0
            viciNoHart Level 1

            thanks for reply

            error  tips

            1046: can not find the type, or it is not a compiler constant:LineChart.

             

             

            all  code are here:

             

            <?xml version="1.0" encoding="utf-8"?>
            <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" verticalAlign="top"
                horizontalAlign="center" backgroundGradientColors="[0x000000,0x323232]" paddingTop="0" viewSourceURL="srcview/index.html">
               
                <mx:Script>
                    <![CDATA[

                    import mx.collections.ArrayCollection;

                    [Bindable]
                    private var expensesAC:ArrayCollection = new ArrayCollection( [
                        { Month: "Jan", Profit: 2000, Expenses: 1500, Amount: 450 },
                        { Month: "Feb", Profit: 1000, Expenses: 200, Amount: 600 },
                        { Month: "Mar", Profit: 1500, Expenses: 500, Amount: 300 },
                        { Month: "Apr", Profit: 1800, Expenses: 1200, Amount: 900 },
                        { Month: "May", Profit: 2400, Expenses: 575, Amount: 500 } ]);
                    ]]>
                </mx:Script>
               
                <mx:Panel title="LineChart Control" layout="horizontal" color="0xffffff" borderAlpha="0.15" width="600" height="240"
                     paddingTop="10" paddingRight="5" paddingBottom="10" paddingLeft="5" horizontalAlign="center">
                    
                     <mx:LineChart id="linechart" color="0x323232" height="100%"
                        showDataTips="true" dataProvider="{expensesAC}">
                           
                        <mx:horizontalAxis>
                            <mx:CategoryAxis categoryField="Month"/>
                        </mx:horizontalAxis>

                        <mx:series>
                            <mx:LineSeries yField="Profit" form="curve" displayName="Profit"/>
                            <mx:LineSeries yField="Expenses" form="curve" displayName="Expenses"/>
                            <mx:LineSeries yField="Amount" form="curve" displayName="Amount"/>
                        </mx:series>
                    </mx:LineChart>

                    <mx:Legend dataProvider="{linechart}" color="0x323232"/>
                   
                </mx:Panel>
            </mx:Application>

            • 3. Re: How to use  LineChart  in SDK4.0
              Michael Borbor Level 4

              The mx.charts package is an extra package that contains the charting controls but it comes with Flex Builder , and it's not part of the Free Flex SDK, probably you'll have to wait a little bit when Flash Builder 4 comes out to the market.

              1 person found this helpful
              • 4. Re: How to use  LineChart  in SDK4.0
                Michael Borbor Level 4

                Which Flex SDK 4 build are you using?

                • 5. Re: How to use  LineChart  in SDK4.0
                  viciNoHart Level 1

                  my sdk4 build  is:

                  flex_sdk_4.0.0.4904.zip

                  • 6. Re: How to use  LineChart  in SDK4.0
                    viciNoHart Level 1

                    thanks for your help,

                    I think I should find another way to sovle my problem.till the flex Builder 4 to  comes out .

                    • 7. Re: How to use  LineChart  in SDK4.0
                      Michael Borbor Level 4

                      I see that's why the SDK has the old naming convention, my friend download the latest nightly build and begin using the new namespaces.

                      1 person found this helpful
                      • 8. Re: How to use  LineChart  in SDK4.0
                        viciNoHart Level 1

                        good advice.

                        I will try another nightly build .

                        • 9. Re: How to use  LineChart  in SDK4.0
                          Gregory Lafrance Level 6

                          This works:

                           

                          <?xml version="1.0" encoding="utf-8"?>
                          <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
                            xmlns:s="library://ns.adobe.com/flex/spark" 
                            xmlns:mx="library://ns.adobe.com/flex/halo">
                            <fx:Script>
                              <![CDATA[
                                import mx.collections.ArrayCollection;
                                
                                [Bindable] private var arr:ArrayCollection = new ArrayCollection([
                                  {Month:"Jan", Profit:2000, Expenses:1500, Amount:450},
                                  {Month:"Feb", Profit:1000, Expenses:200, Amount:600},
                                  {Month:"Mar", Profit:1500, Expenses:500, Amount:300}        
                                ]);
                              ]]>
                            </fx:Script>
                            <s:Group>
                              <s:layout>
                                <s:VerticalLayout/>
                              </s:layout>
                              <mx:LineChart id="myChart" dataProvider="{arr}">
                                <mx:horizontalAxis>
                                  <mx:CategoryAxis dataProvider="{arr}" categoryField="Month"/>
                                </mx:horizontalAxis>
                                <mx:series>
                                  <mx:LineSeries yField="Profit" displayName="Profit"/>
                                  <mx:LineSeries yField="Expenses" displayName="Expenses"/>
                                </mx:series>
                              </mx:LineChart>
                              <mx:Legend dataProvider="{myChart}"/>    
                            </s:Group>
                          </s:Application>
                          
                          • 10. Re: How to use  LineChart  in SDK4.0
                            viciNoHart Level 1

                            thanks ,

                            but this time the error is:

                             

                            Severity and Description Path Resource Location Creation Time Id
                            Could not resolve <s:Application> to a component implementation.

                            chartTest/src chartTest.mxml line 4 1243363520125 18656

                            • 11. Re: How to use  LineChart  in SDK4.0
                              Gregory Lafrance Level 6

                              Are you copying mny entire code?

                               

                              Maybe you need to mess with the SDK in the preferences.

                              • 12. Re: How to use  LineChart  in SDK4.0
                                viciNoHart Level 1

                                thanks again!

                                 

                                I have  mess with the SDK in the preferences.

                                My sdk4 build is     "flex_sdk_4.0.0.4904"

                                I copy your code here:

                                 

                                 

                                <?xml version="1.0" encoding="utf-8"?>
                                <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
                                  xmlns:s="library://ns.adobe.com/flex/spark"
                                  xmlns:mx="library://ns.adobe.com/flex/halo">
                                  <fx:Script>
                                    <![CDATA[
                                      import mx.collections.ArrayCollection;
                                     
                                      [Bindable] private var arr:ArrayCollection = new ArrayCollection([
                                        {Month:"Jan", Profit:2000, Expenses:1500, Amount:450},
                                        {Month:"Feb", Profit:1000, Expenses:200, Amount:600},
                                        {Month:"Mar", Profit:1500, Expenses:500, Amount:300}       
                                      ]);
                                    ]]>
                                  </fx:Script>
                                  <s:Group>
                                    <s:layout>
                                      <s:VerticalLayout/>
                                    </s:layout>
                                    <mx:LineChart id="myChart" dataProvider="{arr}">
                                      <mx:horizontalAxis>
                                        <mx:CategoryAxis dataProvider="{arr}" categoryField="Month"/>
                                      </mx:horizontalAxis>
                                      <mx:series>
                                        <mx:LineSeries yField="Profit" displayName="Profit"/>
                                        <mx:LineSeries yField="Expenses" displayName="Expenses"/>
                                      </mx:series>
                                    </mx:LineChart>
                                    <mx:Legend dataProvider="{myChart}"/>   
                                  </s:Group>
                                </s:Application>

                                • 13. Re: How to use  LineChart  in SDK4.0
                                  Gregory Lafrance Level 6

                                  Are you saying that now it works?

                                  • 14. Re: How to use  LineChart  in SDK4.0
                                    viciNoHart Level 1

                                    I hope so ,but it still  can not work.