Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
498
Column Line Chart
posted

I really need help creating a chart with dual Y axis. I am getting a simple data from SQL database. The data I'm getting looks like:

Date

Price

TRP Analyst          Rating

 

2009-08-03 00:00:00

119.92

     2

 

2009-08-04 00:00:00

119.6

     3

 

2009-08-05 00:00:00

118.47

     2

 

2009-08-06 00:00:00

117.38

     2

 

2009-08-07 00:00:00

119.33

     2

 

2009-08-10 00:00:00

118.7

     3

 

2009-08-11 00:00:00

117.79

     5

 

2009-08-12 00:00:00

119.29

     2

 

2009-08-13 00:00:00

119.58

     2

 

2009-08-14 00:00:00

118.57

     3

 

2009-08-17 00:00:00

116.86

     1

 

2009-08-18 00:00:00

117.63

     2

 

I would like my X-axis to be column "Date", Y1_axis to be "Price" and Y2_axis to be "TRP Analyst Rating".

I've read the posts about this topic but for some reason none of them seem to work for me.

I just tried using ColumnLine chart and it didn't work.

Please Help!!

Parents
No Data
Reply
  • 26458
    Offline posted

    Try this example:

    DataTable dt = new DataTable();
    dt.Columns.Add("Date", typeof(string));
    dt.Columns.Add("Price", typeof(double));
    dt.Columns.Add("Rating", typeof(double));

    dt.Rows.Add(new object[] { "2009-08-03", 119, 2 });
    dt.Rows.Add(new object[] { "2009-08-04", 118, 3 });
    dt.Rows.Add(new object[] { "2009-08-05", 117, 2 });
    dt.Rows.Add(new object[] { "2009-08-06", 119, 2 });
    dt.Rows.Add(new object[] { "2009-08-07", 117, 3 });

    UltraChart1.ChartType = ChartType.ColumnLineChart;

    UltraChart1.ColumnLineChart.ColumnData.DataSource = dt;
    UltraChart1.ColumnLineChart.ColumnData.IncludeColumn(2, false);
    UltraChart1.ColumnLineChart.ColumnData.SwapRowsAndColumns = true;

    UltraChart1.ColumnLineChart.LineData.DataSource = dt;
    UltraChart1.ColumnLineChart.LineData.IncludeColumn(1, false);
    UltraChart1.ColumnLineChart.LineData.SwapRowsAndColumns = true;

    UltraChart1.Axis.X2.Visible = false;
    UltraChart1.Data.DataBind();


    This should display a columnline chart with a few rows of data. While this is a decent starting point, I do reccomend using a composite chart for this, because it is more customizable.

Children