Note that there are some explanatory texts on larger screens.

plurals
  1. POBind color to a specific xvalue in an asp.net chart using xml
    text
    copied!<p>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).</p> <p>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:</p> <p>0-5 days late (= code 0) ----> green</p> <p>5-10 days late (= code 1) ----> yellow</p> <p>10-15 days late (= code 2) ----> orange</p> <pre><code>&gt;15 days late (= code 3) ----&gt; red </code></pre> <p>The data I am receiving from the server is for example:</p> <p>Code (days late) Count (books) 0 4 2 5 3 14</p> <p>This works when I use the <strong>PaletteCustomColors</strong> attribute and specify the colours like this:</p> <pre><code>&lt;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"&gt; &lt;Series&gt; &lt;Series ShadowOffset="0" IsValueShownAsLabel="True" Font="{0}, 9.5px" LabelForeColor="59, 59, 59" CustomProperties="PieLabelStyle=Inside, PieDrawingStyle=Default" ChartType="pie"&gt; &lt;SmartLabelStyle Enabled="True" /&gt; &lt;/Series&gt; &lt;/Series&gt; &lt;ChartAreas&gt; &lt;ChartArea&gt; &lt;Area3DStyle Enable3D="true" /&gt; &lt;/ChartArea&gt; &lt;/ChartAreas&gt; &lt;Legends&gt; &lt;Legend Alignment="Center" LegendStyle="Table" Docking="right" IsEquallySpacedItems="True" Font="{0}, 11px" ShadowColor="0, 0, 0, 0" ForeColor="59, 59, 59" /&gt; &lt;/Legends&gt; &lt;Titles&gt; &lt;Title Alignment="TopLeft" DockingOffset="-3" Font="{0}, 13px" ForeColor="0, 0, 0"&gt;&lt;/Title&gt; &lt;/Titles&gt; &lt;/Chart&gt; </code></pre> <p><strong>However,</strong> this does not work when a certain code is not present. In this case the colors will be:</p> <p>Code 0 -> green, Code 2 -> yellow, Code 3 -> organge</p> <p>So 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, ... <strong>Which is not what I want, I want the colors to be bound to their Code property.</strong></p> <p>I have tried using DataPoints for this (see code below), but to no avail... Does anyone have any decent solution?</p> <pre><code> &lt;Chart&gt; &lt;Series&gt; &lt;Series ShadowOffset="0" IsValueShownAsLabel="True" Font="{0}, 9.5px" LabelForeColor="59, 59, 59" CustomProperties="PieLabelStyle=Inside, PieDrawingStyle=Default" ChartType="pie"&gt; &lt;SmartLabelStyle Enabled="True" /&gt; &lt;Points&gt; &lt;DataPoint XValue="0" Color="Green" /&gt; &lt;DataPoint XValue="1" Color="Yellow" /&gt; &lt;DataPoint XValue="2" Color="Orange" /&gt; &lt;DataPoint XValue="3" Color="Red" /&gt; &lt;DataPoint XValue="4" Color="Purple" /&gt; &lt;/Points&gt; &lt;/Series&gt; &lt;/Series&gt; &lt;ChartAreas&gt; &lt;ChartArea&gt; &lt;Area3DStyle Enable3D="true" /&gt; &lt;/ChartArea&gt; &lt;/ChartAreas&gt; &lt;Legends&gt; &lt;Legend Alignment="Center" LegendStyle="Table" Docking="right" IsEquallySpacedItems="True" Font="{0}, 11px" ShadowColor="0, 0, 0, 0" ForeColor="59, 59, 59" /&gt; &lt;/Legends&gt; &lt;Titles&gt; &lt;Title Alignment="TopLeft" DockingOffset="-3" Font="{0}, 13px" ForeColor="0, 0, 0"&gt;&lt;/Title&gt; &lt;/Titles&gt; &lt;/Chart&gt; </code></pre> <p>Thanks!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload