AddRange of Chart in descending order

Thread is closed for posting
2 posts, 0 answers
  1. Dhamodharan
    Dhamodharan avatar
    300 posts
    Member since:
    Sep 2010

    Posted 18 Apr 2014 Link to this post

    Hi,
          I am working in radchart control. i am using addrange property to add X axis item dynamically. I have a requirement to show values in reverse order.  I need an immediate solution.






    Thanks
  2. Danail Vasilev
    Admin
    Danail Vasilev avatar
    1492 posts

    Posted 22 Apr 2014 Link to this post

    Hi Dhamodharan,

    You can use the code as follows:

    ASPX:
    <telerik:RadChart ID="RadChart1" runat="server" Height="400px" Width="600px" OnBeforeLayout="RadChart1_BeforeLayout">
        <Series>
            <telerik:ChartSeries Type="Point" Name="Series 1">
                <Items>
                    <telerik:ChartSeriesItem YValue="30" XValue="15">
                    </telerik:ChartSeriesItem>
                    <telerik:ChartSeriesItem YValue="10" XValue="20">
                    </telerik:ChartSeriesItem>
                    <telerik:ChartSeriesItem YValue="20" XValue="25">
                    </telerik:ChartSeriesItem>
                </Items>
            </telerik:ChartSeries>
        </Series>
    </telerik:RadChart>
    C#:
    protected void Page_Load(object sender, EventArgs e)
    {
        RadChart1.PlotArea.XAxis.AutoScale = false;
        RadChart1.PlotArea.XAxis.AddRange(10, 30, 5);
    }
    protected void RadChart1_BeforeLayout(object sender, EventArgs e)
    {
        int numXAxisLabels = RadChart1.PlotArea.XAxis.Items.Count;
        var axisItems = new ChartAxisItem[numXAxisLabels];
        RadChart1.PlotArea.XAxis.Items.CopyTo(axisItems, 0);
        RadChart1.PlotArea.XAxis.Items.Clear();
        foreach (var item in axisItems.Reverse())
        {
            RadChart1.PlotArea.XAxis.Items.Add(item);
        }
    }



    Regards,
    Danail Vasilev
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top