0

我使用 DateTimeAxis 作为水平轴,我得到一个图表,其中所有记录都压缩在图表的末尾,我尝试设置最小值和最大值,但它没有解决问题

我想让图表上的点更加分散

提前致谢

编码

            public function todate(obj:Object  , index:int, arr:Array){
                trace("timestamp  =>" ,  Number(obj["time"]) ) ; 
             obj["time"] = new Date(Number(obj["time"])*1000) ; //new Date( 

             trace("converted date  =>" ,  obj["time"] ) ; 
             return obj ;
            }


            public function getfuel(ev:Object):void{
                trace("the message has been received by fuel" , ev.toString()) ; 
                var obj:Object = JSON.parse(ev.toString());
                var arr:Array = obj as Array ; 
                min_date = new Date(Number(arr[0]["time"])*1000) ; 
                max_date = new Date(Number(arr[arr.length-1]["time"])*1000) ;
                trace("min max date " ,min_date , max_date ) ;

                var dar:Array = arr.map(todate);

                arrcol = new ArrayCollection(dar ); //obj as Array

                trace("array collection " , arrcol ) ;
                linechart.dataProvider = arrcol ; 




                if ( combogr.selectedItem.value == "speed") 
                {


                    var ls:LineSeries;
                    ls = new LineSeries();
                    ls.xField = "time";
                    ls.yField = "speed";
                    ls.displayName = "Vitesse" ;

                    ls.dataProvider = linechart.dataProvider;
                    var tmp:Array = linechart.series;
                    tmp.push(ls)
                    linechart.series = tmp;

                }
            }




<s:HGroup width="417" height="194">
                    <mx:LineChart id="linechart" height="100%" width="288"
                      paddingLeft="5" paddingRight="5" 
                      showDataTips="true" dataProvider="{arrcol}">

            <mx:horizontalAxis>
                <mx:DateTimeAxis  id="time"   maximum="{max_date}"  minimum="{min_date}"   />
            </mx:horizontalAxis>

            <mx:series>
                <mx:LineSeries yField="fuel_fd" form="curve" displayName="fuel_df" lineStroke="{s2}"/>
                <mx:LineSeries yField="fuel" form="curve" displayName="fuel" lineStroke="{s1}"/>

            </mx:series>
        </mx:LineChart>

        <mx:Legend dataProvider="{linechart}"/>
4

0 回答 0