This is a migrated thread and some comments may be shown as answers.
Clear Series ! Help me
1 Answer 62 Views
This is a migrated thread and some comments may be shown as answers.
Tien
Top achievements
Rank 1
Tien asked on 04 Jul 2013, 04:52 AM
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 !

1 Answer, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 08 Jul 2013, 04:43 PM
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.
Asked by
Tien
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Share this question
or