First off, I'm on version 2006 volume 3.
I originally had a simple line chart showing 2 lines (interest paid for interest rate A in blue and interest rate B in red) over several years. Dollars paid is the Y Axis and Year is the X Axis. Now, I need to show both principle and interest paid in a stacked chart (to show the total amount paid during each year). However, because I have 2 sets of rates (A and B), I'd like my 2 sets of stacks to be "paired" or "side-by-side" for each year.
It would be similar to the demo picture below, except there would only be 2 items (principle and interest) stacked for each bar, and only 2 bars (rates A and B) per year. I'm lost as to how to tell Infragistics exactly what to stack, and what to group together...if it's even possible. Can anyone shed light on the situation?
Unfortunately, our chart doesn't have such functionality. Our stack charts don't have that extra level of grouping (grouping by month in the image). The grouping is done by stacking column values in each row of data. The column chart has the same type of grouping as your image does, but no stacking. The're a few workarounds that I can think of. You can use a column chart and add stack another box on top of the existing one using a custom layer. You can use a composite chart and add a stacked column layer for each of the monthly groups. Each group would also have to be on a separate x axis. I'd go with a custom layer approach, as it would be more friendly to databinding.
Thank you for the clarification and suggestions! I'm not familiar with what's involved for Custom Layers and Composite Charts yet, so pardon my lack of knowledge. Would it, instead, be possible to:
Is that possible? If so, how would I accomplish that? Would that require Custom Layers, a Composite Chart, or something entirely different?
Thanks!
For anyone curious, this is what I was able to develop with the help of Max' code above:
Mark, I need to create a chart as below. Can you please help om this? I tried your code,
I have problem in displaying the Legend.
If I were to add code to display the legend in my example in the previous posts it would look like this:
CompositeLegend legend = new CompositeLegend();legend.Bounds = new Rectangle(0, 90, 100, 10);legend.BoundsMeasureType = MeasureType.Percentage;legend.ChartLayers.Add(layer1);legend.ChartLayers.Add(layer2);ultraChart1.CompositeChart.Legends.Add(legend);
However, you have to make sure that the point labels (these are the labels that the legend will be showing) are different. Can you describe what problems you're experiencing with the legend?
Thanks a lot Max. I made mistake in adding the layers to the legend. It works now.
I want to display the data values on the bars. Can you please help me on this?
You can add a chart text appearance to your layer in order to display text on each column in that layer.
ColumnChartAppearance appearance = new ColumnChartAppearance();ChartTextAppearance chartText = new ChartTextAppearance();chartText.Row = -2;chartText.Column = -2;chartText.ItemFormatString = "<DATA_VALUE_ITEM>";appearance.ChartText.Add(chartText);layer.ChartTypeAppearance = appearance;
You are setting the ChartTypeAppearance property on your layer and therefore overwriting any existing appearances that were set earlier, including ColumnSpacing. Simply include appearance.ColumnSpacing = 2 in your last code segment.
The text doesn't show up because you also need to set chartText.Visible = true
Max, I tried your code, the chart layer1 and layer 2 are overlapping each
other and the values are not displayed in the bar. Below is the code,
[] {s1, s2, s3, s4, s5,s6, s7, s8 });
();
layer1.ChartType = layer2.ChartType =
.StackColumnChart;
layer1.ChartArea = layer2.ChartArea = area;
layer1.AxisY = layer2.AxisY = yAxis;
layer1.AxisX = xAxis1;
layer2.AxisX = xAxis2;
yAxis.DataType =
.Numeric;
yAxis.SetLabelAxisType = Infragistics.UltraChart.Core.Layers.
.GroupBySeries;
yAxis.Labels.ItemFormat =
.DataValue;
yAxis.Labels.SeriesLabels.Format =
.Custom;
layer1.Series.Add(s1);
layer1.Series.Add(s3);
layer1.Series.Add(s5);
layer1.Series.Add(s7);
layer1.ChartArea.Border.Thickness = 100;
layer2.Series.Add(s2);
layer2.Series.Add(s4);
layer2.Series.Add(s6);
layer2.Series.Add(s8);
((
)layer1.ChartTypeAppearance).ColumnSpacing = 2;
)layer2.ChartTypeAppearance).ColumnSpacing = 2;
.ultraChart1.CompositeChart.ChartLayers.Add(layer1);
.ultraChart1.CompositeChart.ChartLayers.Add(layer2);
//To display data values in the bar
chartText.Row = -2;
chartText.Column = -2;
chartText.ItemFormatString =
;
appearance.ChartText.Add(chartText);
layer1.ChartTypeAppearance = appearance;
layer2.ChartTypeAppearance = appearance;