multiple y-axis

2 posts, 0 answers
  1. david
    david avatar
    210 posts
    Member since:
    May 2007

    Posted 30 Sep Link to this post

    Hi, I'm trying to reproduce this chart style - http://demos.telerik.com/aspnet-ajax/htmlchart/examples/functionality/multipleyaxes/defaultcs.aspx

    with a sql datasource that looks like this:

    Period     Person          Sales

    1              Rick                100

    1              Sue                  200

    2              Rick                 120

    2               Sue                 180

    So rick/sue would each have a bar for this respective sales in each period. I cant figure out how to bind the values in the chart?

    Thank you

  2. Vessy
    Admin
    Vessy avatar
    1385 posts

    Posted 04 Oct Link to this post

    Hi David,

    I am not quite sure I understand the scenario you are trying to achieve properly. Can you send us a simple scheme of the chart you are targeting, so we can advice you further?

    Is this the result you want to achieve?

    I so, you want to have separate Series item for each person (Rick and Sue in this case), you will have to have separate columns for each person and structure your data base in a similar way (or make a select bringing this result from your DB and bind the chart with this data):
    Period        Rick              Sue
    1                 100               120
    2                  200              180

    You can have a similar configuration:
    <telerik:RadHtmlChart runat="server" ID="RadHtmlChart1">
        <PlotArea>
            <Series>
                <telerik:ColumnSeries Name="Rick" DataFieldY="RickSales">
                </telerik:ColumnSeries>
                <telerik:ColumnSeries Name="Sue" DataFieldY="SueSales">
                </telerik:ColumnSeries>
            </Series>
            <XAxis DataLabelsField="Period">
            </XAxis>
        </PlotArea>
    </telerik:RadHtmlChart>
    Code Behind:
    protected
    void Page_Load(object sender, System.EventArgs e)
    {
        RadHtmlChart1.DataSource = GetData();
        RadHtmlChart1.DataBind();
    }
     
    private DataSet GetData()
    {
        DataSet ds = new DataSet("Bookstore");
        DataTable dt = new DataTable("Products");
        dt.Columns.Add("Period", Type.GetType("System.Int32"));
        dt.Columns.Add("RickSales", Type.GetType("System.Int32"));
        dt.Columns.Add("SueSales", Type.GetType("System.Int32"));
        dt.Rows.Add(1, 100, 200);
        dt.Rows.Add(2, 120, 180);
        ds.Tables.Add(dt);
        return ds;
    }

    Regards,
    Vessy
    Telerik by Progress
    Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
  3. UI for ASP.NET Ajax is Ready for VS 2017
Back to Top