|
Associate dataset to 2nd xAxis2 |
Posted by Chuck Willette on Feb-08-2012 23:01 |
|
Code Fragment:
// Add a horizontal layer to the chart
LineLayer *hlayer = c->addLineLayer();
hlayer->addDataSet(DoubleArray(hdata, IRES), 0x008800,"X-Axis Irradiation");
// Add a vertical layer to the chart
LineLayer *vlayer = c->addLineLayer();
vlayer->addDataSet(DoubleArray(vdata, JRES),
c->dashLineColor(0x3333ff, Chart::DashLine), "Y-Axis Irradiation");
// vlayer->setXData2(0,JRES); //class "LineLayer has no member "setXdata2"
//c->xAxis()->setLinearScale(0, biggest, 10, 0);
c->xAxis()->setLinearScale(0, IRES, 10, 0);
c->xAxis2()->setLinearScale(0, JRES, 10, 0);
How can I make a second data set use xAxis2 instead of xAxis? The code fragment above
causes both datasets (hdata and vdata) to use xAxis. I want data to use xAxis and vdata to
use xAxis2.
Also, vlayer->setData2(0,JRES) causes an unexplained compile error.
Regards,
Chuck |
Re: Associate dataset to 2nd xAxis2 |
Posted by Peter Kwan on Feb-09-2012 01:20 |
|
Hi Chuck,
In ChartDirector, all data series must use the primary x-axis. This should not cause any limitation, but may require the developer to structure their code to fit this requirement.
Usually, the reason to plot two data series in the same chart is so that you can compare them somehow. If two data series are independent in both the x and y axes, then they cannot be compare, because their relative position becomes arbitrarily. So there must be a shared axis. In ChartDirector, the shared axis must be the primary x-axis.
In your case, there are several approach to meet the above requirement. For example, you may use:
vlayer->setXData(0, IRES);
c->xAxis()->setLinearScale(0, IRES, 10, 0);
c->xAxis2()->setLinearScale(0, JRES, 10, 0);
So what happens is that the vlayer is spread across the chart (because the primary x-axis is from 0 to IRES (actually, I think it may be more appropriate to change IRES to IRES - 1 and JRES to JRES - 1 in the above code). This would be visually the same if your use setXData(0, JRES) and binds to the secondary x-axis. Your code still shows the secondary x-axis.
For the setXData2, sorry for the confusion. In C++, the methods are overloaded, and the actual method name is setXData. (In the setXData2 documentation, in the "Usage" section, it displays that the actual method name is setXData.)
Hope this can help.
Regards
Peter Kwan |
|