Page 1 of 1

Crash in bar chart

Posted: Thu Dec 04, 2003 3:43 pm
by 6928507
Hi
Im using Tchart version 5.0.6.0, VC++ 6.0. Im getting an exception fired in debug mode, if I
1) Create a bar chart
2) Turn on color each point
3) Open the editor dialog and select the Data tab.

Note* This only happends when the color each point property is set to true.

I think theres an exception fired somewhere, probably when the it tries to fill in the data in the color column of the data table. I have not tried this in relase mode, so Im not sure if its isolated to debig only.

Heres my code snippet

const xercesc::DOMElement* elem = someXmlelement

vector<double> x;
vector<double> y;
create2Ddata(elem,x,y);

assert(x.size() == y.size());

int id = chartCtrl->AddSeries(scBar);

//horiz line is derived from line, so we can set style on line
//for both types
CBarSeries barChart = chartCtrl->Series(id).GetAsBar();

//get the percent width of the bars from xml file
//this will be first child of current element node
XMLCh* val;
wchar_t** stopStr = 0;
ChartUtils::getFirstChildNode(elem,ChartXmlString::percentBarWidthStr(),val);
double barWidth = 50;
if(val) barWidth = wcstod(val,stopStr);

//set bar width. Clip width to deal with roundoff
if(barWidth < 0.0) barWidth = 0.0;
if(barWidth > 100.0) barWidth = 100.0;
barChart.SetBarWidthPercent(barWidth);

//set style of bar chart to rectangular gradient
barChart.SetBarStyle(bsRectGradient);


//disable repaint while adding data.
chartCtrl->SetAutoRepaint(FALSE);

int len = x.size();
for(int i=0; i<len; ++i)
{
chartCtrl->Series(id).AddXY(x,y,"",clTeeColor);
}

//turn off marks on top of bars
chartCtrl->Series(id).GetMarks().SetVisible(FALSE);
chartCtrl->Series(id).SetColorEachPoint(TRUE);

//reactivate autorepaint and repaint
chartCtrl->SetAutoRepaint(TRUE);
chartCtrl->Repaint();

Posted: Thu Dec 04, 2003 4:43 pm
by 6928507
This happens in relase mode and with other charts (line etc). This is a very nasty problem for us. This also happends if i use the tchart 5 demo

Posted: Wed Dec 10, 2003 4:01 pm
by Chris
Hi -
Note* This only happends when the color each point property is set to true.

I think theres an exception fired somewhere, probably when the it tries to fill in the data in the color column of the data table. I have not tried this in relase mode, so Im not sure if its isolated to debig only.
I'm afraid I'm having diffculty reproducing this one here with TeeChart AX v5.0.6.0 and a simple MFC exe VC++6.0 project. Following is the code I'm using:

Code: Select all

void CVCplus6AXv5Dlg::OnShowWindow(BOOL bShow, UINT nStatus) 
{
	CDialog::OnShowWindow(bShow, nStatus);
	m_Chart1.AddSeries(scBar);
	m_Chart1.SetAutoRepaint(FALSE);
	for(double i =0; i < 20; ++i) {
		m_Chart1.Series(0).AddXY(i, rand() * 100, "", clTeeColor);
	}	

	m_Chart1.Series(0).SetColorEachPoint(TRUE);
	m_Chart1.Series(0).GetMarks().SetVisible(FALSE);

	m_Chart1.SetAutoRepaint(TRUE);
	m_Chart1.Repaint();

}

void CVCplus6AXv5Dlg::OnButton1() 
{
	m_Chart1.ShowEditor(0);
}
Could you please modify the above example, or send me a simple project ([email protected]) that I can run "as-is", so that I can reproduce the problem here?

Many thanks.

Posted: Wed Dec 10, 2003 4:25 pm
by 6928507
Ill will try and create a simple example, to replicate the problem. In the mean while, I can get this to happen if with teechart 5 demo.

welcome->New Features->Chart->Axes->Labels->Milleseconds.

Select the editor dialog, select series tab then select color each checkbox. Pick the data Tab on the main dialog

Posted: Wed Dec 10, 2003 5:10 pm
by Chris
Hi -
Ill will try and create a simple example, to replicate the problem. In the mean while, I can get this to happen if with teechart 5 demo.
No, that's alright, I've got it now. This appears to be a defect that occurs when the series XValues are outside of the range produced by the FillSampleValues method (i.e. if the XValues are anything other than 0, 1, 2, 3, 4 etc.). For example, I can make the code example I sent you fall over by changing:

Code: Select all

for(double i =0; i < 20; ++i) { 
      m_Chart1.Series(0).AddXY(i, rand() * 100, "", clTeeColor); 
   } 
to:

Code: Select all

for(double i =1; i < 20; ++i) {  //changed from 0 to 1
      m_Chart1.Series(0).AddXY(i, rand() * 100, "", clTeeColor); 
   } 
This problem also occurs in TeeChart AXv6 and as such I have added it to our list of defects.