I need to combine a stacked line chart with a stacked bar chart. So far, I have been successful in combining the stacked line chart with a bar chart or in creating the stacked bar chart but I cannot combine it with the stacked line chart.
This is the code I'm using,
Any suggestions?
Thanks in advance
This is the code I'm using,
Any suggestions?
Thanks in advance
<
BR
>
<
P
>Dim TheChart As Telerik.Windows.Controls.RadChart = TryCast(sender,
Telerik.Windows.Controls.RadChart)<
BR
>
'TheChart.ItemsSource = CreateChart_DefaultView().ItemsSource</
P
>
<
P
>
TheChart.DefaultView.ChartTitle.Content = "Year
2009"<
BR
>
TheChart.DefaultView.ChartTitle.HorizontalAlignment =
HorizontalAlignment.Center<
BR
> 'Chart
Legend<
BR
>
TheChart.DefaultView.ChartLegend.UseAutoGeneratedItems =
True<
BR
> 'Charts
values<
BR
> Dim LineChartValues() As
Integer = {154, 138, 143, 120, 135, 125, 179, 170, 198, 187, 193,
176}<
BR
> Dim LineChartCats() As String
= {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
"Dec"}<
BR
> Dim ConstantValue As
Integer = 140<
BR
> 'Line
Chart<
BR
> Dim lineSeries As New
DataSeries()<
BR
>
lineSeries.LegendLabel =
"Turnover"<
BR
> lineSeries.Definition =
New LineSeriesDefinition()<
BR
> Dim
dataPoint As New DataPoint()<
BR
> For i
As Integer = 0 To LineChartValues.Length -
1<
BR
>
dataPoint = New
DataPoint()<
BR
>
dataPoint.YValue =
LineChartValues(i)<
BR
>
dataPoint.XCategory =
LineChartCats(i)<
BR
>
lineSeries.Add(dataPoint)<
BR
>
Next<
BR
>
TheChart.DefaultView.ChartArea.DataSeries.Add(lineSeries)</
P
>
<
P
> ' Line chart
(constant)<
BR
> Dim lineSeriesB As New
DataSeries()<
BR
>
lineSeriesB.LegendLabel =
"Turnover"<
BR
> lineSeriesB.Definition
= New LineSeriesDefinition()<
BR
> For i
As Integer = 0 To LineChartValues.Length -
1<
BR
>
dataPoint = New
DataPoint()<
BR
>
dataPoint.YValue =
ConstantValue<
BR
>
dataPoint.XCategory =
LineChartCats(i)<
BR
>
lineSeriesB.Add(dataPoint)<
BR
>
Next<
BR
>
TheChart.DefaultView.ChartArea.DataSeries.Add(lineSeriesB)</
P
>
<
P
> 'Bar
Chart<
BR
> Dim BarChartValues() As
Integer = {5, 18, 12, 11, 15, 20, 10, 7, 15, 25, 10,
5}<
BR
> Dim BarChartValuesB() As
Integer = {15, 25, 13, 8, 5, 10, 15, 20, 10, 13, 15,
10}<
BR
> Dim BarChartValuesC() As
Integer = {10, 20, 15, 10, 5, 14, 9, 11, 20, 16, 10,
15}<
BR
> Dim BarChartCats() As String =
{"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov",
"Dec"}<
BR
> Dim barSeries As New
DataSeries()<
BR
> Dim sampleData As New
List(Of Company)()<
BR
>
barSeries.LegendLabel = "Expenses"<
BR
>
barSeries.Definition = New
BarSeriesDefinition()<
BR
> For j As
Integer = 0 To BarChartValues.Length -
1<
BR
>
sampleData.Add(New Company("Name " & j, BarChartValues(j),
BarChartValuesB(j),
BarChartValuesC(j)))<
BR
> Next</
P
>
<
P
> Dim SeriesMappingList As New
List(Of SeriesMapping)<
BR
> Dim
seriesMapping As New SeriesMapping()</
P
>
<
P
> seriesMapping = New
SeriesMapping()<
BR
>
seriesMapping.LegendLabel = "Label
1"<
BR
>
seriesMapping.ItemMappings.Add(New ItemMapping("Value1",
DataPointMember.YValue))<
BR
>
seriesMapping.ItemMappings.Add(New ItemMapping("Name",
DataPointMember.XCategory))<
BR
>
seriesMapping.SeriesDefinition = New
StackedBarSeriesDefinition()<
BR
>
seriesMapping.SeriesDefinition.ShowItemLabels =
True<
BR
>
SeriesMappingList.Add(seriesMapping)<
BR
>
seriesMapping = New
SeriesMapping()<
BR
>
seriesMapping.LegendLabel = "Label
2"<
BR
>
seriesMapping.ItemMappings.Add(New ItemMapping("Value2",
DataPointMember.YValue))<
BR
>
seriesMapping.ItemMappings.Add(New ItemMapping("Name",
DataPointMember.XCategory))<
BR
>
seriesMapping.SeriesDefinition = New
StackedBarSeriesDefinition()<
BR
>
seriesMapping.SeriesDefinition.ShowItemLabels =
True<
BR
>
SeriesMappingList.Add(seriesMapping)<
BR
>
seriesMapping = New
SeriesMapping()<
BR
>
seriesMapping.LegendLabel = "Laabel
3"<
BR
>
seriesMapping.ItemMappings.Add(New ItemMapping("Value3",
DataPointMember.YValue))<
BR
>
seriesMapping.ItemMappings.Add(New ItemMapping("Name",
DataPointMember.XCategory))<
BR
>
seriesMapping.SeriesDefinition = New
StackedBarSeriesDefinition()<
BR
>
seriesMapping.SeriesDefinition.ShowItemLabels =
True<
BR
>
SeriesMappingList.Add(seriesMapping)</
P
>
<
P
> 'seriesMapping = New
SeriesMapping()<
BR
>
'seriesMapping.SeriesDefinition = New
LineSeriesDefinition()<
BR
>
'seriesMapping.ItemMappings.Add(New ItemMapping("Line1",
DataPointMember.YValue))<
BR
>
'seriesMapping.ItemMappings.Add(New ItemMapping("StageVariable",
DataPointMember.XCategory))<
BR
>
'seriesMapping.SeriesDefinition.LegendDisplayMode =
LegendDisplayMode.DataPointLabel<
BR
>
'SeriesMappingList.Add(seriesMapping)<
BR
>
'seriesMapping = New
SeriesMapping()<
BR
>
'seriesMapping.SeriesDefinition = New
LineSeriesDefinition()<
BR
>
'seriesMapping.ItemMappings.Add(New ItemMapping("Line2",
DataPointMember.YValue))<
BR
>
'seriesMapping.ItemMappings.Add(New ItemMapping("StageConstant",
DataPointMember.XCategory))<
BR
>
'seriesMapping.SeriesDefinition.LegendDisplayMode =
LegendDisplayMode.DataPointLabel<
BR
>
'SeriesMappingList.Add(seriesMapping)</
P
>
<
P
> TheChart.ItemsSource =
sampleData</
P
>
<
P
>
TheChart.DefaultView.ChartArea.AxisY.AutoRange =
True<
BR
>
'TheChart.DefaultView.ChartArea.AxisY.AddRange(0, 200,
100)<
BR
>
TheChart.SeriesMappings.Clear()<
BR
>
For n = 0 To SeriesMappingList.Count -
1<
BR
>
TheChart.SeriesMappings.Add(SeriesMappingList(n))<
BR
>
Next</
P
>