This is a migrated thread and some comments may be shown as answers.
HtmlChart ScatterLineSeries Axis Title Not Showing
1 Answer 28 Views
This is a migrated thread and some comments may be shown as answers.
Tim Johnson
Top achievements
Rank 1
Tim Johnson asked on 06 Feb 2013, 09:05 PM
Hi,

I'm having a problem with the X and Y axis titles of a ScatterLine Chart. I am binding data to the chart server-side and when I add no series to the chart then the Axis Titles display fine. However, when I add a list of ScatterLineSeries via the PlotArea.Series.AddRange function then the data gets added, but my Axis Titles disappear. I've tried setting the Axis Titles in the ASP markup at design time and via C# code but neither seem to do anything. Note: In the server-side C# code I only tried setting the X-Axis title.

Please see my code blocks below:
public void BindWaterFlowRateChart(List<ScatterLineSeries> WaterFlowRateSeries)
        {
            WaterFlowRateChart.PlotArea.Series.Clear();
            WaterFlowRateChart.PlotArea.Series.AddRange(WaterFlowRateSeries);
            WaterFlowRateChart.Legend.Appearance.Visible = true;
            WaterFlowRateChart.PlotArea.XAxis.AxisCrossingValue = 0;
            WaterFlowRateChart.PlotArea.XAxis.Visible = true;
            WaterFlowRateChart.PlotArea.XAxis.TitleAppearance.Text = "Time (min)";
            WaterFlowRateChart.PlotArea.XAxis.TitleAppearance.Position = AxisTitlePosition.Center;
            WaterFlowRateChart.PlotArea.XAxis.TitleAppearance.Visible = true;
        }
 
<telerik:RadHtmlChart runat="server" ID="WaterFlowRateChart">
            <ChartTitle Text="Water Flow Rate Summary" />
            <Legend>
                <Appearance BackgroundColor="White" Position="Right"></Appearance>
            </Legend>
            <PlotArea>
                <XAxis AxisCrossingValue="0">
                    <TitleAppearance Text="Time (min)" Position="Center" Visible="True" />
                </XAxis>
                <YAxis AxisCrossingValue="0">
                    <TitleAppearance Text="Flow Rate (gal/min)" Position="Center" Visible="True" />
                </YAxis>
            </PlotArea>
        </telerik:RadHtmlChart>

1 Answer, 1 is accepted

Sort by
0
Tim Johnson
Top achievements
Rank 1
answered on 06 Feb 2013, 09:52 PM
I was able to solve my own problem:

Apparently the AddRange function of the Series collection does some sort of DataBind internally which blows away all of the Axis Title settings. This problem can be avoided by either setting the Axis Title during PreRender (after the Axis Title has been reset by AddRange) or don't use AddRange and just loop through all of the ScatterLineSeries and add them to the Series collection individually using the simple Add function (which is what I did).
Asked by
Tim Johnson
Top achievements
Rank 1
Answers by
Tim Johnson
Top achievements
Rank 1
Share this question
or