HtmlChart ScatterLineSeries Axis Title Not Showing

2 posts, 0 answers
  1. Tim Johnson
    Tim Johnson avatar
    11 posts
    Member since:
    Dec 2009

    Posted 06 Feb 2013 Link to this post

    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>
  2. Tim Johnson
    Tim Johnson avatar
    11 posts
    Member since:
    Dec 2009

    Posted 06 Feb 2013 Link to this post

    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).
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top