The Colors property
The Colors property
I would like to change the colors of the points of a series (i.e. the colors of each slice of a Pie series). I tried to use the Colors property of the Series class to get and set the color for each series point. I found that the Colors property returns an empty collection unless I have set it first. How do I get the color of each series point for a Series after I set the ColorEach property to true? Thank you.
Jeff
Jeff
Hi Jeff
You can use the ValueColor() method, as below code:
You can use the ValueColor() method, as below code:
Code: Select all
for (int i=0;i <pie1.Count;i++)
{
listBox1.Items.Add(pie1.ValueColor(i).ToString());
}
Thanks for the reply.
Another problem is that after I set the color value of an item of the Colors property and then save the chart, the new color is not saved to the file. How do I fix this problem? The following is my code.
Another problem is that after I set the color value of an item of the Colors property and then save the chart, the new color is not saved to the file. How do I fix this problem? The following is my code.
Code: Select all
private void tChart_ClickSeries(object sender, Series s, int valueIndex, MouseEventArgs e)
{
if (e == null || sender == null || s == null) return;
if (e.Clicks == 1)
{
if (s.ColorEach && Control.ModifierKeys == Keys.Control && valueIndex >= 0 && valueIndex <= s.Count)
{
ColorDialog colorDialog = new ColorDialog();
colorDialog.Color = s.ValueColor(valueIndex);
if (colorDialog.ShowDialog() == DialogResult.OK)
{
s.Colors[valueIndex] = colorDialog.Color;
s.Repaint();
}
}
}
else ShowSeriesEditor(s);
}
Hi Jeff
Here It's working fine using the last release (Build 2.0.2652.22325). Which TeeChart version are you using? Could you please try with the last version?
If the problem persist could you please send us a simple example project we can run "as-is" to reproduce the issue here?
You can post your files either at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup or at our upload page
Thanks in advance!
Here It's working fine using the last release (Build 2.0.2652.22325). Which TeeChart version are you using? Could you please try with the last version?
If the problem persist could you please send us a simple example project we can run "as-is" to reproduce the issue here?
You can post your files either at [url]news://www.steema.net/steema.public.attachments[/url] newsgroup or at our upload page
Thanks in advance!
Hi Jeff
I could reproduce the issue here and this seems to be a bug. I've added it (TF02012193) to our defect list to be fixed for future releases.
In the meantime, a workaround can be set the colors with the wish transparency, for example:
I could reproduce the issue here and this seems to be a bug. I've added it (TF02012193) to our defect list to be fixed for future releases.
In the meantime, a workaround can be set the colors with the wish transparency, for example:
Code: Select all
private void Form1_Load(object sender, EventArgs e)
{
bar1.Add(3, Color.FromArgb(255, Color.AliceBlue)); //255 is total opaque
bar1.Add(1, Color.FromArgb(70,Color.AntiqueWhite));
bar1.Add(4, Color.FromArgb(0,Color.Aqua)); //0 is total Transparency
bar1.Add(5, Color.FromArgb(100,Color.Aquamarine));
bar1.Add(3, Color.FromArgb(200,Color.Azure));
}
Hi Jeff
You can accede to each point and change the color, as below code:
You can accede to each point and change the color, as below code:
Code: Select all
for (int i=0;i<bar1.Count;i++)
bar1[i].Color = Color.FromArgb(200, Color.Tomato);