This is a migrated thread and some comments may be shown as answers.

Setting labels in stacked barchart

1 Answer 82 Views
Chart (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Marek
Top achievements
Rank 1
Marek asked on 29 Jul 2011, 10:22 AM
Hi,

My labels are appearing as 1, 2, 3 etc. and I want to set them to some text. Searches of the forum lead me to Datalabelscolumn but that appears to be for bound data. My data is unbound.

Hope soembody can help.

Many thanks,
Marek Walford

Here's my code:


Public

 

 

Sub GenerateGraph(ByVal X As Int16, ByVal Y As Int16, _

 

 

 

ByVal KTO As Double, ByVal CTO As Double, _

 

 

 

ByVal KHW As Double, ByVal CHW As Double, _

 

 

 

ByVal KCC As Double, ByVal CCC As Double, _

 

 

 

ByVal KMC As Double, ByVal CMC As Double, _

 

 

 

ByVal KWA As Double, ByVal CWA As Double)

 

 

 

Dim radChart1 As New Telerik.WinControls.UI.RadChart

 

 

 

Dim CSHW As New Telerik.Charting.ChartSeries()

 

 

 

Dim CSCC As New Telerik.Charting.ChartSeries()

 

 

 

Dim CSMC As New Telerik.Charting.ChartSeries()

 

 

 

Dim CSWA As New Telerik.Charting.ChartSeries()

 

 

 

Dim CSIEHW As New Telerik.Charting.ChartSeriesItem(KHW)

 

 

 

Dim CSIECC As New Telerik.Charting.ChartSeriesItem(KCC)

 

 

 

Dim CSIEMC As New Telerik.Charting.ChartSeriesItem(KMC)

 

 

 

Dim CSIEWA As New Telerik.Charting.ChartSeriesItem(KWA)

 

 

 

Dim CSICHW As New Telerik.Charting.ChartSeriesItem(CHW)

 

 

 

Dim CSICCC As New Telerik.Charting.ChartSeriesItem(CCC)

 

 

 

Dim CSICMC As New Telerik.Charting.ChartSeriesItem(CMC)

 

 

 

Dim CSICWA As New Telerik.Charting.ChartSeriesItem(CWA)

 

radChart1.BeginInit()

radChart1.Size =

 

New System.Drawing.Size(X, Y)

 

radChart1.DefaultType = Telerik.Charting.

 

ChartSeriesType.StackedBar

 

radChart1.ChartTitle.Remove()

 

 

'PlotArea X Axis

 

 

 

With radChart1.PlotArea.XAxis

 

.AxisLabel.Visible =

 

True

 

 

 

End With

 

 

 

'PlotArea Y Axis

 

 

 

With radChart1.PlotArea.YAxis

 

.Appearance.ValueFormat = Telerik.Charting.Styles.

 

ChartValueFormat.Currency

 

.AxisLabel.TextBlock.Text =

 

"Cost"

 

.AxisLabel.Visible =

 

True

 

 

 

End With

 

 

 

'Hardware

 

CSHW.Items.AddRange(

 

New Telerik.Charting.ChartSeriesItem() {CSIEHW, CSICHW})

 

CSHW.Name =

 

"Hardware"

 

CSHW.Appearance.ShowLabels =

 

False

 

CSHW.Type = Telerik.Charting.

 

ChartSeriesType.StackedBar

 

radChart1.Series.Add(CSHW)

 

 

'Colour consumables

 

CSCC.Items.AddRange(

 

New Telerik.Charting.ChartSeriesItem() {CSIECC, CSICCC})

 

CSCC.Name =

 

"Colour Consumables"

 

CSCC.Appearance.ShowLabels =

 

False

 

CSCC.Type = Telerik.Charting.

 

ChartSeriesType.StackedBar

 

radChart1.Series.Add(CSCC)

 

 

'Mono consumables

 

CSMC.Items.AddRange(

 

New Telerik.Charting.ChartSeriesItem() {CSIEMC, CSICMC})

 

CSMC.Name =

 

"Mono Consumables"

 

CSMC.Appearance.ShowLabels =

 

False

 

CSMC.Type = Telerik.Charting.

 

ChartSeriesType.StackedBar

 

radChart1.Series.Add(CSMC)

 

 

'Warranty

 

CSWA.Items.AddRange(

 

New Telerik.Charting.ChartSeriesItem() {CSIEWA, CSICWA})

 

CSWA.Name =

 

"Warranty"

 

CSWA.Appearance.ShowLabels =

 

False

 

CSWA.Type = Telerik.Charting.

 

ChartSeriesType.StackedBar

 

radChart1.Series.Add(CSWA)

 

 

'Oreintation

 

radChart1.SeriesOrientation = Telerik.Charting.

 

ChartSeriesOrientation.Horizontal

 

radChart1.EndInit()

radChart1.Save(Response.OutputStream,

 

ImageFormat.Jpeg)

 

 

 

End Sub

 

1 Answer, 1 is accepted

Sort by
0
Bartholomeo Rocca
Top achievements
Rank 1
answered on 03 Aug 2011, 09:09 AM
Hello Marek,

You can try this but I still would suggest you to consider using the databound approach:
Dim series As New ChartSeries()
series.AddItem(New ChartSeriesItem(5))
series.AddItem(New ChartSeriesItem(15))
series.AddItem(New ChartSeriesItem(13))
series.AddItem(New ChartSeriesItem(8))
series.AddItem(New ChartSeriesItem(9))
radChart.Series.Add(series)
 
radChart.PlotArea.XAxis.AutoScale = False
radChart.PlotArea.XAxis.Items.Add(New ChartAxisItem("TEST1"))
radChart.PlotArea.XAxis.Items.Add(New ChartAxisItem("TEST2"))
radChart.PlotArea.XAxis.Items.Add(New ChartAxisItem("TEST3"))
radChart.PlotArea.XAxis.Items.Add(New ChartAxisItem("TEST4"))
radChart.PlotArea.XAxis.Items.Add(New ChartAxisItem("TEST5"))


Greetings,
Bart.
Tags
Chart (Obsolete)
Asked by
Marek
Top achievements
Rank 1
Answers by
Bartholomeo Rocca
Top achievements
Rank 1
Share this question
or