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

Message ListMessage List     Post MessagePost Message

  How to show xAxis value on my chart if the value exclude xlabel? (MFC)
Posted by Tony on Apr-09-2015 20:16
Hi,


A x label as below:
char *xlabel[] =
{0.7 , 1.2 , 1.3 , 2.5 , 3.1 , 3.4, 3.8 , 4.1, 4.7 , 5.2 , 5.3 , 6.5 , 7.4, 7.8 , 8.1 , 8.7 , 8.9};

but I want  to show only 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 on xAxis of my chart.
How can it only show 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 ? (xlabel can not be modified.)



If it doesn't work.
I will modify xlabel data to
{0 , 0.7 ,1 , 1.2 , 1.3 , 2 , 2.5 , 3 , 3.1 , 3.4, 3.8  , 4 , 4.1, 4.7 ,5, 5.2 , 5.3 , 6 , 6.5 , 7 ,
7.4, 7.8 ,8 , 8.1 , 8.7 , 8.9 , 9}

How can I do to show 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 on xAxis of my chart?



thanks for help.

  Re: How to show xAxis value on my chart if the value exclude xlabel? (MFC)
Posted by Peter Kwan on Jul-07-2007 13:06
Hi Tony,

If you want to show 0, 1, 2, .... 9 on your chart, you should not use 0.7, 1.2, 1.3, ... as
the x-axis labels.

Are these uneven numbers not intended as the axis labels, but are the x-coordinates of
the data points?

Axis labels are text that you want to display on the axis. X-coordinates are numbers that
are used to position the data points. For example, in the "Simple Bar Chart" sample code,
the y-coordinates (the data values) are {85, 156, 179.5, 211, 123}, but the y-axis labels
are {0, 50, 100, 150, 200, 250}. You can see that coordinates and labels are completely
different.

If you want to use 0.7, 1.2, 1.3, as the x-coordinates, you may pass them to your chart
layer using setXData. You may refer to the "Uneven Data Points" sample code for an
example.

http://www.advsofteng.com/doc/cdcpp.htm#unevenpoints.htm

For the x-axis, you can let ChartDirector automatically determine the x-axis labels (just
like how to y-axis labels are automatically determined), or you can use
Axis.setLinearScale to specify the labels. For example:

c->xAxis()->setLinearScale(0, 9, 1);

Hope this can help.

Regards
Peter Kwan

  Re: How to show xAxis value on my chart if the value exclude xlabel? (MFC)
Posted by Tony on Apr-13-2015 18:44
Attachments:
Hi,

The setXData function is OK, thanks!

I want to use Area Chart, and x need to set from 7 to 18.
But the Area Layer appears to be shifted on the chart. (example.jpg)

Sample Code as below:


double data0Y[] = { 100, 69, 53, 58, 84, 76, 49, 61, 64, 77, 79 };
double data0X[] = { 7, 8.9, 10 ,11 ,12 ,13 ,14, 15, 16, 17, 18 };
.
.
c->xAxis()->setLinearScale(7, 18, 1, 1);
.
.
c->addAreaLayer(DoubleArray(data0Y, (int)(sizeof(data0Y) / sizeof(data0Y[0]))));
layer0->setXData(DoubleArray(data0X, (int)(sizeof(data0X) / sizeof(data0X[0]))));
layer0->setLineWidth(3);
.
.
m_Picture.setChart(c);


How can I set the x from 7 to 18 using Area Chart?
Example.jpg

  Re: How to show xAxis value on my chart if the value exclude xlabel? (MFC)
Posted by Peter Kwan on Apr-14-2015 23:39
Hi Tony,

Is it possible to provide more complete code to help me diagnose the problem. For example
in your code:

c->addAreaLayer(DoubleArray(data0Y, (int)(sizeof(data0Y) / sizeof(data0Y[0]))));
layer0->setXData(DoubleArray(data0X, (int)(sizeof(data0X) / sizeof(data0X[0]))));

It is not sure what is "layer0". If the above is really your exact code, the code is correct,
because layer0 is not the area layer, so it will affect the area layer. The correct code
should be:

AreaLayer *myLayer = c->addAreaLayer(DoubleArray(data0Y, (int)(sizeof(data0Y) /
sizeof(data0Y[0]))));
myLayer->setXData(DoubleArray(data0X, (int)(sizeof(data0X) / sizeof(data0X[0]))));
layer0->setLineWidth(3);

In brief, the x-coordinates need to be supplied to the area layer object that contains the y-
coordinates.

Regards
Peter Kwan