ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  DataSet - no size() method
Posted by Mark on Nov-17-2013 00:18
When using myLayer.getDataSet(idx).getValue(pntr), I can make sure I don't specify an idx
value greater than myLayer.getDataSetCount()-1, but the DataSet class doesn't offer a
count of how many values are in the data set (array), so I cannot protect pntr from
exceeding the number of points in the data set.

It would seem to me that the DataSet object lacks a method called
getDataSetPointsCount().  Without it, I can't safeguard getValue(pntr) against having a
pntr value that is higher than the number of points in the data set.  Is there a way around
this, other than trapping an Exception?

Mark

  Re: DataSet - no size() method
Posted by Peter Kwan on Nov-19-2013 00:51
Hi Mark,

Are you writing a web application or a desktop application?

The data retrival API is not really designed to get back the data that your code already have and passed to ChartDirector. It is designed for supporting the "programmable track cursor".

For a web application, the API may only return a subset of the data. For example, if you have a line with 10000 data points, but the plot area is only 500 pixels wide, ChartDirector may only pass around 500 data points to the browser in the Javascipt Chart Model. It is because the mouse cursor can only point to 500 different positions. The API only ensures you can obtain all data points that the mouse cursor can point at.

So iterating using DataSet.getValue may not get back all the data. If the "pntr" is obtained using the mouse coordinates (eg. using JsXYChart.getNearestXValue), then the "pntr" should be valid.

For a desktop application, the code myLayer.getDataSet(idx).getValue(pntr) is running on the same machine that creates the chart, so your code should already have the data. Your code just need to keep track of it. If you pass an invalid "pntr" to getValue, it will return NoValue. No exception will be thrown. If you are sure your data cannot contain NoValue, then you can treat the returned NoValue to indicate an invalid "pntr".

Regards
Peter Kwan