Hi
I'm hoping to get help with something that is probably easy to achieve ...
I would like to replicate an Excel style 100% Stacked Bar chart as per the attached example but just can't figure out what to do.
I've experimented with a 2D StackedBarChart but with the tabular data being used I get a separate row on the y axis for each range. Effectively I want a single row on the y axis consisting of the different range values in series.
Ideally I'd also like to use specific colours for range values so that '0 - 39 (Critical)' is red, '95 - 100 (Very Good)' is green and so on. Perhaps that should be a separate quesion to be asked after I get the basic chart layout working.
Any tips to point me in the right direction would be very much appreciated.
Adrian
That has sorted it out for me, thanks very much Hristo.
Hello ,
I have modify the sample base on your code snipped and your requirements. Pease run the sample and let me know if this is what you are looking for.
Please let me know if you have any further questions.
Hi Hristo
Apologies for not having replied to your previous post.
I'm very nearly there now but have one small issue left to resolve. I have a class 'StackChartValueRender' implementing the 'IRenderLabel' interface which I'm hooking up to in the chart load event handler (see code snippets below).
When the chart is first displayed, just the DATA_VALUE_ITEM values are shown but if I move the mouse over the chart then suddenly the desired format with percentage is shown. It's as if the custom format only comes into play on some sort of refresh.
Thanks again for your help.
In the chart load event handler:
Hashtable stackChartValueHashTable = new Hashtable(); stackChartValueHashTable.Add("PC_VALUE", new StackChartValueRenderer()); ucCiGeneral.LabelHash = stackChartValueHashTable; ucCiGeneral.Axis.X.Labels.ItemFormat = AxisItemLabelFormat.Custom; ucCiGeneral.Axis.Y.Labels.ItemFormat = AxisItemLabelFormat.Custom; ucCiGeneral.Axis.X.Labels.ItemFormatString = "<PC_VALUE>"; ucCiGeneral.Axis.Y.Labels.ItemFormatString = "<PC_VALUE>";
IRenderLabel class:
public class StackChartValueRenderer : Infragistics.UltraChart.Resources.IRenderLabel { public string ToString(Hashtable context) { if (context["DATA_ROW"] != null) { double dataValueItem = (double)context["DATA_VALUE_ITEM"]; double totalValue = (double)context["DATA_VALUE_ACCUMULATED_ELEMENT"]; double percentage = (((dataValueItem > 0) && (totalValue > 0)) ? dataValueItem / totalValue : 0); return (String.Format("{0}{1}({2:0.0%})", dataValueItem, Environment.NewLine, percentage)); } return ((double)context["DATA_VALUE_ITEM"]).ToString(); } }
Hi,
I just wanted to know if you were able to solve your issue based on my suggestions or you still need help? Just let me know.
Thank you.
You could achieve your goal if you use IRenderLabel Interface. On the following link you will find a tutorial how to “Customize Labels Using the IRenderLabel Interface”:
http://help.infragistics.com/Help/NetAdvantage/WinForms/2010.2/CLR2.0/html/Chart_Customize_Labels_Using_the_IRenderLabel_Interface.html
please let me know if you have any further questions.