Sunday, December 07, 2008

Instead of using colors...

In my last post I had a go at creating a color array for related segments in a pie chart....

But actually.... using the same color but a different hatch style works much better:

private static List HatchArray = new List()
{
ChartHatchStyle.None,
ChartHatchStyle.Percent10,
ChartHatchStyle.Percent20,
ChartHatchStyle.Percent30,
ChartHatchStyle.Percent40,
ChartHatchStyle.Percent50,
ChartHatchStyle.SmallCheckerBoard,
ChartHatchStyle.Trellis,
ChartHatchStyle.ZigZag,
ChartHatchStyle.Wave,
ChartHatchStyle.LargeConfetti,
ChartHatchStyle.DottedDiamond,
ChartHatchStyle.Cross,
ChartHatchStyle.OutlinedDiamond
};


coupled with:

int runListColorIndex = 0;
int bikeListColorIndex = 0;
int swimListColorIndex = 0;
foreach (DataPoint p in series.Points)
{
ChartHatchStyle hatchStyle = ChartHatchStyle.None;
Color colorToUse = Color.ForestGreen;
switch (p.AxisLabel[0])
{
case 'R':
colorToUse = myCurrentFilterOptions.RunColor;
hatchStyle = HatchArray[runListColorIndex];
runListColorIndex++;
runListColorIndex %= HatchArray.Count;
break;

case 'B':
colorToUse = myCurrentFilterOptions.BikeColor;
hatchStyle = HatchArray[bikeListColorIndex];
bikeListColorIndex++;
bikeListColorIndex %= HatchArray.Count;
break;

case 'S':
colorToUse = myCurrentFilterOptions.SwimColor;
hatchStyle = HatchArray[swimListColorIndex];
swimListColorIndex++;
swimListColorIndex %= HatchArray.Count;
break;
}
p.Color = colorToUse;
p.BackHatchStyle = hatchStyle;
}

No comments:

Post a Comment