Bar chart isn't in color (mostly)

TeeChart for ActiveX, COM and ASP
Post Reply
manelson
Newbie
Newbie
Posts: 2
Joined: Thu Oct 02, 2008 12:00 am

Bar chart isn't in color (mostly)

Post by manelson » Mon Aug 10, 2009 11:14 pm

OK, I've searched the forums & help for SetColor(), GetAsBar(), and other topics but these topics aren't there.

I am trying to plot a barchart in color, but I can't get main part of the bar-chart to plot in color. I can get the border to change colors, but not the main box of color.

I've tried every combination in the TeeChart editing dialog box Series->Series0->Format tab->Format tab to try to get any other color than black on the bar graph but no luck.

I also tried setting the color parameters during runtime but that didn't work either.

I use a very simple code on this test

Code: Select all

void CTeeChartTestDlg::OnBnClickedOk()
{
	// TODO: Add your control notification handler code here
	unsigned int i, I = 20;
	for(i=0; i<I; i++) {
		m_Chart1.Series(0).AddXY(i,i, L"", 0);
		m_Chart1.Series(1).AddXY(i, I-i, L"", 0);
	}
}
I'm using a simple non-3D graph but what I don't know what I'm missing. I've attached screenshots of the settings in the settings editor and a screenshot of what I get.

The border on series0 is not set (i.e. no boarder on series0) but you can see that the border comes out correctly on series1.

btw: For line-graphs I can get the colors to come out fine, just not bar charts.

Compiler: Visual Studio C++ 2008
TeeChart: TeeChart Pro v8 ActiveX
Attachments
Graph 01.jpg
Graph 01.jpg (115.82 KiB) Viewed 13693 times
Pattern Color Editor 01.jpg
Pattern Color Editor 01.jpg (34.13 KiB) Viewed 13686 times
Editing - Series0.jpg
Editing - Series0.jpg (56.5 KiB) Viewed 13694 times

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Bar chart isn't in color (mostly)

Post by Yeray » Tue Aug 11, 2009 8:40 am

Hi manelson,

The problem is that you are a assigning a color to each point when adding data to the series. Therefore you can not change series color if each point has been assigned a color individually.

So that it works as you request you should use clTeeColor constant as the color in the AddXY method when populating your series. Then you could set series color both at runtime or in the editor.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

manelson
Newbie
Newbie
Posts: 2
Joined: Thu Oct 02, 2008 12:00 am

Re: Bar chart isn't in color (mostly)

Post by manelson » Tue Aug 11, 2009 6:19 pm

Thanks, that was it.

Otokon
Newbie
Newbie
Posts: 25
Joined: Thu Sep 18, 2008 12:00 am

Re: Bar chart isn't in color (mostly)

Post by Otokon » Tue Sep 01, 2009 10:51 am

Hi,

Could anyone assist me in the following:

I'm trying to set a specific series color, but the convention of type Color to uint isn't correct. Any suggestions?

P.S This is my code in C#

TChart.Series(0).Color = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(Color.Red));

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Bar chart isn't in color (mostly)

Post by Yeray » Tue Sep 01, 2009 11:20 am

Hi Otokon,

In C# it's easier:

Code: Select all

tChart1.Series[0].Color = Color.Red;
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Otokon
Newbie
Newbie
Posts: 25
Joined: Thu Sep 18, 2008 12:00 am

Re: Bar chart isn't in color (mostly)

Post by Otokon » Tue Sep 01, 2009 11:25 am

Thanks for the quick reply.

I'm getting the error "Cannot implicitly convert type 'System.Drawing.Color' to 'uint' "

That's why I'm trying to convert in to uint...? Am i missing something..?

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Bar chart isn't in color (mostly)

Post by Yeray » Tue Sep 01, 2009 12:01 pm

Hi Otokon,

The following code seems to work fine in AX under C#:

Code: Select all

axTChart1.Series(0).Color = Convert.ToUInt32(ColorTranslator.ToOle(Color.Red));
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Otokon
Newbie
Newbie
Posts: 25
Joined: Thu Sep 18, 2008 12:00 am

Re: Bar chart isn't in color (mostly)

Post by Otokon » Tue Sep 01, 2009 12:22 pm

Hi Yeray,

Sorry, but I'm still in the dark. I'm using VS 2005 with TeeChart 8 ActiveX.

Here is the complete block of code I'm trying to use:

Code: Select all

TeeChart.TChart MyChart = new TeeChart.TChart();

MyChart.AddSeries(TeeChart.ESeriesClass.scBar);
MyChart.Series(0).Marks.Visible = false;
MyChart.Series(0).Pen.Visible = false;
MyChart.Series(0).asBar.MultiBar = TeeChart.EMultiBar.mbStacked;
MyChart.Series(0).asBar.BarWidthPercent = 100;


MyChart.Series(0).Color = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(Color.Red));

MyChart.Series(0).AddXY(1,23,"Peter",(uint)TeeChart.EConstants.clTeeColor);

MyChart.Series(0).AddXY(1,34,"Jerry",(uint)TeeChart.EConstants.clTeeColor);
Do you spot anything wrong?

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Bar chart isn't in color (mostly)

Post by Yeray » Tue Sep 01, 2009 2:02 pm

Hi Otokon,

And could you please explain what is the expected result? I can see the whole bar red with your code. I think that a picture would be very helpful.
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Otokon
Newbie
Newbie
Posts: 25
Joined: Thu Sep 18, 2008 12:00 am

Re: Bar chart isn't in color (mostly)

Post by Otokon » Tue Sep 01, 2009 2:18 pm

Hi Yeray,

The result your are getting would be the desired result. But at my side I'm not getting that same result.

I found something interesting regarding my problem I'm having. When I set a series color to a non class default color it works correctly, for example:

Code: Select all

MyChart.Series(0).Color = 254; //Works fine, and I see a red series

MyChart.Series(1).Color = 255; //Doesn't work, and series does not change to clred

Otokon
Newbie
Newbie
Posts: 25
Joined: Thu Sep 18, 2008 12:00 am

Re: Bar chart isn't in color (mostly)

Post by Otokon » Tue Sep 01, 2009 2:20 pm

PS the 255 should first be converted to a uint.....

Yeray
Site Admin
Site Admin
Posts: 9614
Joined: Tue Dec 05, 2006 12:00 am
Location: Girona, Catalonia
Contact:

Re: Bar chart isn't in color (mostly)

Post by Yeray » Wed Sep 02, 2009 11:17 am

Hi Otokon,

Are you using the latest version available (8.0.0.6)? Here using that version under VS2005 the following code shows one red bar:

Code: Select all

        private void InitializeChart()
        {
            MyChart.AddSeries(TeeChart.ESeriesClass.scBar);
            MyChart.Series(0).Marks.Visible = false;
            MyChart.Series(0).Pen.Visible = false;
            MyChart.Series(0).asBar.MultiBar = TeeChart.EMultiBar.mbStacked;
            MyChart.Series(0).asBar.BarWidthPercent = 100;

            MyChart.Series(0).Color = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(Color.Blue));
            MyChart.Series(0).Color = 255;

            MyChart.Series(0).AddXY(1, 23, "Peter", (uint)TeeChart.EConstants.clTeeColor);
            MyChart.Series(0).AddXY(1, 34, "Jerry", (uint)TeeChart.EConstants.clTeeColor);
        }
Best Regards,
ImageYeray Alonso
Development & Support
Steema Software
Av. Montilivi 33, 17003 Girona, Catalonia (SP)
Image Image Image Image Image Image Please read our Bug Fixing Policy

Otokon
Newbie
Newbie
Posts: 25
Joined: Thu Sep 18, 2008 12:00 am

Re: Bar chart isn't in color (mostly)

Post by Otokon » Thu Sep 03, 2009 8:34 am

Hi,

I downloaded version 8.0.0.6 and it seems to be working correctly. But now I have another question.

I have 3 bar series on my chart, the one is Color.Lime the other Color.Blue, but the one I marked with a Red circle is actually Color.Red. Why is this not 255 type Red...?
TCh.png
Color.Red not 255 type Red
TCh.png (14.09 KiB) Viewed 13615 times

Code: Select all

MyChart.Series(0).Color =System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(Color.Red));

Narcís
Site Admin
Site Admin
Posts: 14730
Joined: Mon Jun 09, 2003 4:00 am
Location: Banyoles, Catalonia
Contact:

Re: Bar chart isn't in color (mostly)

Post by Narcís » Thu Sep 03, 2009 8:47 am

Hi Otokon,

I'm not able to reproduce the problem here using code snippet below. Can you please modify it or attach a simple example project we can run "as-is" to reproduce the problem here?

Code: Select all

			axTChart1.Dock = DockStyle.Fill;
			axTChart1.Aspect.View3D = false;

			for (int i = 0; i < 3; i++)
			{
				axTChart1.AddSeries(TeeChart.ESeriesClass.scBar);
				axTChart1.Series(i).asBar.BarWidthPercent = 100;
				axTChart1.Series(i).asBar.MultiBar = TeeChart.EMultiBar.mbSideAll;
				axTChart1.Series(i).asBar.BarPen.Visible = false;
				axTChart1.Series(i).Marks.Visible = false;
				axTChart1.Series(i).FillSampleValues(100);
			}

			axTChart1.Series(0).Color = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(Color.Red));
			axTChart1.Series(1).Color = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(Color.Blue));
			axTChart1.Series(2).Color = System.Convert.ToUInt32(System.Drawing.ColorTranslator.ToOle(Color.Lime));
Thanks in advance.
Best Regards,
Narcís Calvet / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply