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!
Wow, thank you so much! Sorry my reply took so long. I've been out of town for the past week.
I've got my datapoints in there and displaying A-OK, but the chart appears to be pushed way up toward to the top of the chart control. How do I move it down to make it appear more "centered" ?
I've tried modifying different combinations of these properties, like so:
However, nothing seems to work. The Location.X and Y properties throw a compile-time error saying that the "expression is a value and cannot be the target of an assignment"...which is strange, because it's shown as a property, which should certainly take values assigned to it. Meanwhile, the .Offset(10, 25) method does compile, but it never does affect where the chart appears. Am I doing any of these incorrectly, or is there some different property or method that I need to use?
The chart area takes up the entire chart control. It's actually the axes that leave the white space. By default the axis extent is 80 pixels; you can trying setting that to 30 instead.
xAxis1.Extent = 30;xAxis2.Extent = 30;yAxis.Extent = 30;
When changing chart area bounds, change the entire bounds rectangle, like this:area.Bounds = new Rectangle(10, 10, 80, 80);area.BoundsMeasureType = MeasureType.Percentage;That's typically used to create margins around the area.
Fantastic! Thanks so much, Max!
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.
You can use the Chart Text property to show data values on the bar. An object of ChartTextappearance needs to be created for the same. If the row and column values are given as
-2, data will appear in all stacks.Itemformatstring should be set to Data_Value_Item.
ChartTextAppearance
ct1 = new ChartTextAppearance();
ct1. ...(set all properties here)
ct1.ItemFormatString = "<Data_Value_Item>";
chartname.ChartText.Add(ct1)
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;
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;
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?