Bind color to a specific xvalue in an asp.net chart using xml

kurtz

New Member
I have created an ASPx Pie Chart and am struggling a bit with getting the colors right. Important to note is that I do not have control over the back-end code (3rd party) at all and am therefore limited to XML modifications only (Microsoft Dynamics CRM).The problem is that I want to use colours indicating a certain status of the records returned (e.g. number of days a book is overdue in the library). I want to have a siutation like this:0-5 days late (= code 0) ----> green5-10 days late (= code 1) ----> yellow10-15 days late (= code 2) ----> orange\[code\]>15 days late (= code 3) ----> red\[/code\]The data I am receiving from the server is for example:Code (days late) Count (books)0 42 53 14This works when I use the PaletteCustomColors attribute and specify the colours like this:\[code\]<Chart Palette="None" PaletteCustomColors="149,189,66; 255,255,0; 255,136,35; 197,56,52; 117,82,160; 55,118,193; 168,203,104; 142,116,178; 93,186,215; 255,155,83"> <Series> <Series ShadowOffset="0" IsValueShownAsLabel="True" Font="{0}, 9.5px" LabelForeColor="59, 59, 59" CustomProperties="PieLabelStyle=Inside, PieDrawingStyle=Default" ChartType="pie"> <SmartLabelStyle Enabled="True" /> </Series> </Series> <ChartAreas> <ChartArea> <Area3DStyle Enable3D="true" /> </ChartArea> </ChartAreas> <Legends> <Legend Alignment="Center" LegendStyle="Table" Docking="right" IsEquallySpacedItems="True" Font="{0}, 11px" ShadowColor="0, 0, 0, 0" ForeColor="59, 59, 59" /> </Legends> <Titles> <Title Alignment="TopLeft" DockingOffset="-3" Font="{0}, 13px" ForeColor="0, 0, 0"></Title> </Titles></Chart>\[/code\]However, this does not work when a certain code is not present. In this case the colors will be:Code 0 -> green,Code 2 -> yellow,Code 3 -> organgeSo since no Code 1 result was returned (as the count for this code is 0 no result is returned from the app), code 2 takes the first remaining color, code 3 taks the color after that, ... Which is not what I want, I want the colors to be bound to their Code property.I have tried using DataPoints for this (see code below), but to no avail... Does anyone have any decent solution?\[code\] <Chart> <Series> <Series ShadowOffset="0" IsValueShownAsLabel="True" Font="{0}, 9.5px" LabelForeColor="59, 59, 59" CustomProperties="PieLabelStyle=Inside, PieDrawingStyle=Default" ChartType="pie"> <SmartLabelStyle Enabled="True" /> <Points> <DataPoint XValue="http://stackoverflow.com/questions/11229827/0" Color="Green" /> <DataPoint XValue="http://stackoverflow.com/questions/11229827/1" Color="Yellow" /> <DataPoint XValue="http://stackoverflow.com/questions/11229827/2" Color="Orange" /> <DataPoint XValue="http://stackoverflow.com/questions/11229827/3" Color="Red" /> <DataPoint XValue="http://stackoverflow.com/questions/11229827/4" Color="Purple" /> </Points> </Series> </Series> <ChartAreas> <ChartArea> <Area3DStyle Enable3D="true" /> </ChartArea> </ChartAreas> <Legends> <Legend Alignment="Center" LegendStyle="Table" Docking="right" IsEquallySpacedItems="True" Font="{0}, 11px" ShadowColor="0, 0, 0, 0" ForeColor="59, 59, 59" /> </Legends> <Titles> <Title Alignment="TopLeft" DockingOffset="-3" Font="{0}, 13px" ForeColor="0, 0, 0"></Title> </Titles></Chart>\[/code\]Thanks!
 
Back
Top