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

Message ListMessage List     Post MessagePost Message

  Plot mean point
Posted by Victor on Dec-23-2016 20:00
Hi,

I want plot a LineLayer and every 10 samples, a big point with the mean of last 10 samples.

I add the linelayer:

LineLayer *layer = chart->addLineLayer();

What is better for the mean point? A line chart with missing values or a scatter chart with a circle image?

  Re: Plot mean point
Posted by Peter Kwan on Dec-24-2016 00:32
Hi Victor,

I would use a scatter chart with a circle symbol (or any symbol shape you like). It is like:

std::vector<double> scatterDataY;
std::vector<double> scatterDataX;

for (int i = 10; i <= myLineDataCount; i += 10)
{
    scatterDataY.push_back(std::accumulate(myLineData + (i - 10), myLineData + i, 0.0) / 10);
    scatterDataX.push_back(myLineDataX[i - 1]);
}

c->addScatterLayer(DoubleArray(&(scatterDataX[0]), scatterDataX.size()),
    DoubleArray(&(scatterDataY[0]), scatterDataY.size()), "", Chart::CircleSymbol, 11,
    0xff0000, 0xff0000);

*** NOTE ***: I have not tried the code myself. It may have bugs and you may need to debug it. The above assumes myLineData and myLineDataX are of type "double *". If your code does not use x-coordinates, then just replace "myLineDataX[j]" with "j".

Hope this can help.

Regards
Peter Kwan