I am trying to draw a stacked bar char with the following code but I am seeing my values are shown on x-axis. Is there a way to flip x-axis and y-axis?
Thank you
public void Init()
{
stepReportChart.Series.Clear();
AddSeries("Test1", 0.9);
AddSeries("Test2", 0.2);
AddSeries("Test3", 0.5);
}
private void AddSeries(string name, double val)
DataTable dt = new DataTable("DataPoints");
dt.Columns.Add(new DataColumn("Value", Type.GetType("System.Double")));
dt.Columns.Add(new DataColumn("Name", Type.GetType("System.String")));
DataRow r = dt.NewRow();
r["Value"] = val;
r["Name"] = name;
dt.Rows.Add(r);
DataView dv = new DataView(dt);
Series s = new Series();
s.Label = name;
s.ChartType = ChartType.StackedBar;
s.DataSource = dv;
s.DataMapping = "Value";
stepReportChart.Series.Add(s);
Change the DataMapping value to:
s.DataMapping = "Label=Name;Value=Value";