Im using Tchart version 5.0.6.0, VC++ 6.0. Attempting to set a sidewall color on a waterfall chart crashes if the data was set using addArrayXYZ.
Setting data points with AddXYZ works ok. I assume this is related to no color set for data points, using the addArrayMethod. Heres my test code snippet. Full test app available on request
Code: Select all
//create chart and add as child of "this" view.
m_chart = new CTChart();
m_chart->Create (CHART_CLASSNAME, "", WS_CHILD, rect, this, IDC_TCHART);
m_chart->SetVisible(TRUE);
//add waterfall
m_chart->AddSeries(scWaterfall);
CWaterfallSeries waterfall = m_chart->Series(0).GetAsWaterfall();
//make irregular
waterfall.SetIrregularGrid(TRUE);
//copy over to safe arrays, first dimension them.
long size = 10;
//create data arrays
COleSafeArray XValues;
COleSafeArray YValues;
COleSafeArray ZValues;
XValues.CreateOneDim(VT_R8, size*size);
YValues.CreateOneDim(VT_R8, size*size);
ZValues.CreateOneDim(VT_R8, size*size);
//create 10x10 data grid. x in increments of 0.22, z integer increments
//y random
long index[1];
for(int ii = 0; ii<size; ++ii)
{
for(int jj = 0; jj<size; ++jj)
{
double val = jj*0.22;
index[0] = jj + ii*size;
XValues.PutElement(index,&val);
val = 0.001*rand();
YValues.PutElement(index,&val);
val = ii;
ZValues.PutElement(index,&val);
}
}
//turn off paint
m_chart->SetAutoRepaint(FALSE);
//==============================
//This code crashed after setting side brush
//==============================
waterfall.AddArrayXYZ(XValues,YValues,ZValues);
//this line will fire an exception if adding data with arrays
//adding data points individually and then setting side color works
waterfall.GetSideBrush().SetColor(RGB(255, 0, 0));
//==============================
//This code works
//==============================
//for(int i =0; i < 10; ++i)
//{
//for(int j = 0; j<10; ++j)
//{
//notice X coord is non - integer, this will crash when data tab selected
//on editor dialog. Change to integer and it will work.
//waterfall.AddXYZ(j*0.22, 0.001*rand(),i,"", clTeeColor);
//}
//}
//this works if data set point by point
//waterfall.GetSideBrush().SetColor(RGB(255, 0, 0));
m_chart->SetAutoRepaint(TRUE);