Page 1 of 1

Legend shows wrong colors for Surface Series

Posted: Tue Feb 15, 2011 1:03 pm
by 15053905
Hi,
I am using TeeChart pro V8.0.0.6 Version v Active x, C++.
I am trying to use 3D Surface Series with my own pallets. as described in the code bellow.
The problem is that the surface colors are correct in the plot, but the legend shows the correct values(1,11,21,31) as defined in the calls to AddPalette(...) but he colors are different that the ones in the calls to AddPalette(...). It seems to be that the legend is using another palette for the chart.
1. Why do I get the wrong colors?
2. Is there a full example of using SurfaceSeries in C++ Active X?
Thanks;
YVB

Code: Select all

	m_Chart.Series(m_lSeriesId).GetAsSurface().ClearPalette();
	m_Chart.Series(m_lSeriesId).GetAsSurface().AddPalette(1, RGB(0, 00, 0));
	m_Chart.Series(m_lSeriesId).GetAsSurface().AddPalette(11, RGB(255, 0, 0));
	m_Chart.Series(m_lSeriesId).GetAsSurface().AddPalette(21, RGB(0, 255, 0));
	m_Chart.Series(m_lSeriesId).GetAsSurface().AddPalette(31, RGB(0, 0, 255));

	m_Chart.Series(m_lSeriesId).GetAsSurface().AddXYZ(1, 0, 2,"",m_Chart.Series(m_lSeriesId).GetAsSurface().GetSurfacePaletteColor(0));
	m_Chart.Series(m_lSeriesId).GetAsSurface().AddXYZ(2, 10, 3,"",m_Chart.Series(m_lSeriesId).GetAsSurface().GetSurfacePaletteColor(10));
	m_Chart.Series(m_lSeriesId).GetAsSurface().AddXYZ(3, 20, 4,"",m_Chart.Series(m_lSeriesId).GetAsSurface().GetSurfacePaletteColor(20));
	m_Chart.Series(m_lSeriesId).GetAsSurface().AddXYZ(4, 30, 5,"",m_Chart.Series(m_lSeriesId).GetAsSurface().GetSurfacePaletteColor(30));

	m_Chart.Series(m_lSeriesId).GetAsSurface().SetUsePalette(true);
	m_Chart.GetLegend().GetSymbol().SetSquared(true);
	m_Chart.Repaint();

Re: Legend shows wrong colors for Surface Series

Posted: Thu Feb 17, 2011 12:16 pm
by 10050769
Hello

I recommend you update your TeeChart ActiveX version 8 for last Build that you can find in page download. When you have update your version, please try again if your problem persist and if it still appears please try to send us a simple project we can run as-is to reproduce the problem here so we can help you find a good solution.

Thanks,

Re: Legend shows wrong colors for Surface Series

Posted: Wed Feb 23, 2011 7:48 am
by 15053905
Hi Sandra,
I prepared a project using TeeChart pro v8.0.0.8. The problem was not solved.
How do I send the project to you? I don't see any possibility for an attachemnt here.
Thanks,
yvb

Re: Legend shows wrong colors for Surface Series

Posted: Wed Feb 23, 2011 8:00 am
by narcis
Hi yvb,

Yes, this forums board allows attachments at the bottom of the messages you'll see an "upload attachment option. Otherwise you can post them at our upload page.

Thanks in advance.

Re: Legend shows wrong colors for Surface Series

Posted: Wed Feb 23, 2011 2:51 pm
by 15053905
Attached is the file containing the solution in VS 2008 of my code.
I switched to TeeCahrt pro v8.0.0.8. But it didn’t help.

When executing to application click the “Test 3D Compact” button from the dialogue window.
The code using TChart is in CTchartDisplay::test3D_Compact() and CTchartDisplay::OnAfterDrawTchart1().

I am trying to do two things:
1. Display a 2D color Grid where each cell color represents a value in a specific range.
2. Draw a rotated ellipse over the grid.
I tried to implement thus by using Surface series, where the coordinate system was rotated by 270 degrees
Around the X axis, so the chart is viewed as 2D XZ coordinate system from the Y axis direction. The value Y for each XZ grid
point is displayed at a corresponding color that I defined in a color palette.
My problems/questions are:
1. The legend does not show the correct colors, but it shows the correct value ranges. How can I fix it?
2. How do I draw a rotated ellipse on the grid that is on the XZ plane? The RotatedEllipse() function draws the ellipse on the XY plane ( or parallel to it) so only it’s projection is seen on the grid as a red line.
3. How can I get the value of a Z coordinate in pixels, similar to CalcXPosValue(…) ?. This may enable me to draw shapes in the XZ plane.
4. Will the usage of ColorGrid Series instead of Surface Series simplify things and solve some of the problems?

Thanks,
yvb

Re: Legend shows wrong colors for Surface Series

Posted: Mon Feb 28, 2011 1:20 pm
by 10050769
Hello yvb,
1. The legend does not show the correct colors, but it shows the correct value ranges. How can I fix it?
I recommend you use property ColorRange, and change it to false as do in below lines of code:

Code: Select all

	m_Chart.Series(0).GetAsSurface().SetUseColorRange(false);
My problems/questions are:
2. How do I draw a rotated ellipse on the grid that is on the XZ plane? The RotatedEllipse() function draws the ellipse on the XY plane ( or parallel to it) so only it’s projection is seen on the grid as a red line.
3. How can I get the value of a Z coordinate in pixels, similar to CalcXPosValue(…) ?. This may enable me to draw shapes in the XZ plane.
4. Will the usage of ColorGrid Series instead of Surface Series simplify things and solve some of the problems?
Yes, if you use ColorGrid, the problems that you have when you draw ellipse disappears. I have made a simple code for your using a ColorGrid Series instead of Surface Series and works fine for me here. Please, check if next code works as you want:

InitializeChart:

Code: Select all

void CTchartDisplay::test3D_Compact()
{
	m_Chart.GetAspect().SetView3D(false);
  
	m_Chart.AddSeries(scColorGrid);
	m_Chart.Series(0).FillSampleValues(13);
	m_Chart.Series(0).GetPen().SetColor(RGB(0,255,255));
	m_Chart.GetEnvironment().InternalRepaint();
	m_Chart.GetLegend().GetSymbol().SetSquared(true);

	m_Chart.GetCanvas().GetPen().SetColor(RGB(255,0,0));
	m_Chart.GetCanvas().GetPen().SetWidth(2);
}
AfterDraw Event:

Code: Select all

		
void CTchartDisplay::OnAfterDrawTchart1()
{
m_Chart.GetCanvas().GetPen().SetColor(RGB(255,0,0));
	m_Chart.GetCanvas().GetPen().SetWidth(2);

	long x1 = m_Chart.GetAxis().GetTop().CalcXPosValue(4.0);
	long y1 = m_Chart.GetAxis().GetLeft().CalcYPosValue(5.0);
	long x2 = m_Chart.GetAxis().GetBottom().CalcXPosValue(6.0);
	long y2 = m_Chart.GetAxis().GetRight().CalcYPosValue(7.0);
	m_Chart.GetCanvas().RotatedEllipse(y1,x1,y2,x2,100, 0);

 }
I hope will helps.

Thanks,

Re: Legend shows wrong colors for Surface Series

Posted: Thu Mar 03, 2011 7:08 am
by 15053905
Hi,
Thanks Sandra, everything works now in my application.

Best regards,
yvb

Re: Legend shows wrong colors for Surface Series

Posted: Thu Mar 03, 2011 9:22 am
by 10050769
Hello yvb,

I am glad that your problems are solved :).

Thanks,