I added the js file manually, and I now get currency formatted numbers.
The lack of any ability to further format makes this pretty useless anyway. I don't wany to display £1,433,123.01. Who cares about 1p on a chart when you are dealing in millions?
Sorry, this is not even half baked yet.
Instead I am assigning a DataFormatString in code behind. I have a checkbox which toggles if the charts show counts or values, and I assign the DataFormat String accordingly, e.g.
Public
Sub
ShowChart()
Trace.Write(
"ShowChart"
)
Dim
plt
As
Telerik.Charting.Palette
plt = Telerik.Charting.PalettesCollection.GetPalette(Master.ddlPalette.SelectedValue)
If
dt
Is
Nothing
Then
Else
If
Master.ShowGrid
Then
rg1.DataSource = dt
rg1.DataBind()
rc1.Visible =
False
rc2.Visible =
False
rc3.Visible =
False
rg1.Visible =
True
Else
rc1.Visible =
True
rc2.Visible =
True
rc3.Visible =
True
rg1.Visible =
False
rc1.DataSource = dt
rc1.DataBind()
With
rc1.PlotArea.YAxis
If
Master.chkByValue.Checked
Then
.MaxValue = 1200000
.
Step
= 100000
.LabelsAppearance.DataFormatString =
"£{0:N0}"
Else
.MaxValue = 500
.
Step
= 50
.LabelsAppearance.DataFormatString =
"{0:N0}"
End
If
' reset chart axis upper limit based on actual data values
.MaxValue = (((Int(maxvalue)) / .
Step
) * .
Step
) + (.
Step
* 0.2)
End
With
Dim
colorindex
As
Integer
= 2
For
Each
chtseries
As
ColumnSeries
In
rc1.PlotArea.Series
' vary colours
Try
chtseries.Appearance.FillStyle.BackgroundColor = plt.Items(colorindex).MainColor
chtseries.TooltipsAppearance.BackgroundColor = plt.Items(colorindex).MainColor
Catch
chtseries.Appearance.FillStyle.BackgroundColor = plt.Items(0).MainColor
chtseries.TooltipsAppearance.BackgroundColor = plt.Items(0).MainColor
End
Try
colorindex += 1
If
colorindex = plt.Items.Count
Then
colorindex = 0
' optionally show labels
chtseries.LabelsAppearance.Position = HtmlChart.BarColumnLabelsPosition.InsideEnd
If
Master.chkLabels.Checked
Then
chtseries.LabelsAppearance.ClientTemplate =
""
Else
chtseries.LabelsAppearance.ClientTemplate =
" "
End
If
' show either count or value
If
Master.chkByValue.Checked
Then
chtseries.LabelsAppearance.DataFormatString =
"£{0:N0} "
& chtseries.Name
chtseries.TooltipsAppearance.DataFormatString =
"£{0:N0} "
& chtseries.Name
Else
chtseries.LabelsAppearance.DataFormatString =
"{0:N0} "
& chtseries.Name
chtseries.TooltipsAppearance.DataFormatString =
"{0:N0} "
& chtseries.Name
End
If
Next
' total pie charts
For
pie
As
Int16 = 0
To
1
Dim
pieslices
As
PieSeries
Dim
dtPie
As
DataView
If
pie = 0
Then
pieslices = rc2.PlotArea.Series(0)
dtPie = dt2.AsDataView
Else
pieslices = rc3.PlotArea.Series(0)
dtPie = dt.AsDataView
End
If
pieslices.SeriesItems.Clear()
' optionally show labels
If
Master.chkLabels.Checked
Then
pieslices.LabelsAppearance.ClientTemplate =
""
pieslices.LabelsAppearance.Position = HtmlChart.PieLabelsPosition.Circle
If
Master.chkByValue.Checked
Then
pieslices.LabelsAppearance.DataFormatString =
"£{0:N0}"
Else
pieslices.LabelsAppearance.DataFormatString =
"{0:N0}"
End
If
Else
pieslices.LabelsAppearance.Position = HtmlChart.PieLabelsPosition.Column
pieslices.LabelsAppearance.ClientTemplate =
" "
' make it go away
End
If
' show counts or values
If
Master.chkByValue.Checked
Then
pieslices.TooltipsAppearance.DataFormatString =
"£{0:N0}"
Else
pieslices.TooltipsAppearance.DataFormatString =
"{0:N0}"
End
If
' add items back in varying colours
colorindex = 2
For
Each
dr
As
DataRow
In
dtPie.Table.Rows
Try
Dim
pieslice
As
New
PieSeriesItem(
CInt
(dr(
"Total"
)), plt.Items(colorindex).MainColor, dr(pieslices.Name))
pieslices.SeriesItems.Add(pieslice)
Catch
Dim
pieslice
As
New
PieSeriesItem(
CInt
(dr(
"Total"
)), plt.Items(0).MainColor, dr(pieslices.Name))
pieslices.SeriesItems.Add(pieslice)
End
Try
colorindex += 1
If
colorindex = plt.Items.Count
Then
colorindex = 0
Next
Next
End
If
End
If
Trace.Write(
"ShowChart end"
)
End
Sub
This also implements varying colours by item for the pie charts (users can select a palette from a dropdown), matching tooltip colours to the series/item, and optionally hiding labels. Note the trick of assigning an ClientTemplate of a single space to effectively hide the labels
I'm happy with the way this works and hope it helps someone else.