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

Message ListMessage List     Post MessagePost Message

  Filter array to display values less than a "cutoff" value?
Posted by John Vella on Aug-23-2024 23:15
I have XY charts where I need to explicitly specify the x-axis data.

My chart (i use CD c++) will add several graph lines, but there are times where some of the lines will be hidden. In those cases, I want to have the X axis data limited to only show the max value of those lines still visible.

My X data is maintained to include the values for ALL of the possible graphs, so it's that array where I want to use some technique to limit which values are used on the "layer->setXData" call. Say for example when all graph lines are shown, the max X value will be the largest value from all of the graph data (say that comes from graph line A). But when graph A is hidden, then the max value would be the next largest without A - make sense?

I don't see anything I could use in the ArrayMath class, but maybe I missed something.

Can I get some help with this?

  Re: Filter array to display values less than a "cutoff" value?
Posted by Peter Kwan on Aug-24-2024 03:49
Hi John,

I think ChartDirector is already doing what you mentioned. From your description, it is not clear how you "hide" a line. To "hide" a line, the best way is not to add the line to the chart. If the line is not added to the chart, ChartDirector does not have the x-data for that line, so it is not possible for ChartDirector to consider those x-data to determine the x-axis scale.

As an example, suppose the code is:

if (showLine1) {
     LineLayer *layer = c->addLineLayer(.....);
     layer1->setXData(DoubleArray(xData1, xData1Count));
}

if (showLine2) {
     LineLayer *layer = c->addLineLayer(.....);
     layer->setXData(DoubleArray(xData2, xData2Count));
}

if both "showLine1 = true;" and "showLine2 = true;", both lines will be added to the chart. If the x-axis is automatically determined by ChartDirector, it will consider the x-coordinates of both lines. If "showLine1 = true", but "showLine2 = false", the second line is "hidden" and will not be added to the chart. ChartDirector can only consider the x-data of the first line.

The above assumes the x-axis is automatically determined by ChartDirector. If your code specifies the x-axis scale directly, such as using Axis::setLinearScale or Axis::setLabels, your code can always use any x-axis scale you like. In this case, ChartDirector will use your specified x-axis scale regardless of the actual data in the layers.

If you must add the line to the chart, even though it is hidden, then it is suggested you use Axis::setLinearScale or Axis::setLogScale or Axis::setDateScale to set the axis scale directly.

Best Regards
Peter Kwan