My JSON Data file ise data.txt
[
{
"sayim":"1",
"x":"400",
"y":"5",
"z":"-6"
},
{
"sayim":"2",
"x":"4",
"y":"-40",
"z":"700"
},
{
"sayim":"3",
"x":"5",
"y":"-5",
"z":"500"
},
{
"sayim":"4",
"x":"1400",
"y":"50",
"z":"-6"
},
{
"sayim":"5",
"x":"4",
"y":"5",
"z":"6"
}
]
and my aim ise to create a Slider which can change starting and ending of the graphic, it is like what is showing in figure 6 in this website
and here the MXML codes;
.
..
...
jsonDataArray = JSON.decode(urlLoader.data);
proceed();
}
private function proceed():void
{
dgg.dataProvider = jsonDataArray;
开发者_如何学编程 }
]]>
</mx:Script>
<mx:HSlider minimum="1" maximum="30" id="daySlider" snapInterval="1" thumbCount="2" values="[1,30]" />
<mx:LineChart id="dgg" width="1000" height="500" horizontalCenter="0" >
<mx:series>
<mx:LineSeries xField="sayim" yField="x" displayName="X Bileşeni" />
<mx:LineSeries xField="sayim" yField="y" displayName="Y Bileşeni" />
<mx:LineSeries xField="sayim" yField="z" displayName="Z Bileşeni" />
</mx:series>
</mx:LineChart>
<mx:Legend dataProvider="{dgg}" />
The problem is "dataProvider" definition in LineChart, I wrote this code but it is still not working,
dataProvider="{dgg(sayim>=daySlider.values[0] && sayim<=daySlider.values[1])}"
what is the right code to control the LineChart with the Slider.
You are mixing your metaphors a bit here.
In that article, he is using EcmaScript For Xml (E4X) to bind an XML query to the dataProvider
. The "dots" in that line are very important because it assumes a loose XML tree. It is also using a query syntax on day
that can only be done with XML objects. Thus, the following binding only works if the stockData
is of the data type XML.
dataProvider="{stockData..day.(num >= daySlider.value )}"
In your case, however, your data is JSON, so your objects are not in the form that the query above will work.
Further, you are setting your dataProvider
to call a function dgg
but dgg
is a LineChart
and not a function.
In your case, I would recommend packing your data into an ArrayCollection
and use filterFunction
to define how to filter that data. Then, bind to the ArrayCollection
directly and modify the filter function proceeded by a refresh()
. You can see an example of doing this here: http://www.flex-blog.com/arraycollection-filter-example/
Good luck
精彩评论