[ 2 posts ]

Abhaya Thakur

  • Username: abhaya
  • Joined: Wed Jan 02, 2013 11:10 pm
  • Posts: 5
  • Offline
  • Profile

YUI Chart Series xData

Post Posted: Tue Jan 08, 2013 11:10 pm
+0-
Hi,

I have plotted a chart with dates in the X-axis and usercount on the Y-axix

I am able to get Series yData(User Count) by using below script
Code:
ydata = series.get("yData");



But I cannot find a way to get xData(Dates) for a series as below script is returning Indexno not dates
Code:
xdata = series.get("xData");



Below is the preview of my script. Line 7 is returning incorrect value.
Code:
sc = mychart.get("seriesCollection");
for(; i < sc.length; ++i)
    {
        series = sc[i];
        ydata = series.get("yData"); // returning correct value

        xdata = series.get("xData"); // returning incorrect value       
    }



Can you please tell me the correct way to get xData.


Thanks

Tripp Bridges

YUI Developer

  • Username: tripp
  • Joined: Wed Jan 07, 2009 1:54 pm
  • Posts: 435
  • GitHub: tripp
  • Gists: tripp
  • YUI Developer
  • Offline
  • Profile

Re: YUI Chart Series xData

Post Posted: Wed Jan 09, 2013 11:46 am
+0-
The Category axis returns an array of indices for getDataByKey (which is used to define the series' xData/yData attributes). I have filed a ticket here. For now, you can use the workaround that I've written below.
Thanks,
Tripp
Code:
var i,
    sc = mychart.get("seriesCollection"),
    len = sc.length,
    isVertical = mychart.get("direction") === "vertical",
    categoryKey = mychart.get("categoryKey");
for(i = 0; i < len; ++i) {
    series = sc[i];
    if(isVertical) {
        ydata = series.get("yAxis").get("keys")[categoryKey];
        xdata = series.get("xData");       
    } else {
        ydata = series.get("yData");
        xdata = series.get("xAxis").get("keys")[categoryKey];
    }
}
  [ 2 posts ]
Display posts from previous:  Sort by  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum