Clear Series ! Help me

2 posts, 0 answers
  1. Tien
    Tien avatar
    2 posts
    Member since:
    Mar 2013

    Posted 03 Jul 2013 Link to this post

    Hi Telerik Support,
    I have a RadChartHtml, in code behind, I add series to radChartHtml, This is code I define char on Source

    <telerik:RadHtmlChart ID="rhcChart" runat="server" Transitions="true"
        Skin="Forest" Width="1250px" Height="600px">
        <PlotArea>
            <XAxis AxisCrossingValue="0" Color="#b3b3b3" MajorTickType="Outside" MaxValue="12" MinValue="1" MajorTickSize="1"
                MinorTickType="Outside" Reversed="False" Step="1">
                <TitleAppearance Text="Months of Year">
                </TitleAppearance>
            </XAxis>
            <YAxis AxisCrossingValue="0" Color="#b3b3b3" MajorTickSize="1" MajorTickType="Outside"
                MaxValue="9000000" MinorTickSize="1" MinorTickType="Outside" MinValue="0" Reversed="false"
                Step="1000000">
                <TitleAppearance Position="Center" RotationAngle="0" Text="Dollars">
                </TitleAppearance>
                <LabelsAppearance DataFormatString="{0}$" RotationAngle="0">
                </LabelsAppearance>
            </YAxis>
        </PlotArea>
        <Legend>
            <Appearance Visible="True" Position="Bottom">
            </Appearance>       
        </Legend>
    </telerik:RadHtmlChart>
    In code Behind

    void
    BuildChart(string BICode, string RevName)
            {
     
                var data = Pnl.GetPnLDataByMonthAndYearAndBICode("2012", "1,2,3,4,5,6,7,8,9,10,11,12", BICode);
                ScatterLineSeries series1 = new ScatterLineSeries();
                series1.Name = RevName;
                series1.LabelsAppearance.Visible = false;
                series1.TooltipsAppearance.BackgroundColor = Color.White;
                series1.TooltipsAppearance.DataFormatString = "{1} $,";
     
     
                for (int i = 0; i <= data.Count - 1; i++)
                {
                    SeriesItem seriesItem = new SeriesItem(data[i].month, data[i].AMOUNT);
     
                    series1.Items.Add(seriesItem);
                }
     
                rhcChart.PlotArea.Series.Add(series1);
             
            }
    This is my code remove series, when click to Remove
    rhcChart.PlotArea.Series.RemoveAt(2);




     Plz help me :(
    Thanks before !
  2. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1490 posts

    Posted 08 Jul 2013 Link to this post

    Hi Tien,

    This seems to be an issue with the preservation of the axes settings for a programmatically created series. I have logged the issue in our feedback portal here, so that you can monitor, comment and vote on it. For the time being you can either:
    • create an empty series in the markup:
            <telerik:RadHtmlChart ID="RadHtmlChart1" runat="server">
    ...
                <PlotArea>
                    <YAxis>...</YAxis>
                    <XAxis>...</XAxis>
                    <Series>
                        <telerik:ScatterLineSeries Name=" ">
                            <Appearance FillStyle-BackgroundColor="Transparent"></Appearance>
                        </telerik:ScatterLineSeries>
                    </Series>
                </PlotArea>
            </telerik:RadHtmlChart>
    • OR instead of removing the series at index n, recreate all the series except the one with the index of n. For example:

    ASPX:

    <telerik:RadHtmlChart ID="rhcChart" runat="server" Transitions="true"
                Skin="Forest" Width="1250px" Height="600px">
                <PlotArea>
                    <XAxis AxisCrossingValue="0" Color="#b3b3b3" MajorTickType="Outside" MaxValue="12" MinValue="1" MajorTickSize="1"
                        MinorTickType="Outside" Reversed="False" Step="1">
                        <TitleAppearance Text="Months of Year">
                        </TitleAppearance>
                    </XAxis>
                    <YAxis AxisCrossingValue="0" Color="#b3b3b3" MajorTickSize="1" MajorTickType="Outside"
                        MaxValue="9000000" MinorTickSize="1" MinorTickType="Outside" MinValue="0" Reversed="false"
                        Step="1000000">
                        <TitleAppearance Position="Center" RotationAngle="0" Text="Dollars">
                        </TitleAppearance>
                        <LabelsAppearance DataFormatString="{0}$" RotationAngle="0">
                        </LabelsAppearance>
                    </YAxis>
                </PlotArea>
                <Legend>
                    <Appearance Visible="True" Position="Bottom">
                    </Appearance>
                </Legend>
            </telerik:RadHtmlChart>
    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            BuildChart(-1);
        }
    }
     
    void BuildChart(int skipIndex)
    {
        for (int i = 0; i < 4; i++)
        {
            if (i == skipIndex)
            {
                continue;
            }
     
            ScatterLineSeries series1 = new ScatterLineSeries();
            series1.Name = "Series name " + i;
     
            for (int g = 1; g <= 3; g++)
            {
                SeriesItem seriesItem = new SeriesItem(g + i, g * 1000000 + i);
                series1.Items.Add(seriesItem);
            }
     
            rhcChart.PlotArea.Series.Add(series1);
        }
    }
     
    protected void RadButton1_Click(object sender, EventArgs e)
    {
        rhcChart.PlotArea.Series.Clear();
        int n = 2;
        //Remove series at n-th index
        BuildChart(n);
    }

    I have also updated your Telerik points as a small token of gratitude for reporting this issue to us.

    Regards,
    Danail Vasilev
    Telerik
    If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to the blog feed now.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top