Page 1 of 1

Set Individual Colors on Bar Chart...

Posted: Tue Jan 24, 2006 9:54 pm
by 8719701
I want to set individual colors on a bar chart, but I can't seem to find how. If I convert the bar chart into a pie chart, the chart automatically gets different colors. But it's defaulted to RED on a bar chart.

Can anybody point me in the right direction?


private void seriesHotSpot1_GetHTMLMap(Steema.TeeChart.Tools.SeriesHotspot sender, Steema.TeeChart.Tools.SeriesHotspotEventArgs e)
{
String strDateFrom = txtDate1.Text.ToString();
String strDateTo = txtDate2.Text.ToString();
String strXaxis = Request["xaxis"].ToString();
String strYaxis = Request["yaxis"].ToString();
String strPath = System.Configuration.ConfigurationSettings.AppSettings.Get("Web.Path");
String strLabel = "";

strLabel = e.Series.Labels[e.PointPolygon.ValueIndex];
e.PointPolygon.Title = strLabel;
e.PointPolygon.HREF = strPath + "listview.jsp?Ver=1&Side=Left&X=" + strXaxis + "&Y=" + strYaxis + "&DateFrom=" + strDateFrom + "&DateTo=" + strDateTo + "&Value=" + strLabel;
e.PointPolygon.Attributes = "target='bottomRightFrame'";

switch(e.PointPolygon.ValueIndex)
{
case 0:
//Set Bar color AND legend to BLUE break;
case 1:
//Set Bar color AND legend to RED break;
case 2:

break;
case 3:

break;
case 4:

break;
default:

break;
}
}

Posted: Wed Jan 25, 2006 9:12 am
by narcis
Hi Okie,

The easiest way to do that is setting the colorr for each point when populating the series as shown in the snippet below. You'll have to set ColorEach property to true to enable that behaviour:

Code: Select all

			WebChart1.Chart.Series[0].ColorEach=true;

			WebChart1.Chart.Series[0].Add(3,Color.Blue);
			WebChart1.Chart.Series[0].Add(6,Color.Red);
			WebChart1.Chart.Series[0].Add(7,Color.Green);
			WebChart1.Chart.Series[0].Add(2,Color.Yellow);
			WebChart1.Chart.Series[0].Add(4,Color.White);