I am passing -5, -4, -3, -2, -1, 0, 1, 2, 3, 4, 5 for the Y axis. Client wants all values to show as positive, but respecting the negative position 5, 4, 3, 2, 1, 0, 1, 2, 3, 4, 5 on the same Y axis.
Is there a way to step through axis labels and if the value is less than 1, multiply by -1, or just abs() all the ticks?
5 Answers, 1 is accepted
Generally the concepts of the axis item label and the underlying axis item value are separated in RadChart so you can achieve the desired effect by modifying the label and keeping the underlying value intact like this:
ASPX
<
telerik:RadChart
ID
=
"RadChart1"
runat
=
"server"
AutoLayout
=
"true"
SeriesOrientation
=
"Horizontal"
OnBeforeLayout
=
"RadChart1_BeforeLayout"
>
<
Series
>
<
telerik:ChartSeries
Type
=
"Gantt"
>
<
Appearance
BarWidthPercent
=
"5"
ShowLabels
=
"false"
LegendDisplayMode
=
"Nothing"
/>
<
Items
>
<
telerik:ChartSeriesItem
YValue
=
"-4"
YValue2
=
"2"
/>
<
telerik:ChartSeriesItem
YValue
=
"-1"
YValue2
=
"4"
/>
</
Items
>
</
telerik:ChartSeries
>
</
Series
>
<
PlotArea
>
<
YAxis
AutoScale
=
"false"
MinValue
=
"-5"
MaxValue
=
"5"
Step
=
"1"
/>
</
PlotArea
>
</
telerik:RadChart
>
C#
protected
void
RadChart1_BeforeLayout(
object
sender, EventArgs e)
{
foreach
(ChartAxisItem axisItem
in
RadChart1.PlotArea.YAxis.Items)
{
axisItem.TextBlock.Text = Math.Abs(axisItem.Value).ToString();
}
}
Hope this helps.
Kind regards,
Evgenia
the Telerik team
Dim NewChart As New RadChart
NewChart.Width = Unit.Pixel(980)
NewChart.Chart.DefaultType = Telerik.Charting.ChartSeriesType.Line
NewChart.PlotArea.YAxis.AutoScale =
False
NewChart.PlotArea.XAxis.DataLabelsColumn =
"PrettyDate"
NewChart.Skin =
"Hay"
NewChart.AutoLayout =
True
For Each YI As Telerik.Charting.ChartAxisItem In NewChart.PlotArea.YAxis.Items
YI.TextBlock.Text =
"SomethingNew"
Next
TableCell.Controls.Add(NewChart)
You can set custom Axis Labels Programmatically as described in our help topic with code sample.
Kind regards,
Evgenia
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
NewChart.PlotArea.YAxis.Items.Count.ToString
that count turns out to be 0, even though there are clearly items on the y-axis of the chart.
To be able to have the actual count of the Axis Items and not 0 you should subscribe to the BeforeLayout event of the Chart.
All the best,
Evgenia
the Telerik team
Browse the vast support resources we have to jump start your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.