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

Message ListMessage List     Post MessagePost Message

  C++ version: crash in makeChart
Posted by Rick Issen on Sep-11-2023 22:28
Attachments:
Hi Peter,

CD 7 crashed in this line (see attached picture)

pChart->addLine(xCoor, yCoor, xCoor2, yCoor2, gradient_color, width);

(By the way: is 'gradient_color' a pointer?)

if 'number_of_columns' gets too high:

//
// Draw the line segments
//
if (pColorAxis != NULL && surface_data.m_bSetColorAxis)
{
for (DWORD col = 0; col < number_of_columns - 1; col++)
{
for (DWORD row = 0; row < numer_of_lines - 1; row++)
{
int xCoor = pChart->getXCoor(x_array[row], y_array[row], z_array[row]);
int yCoor = pChart->getYCoor(x_array[row], y_array[row], z_array[row]);

int xCoor2 = pChart->getXCoor(x_array[row + 1], y_array[row + 1], z_array[row + 1]);
int yCoor2 = pChart->getYCoor(x_array[row + 1], y_array[row + 1], z_array[row + 1]);

int startColor = pColorAxis->getColor(z_array[row]);
int endColor = pColorAxis->getColor(z_array[row + 1]);

gradient_color = pChart->linearGradientColor(xCoor, yCoor, xCoor2, yCoor2, startColor, endColor);

pChart->addLine(xCoor, yCoor, xCoor2, yCoor2, gradient_color, width);
}
}
}

Regards,
Rick
crash.png

  Re: C++ version: crash in makeChart
Posted by Peter Kwan on Sep-12-2023 05:12
Hi Rich,

The Subject if your post is "C++ version: crash in makeChart", but in the message you mentioned it crashes on "pChart->addLine(....)". By reading your code, I think if it crashes, it is more likely to crash in makeChart. Is my guess correct?

The gradient_color is a "handle" to a dynamic color (color that can change based on position). There is only a limited number of handles available (around 65000 handles). When this system was designed, we did not foresee any chart will use that many dynamic colors.

For your case, would you mind to clarify the number_of_columns and numer_of_lines you are using? I will try to reproduce the problem.

Best Regards
Peter Kwan

  Re: C++ version: crash in makeChart
Posted by Rick Issen on Sep-12-2023 16:54
Topic: 3D Scatter Plot with Marker & Lines (polyline)

Hi Peter,

Thank you very much for your excellent support...

If you let pChart->addLine(..) away then it works, else crash in makeChart(..)

I'm not sure how many col/rows. I had rows around 50 per series and columns ~ 500. I limited it in the program to columns < 100; then it works fine.

If you get columns > 300 then the gradient 'pColorAxis->setColorGradient(..)' shows also mismatched colors.

Best Regards,
Rick

  Re: C++ version: crash in makeChart
Posted by Peter Kwan on Sep-13-2023 12:00
Hi Rick,

I tested myself. In my case, the chart works normally with 50000 gradients. When I tried 500 x 500 = 250000 gradients, it displays incorrect color, but does not crash.

In any case, it would not work normally if there are too many gradients.

For you case, if you have many line segments, I suppose each segment is short. May be you can try to use a single color for the segment instead of a gradient color. You can simply use the mid-polnt color as the line color:

int lineColor = pColorAxis->getColor((z_array[row] + z_array[row + 1]) / 2);

I notice that in the code in your message, the col variable is not used at all, so it is just repeating drawing the same set of lines many times. I suppose this is not your real code. If your line segments are a kind of grid, may be you can consider to draw it using the surface chart. See:

https://www.advsofteng.com/doc/cdcpp.htm#surfacewireframe.htm

Best Regards
Peter Kwan

  Re: C++ version: crash in makeChart
Posted by Rick Issen on Sep-13-2023 16:28
Hi Peter,

Thanks for your quick reply...

Yes, my code example was not the real one.

In my program you can choose 3D surface plot, 3D normal line color plot and this one here the gradient. As you said, the gradient works with a limited number of gradients. So I left it limited.

Best regards,
Rick