Hi,
how can I display mutiple lines on a step-line chart?I would like to show the variations of two different values over the same time scale (purchases and sales of a particular item). I built a DataTable from my database, which has time values on the first column and data values on the other two columns, but when I create a step line chart, only the second column is taken into consideration (purchases column).
How can I make it work? Should I initialize a composite chart?
The final result should be something like this:http://www.advsofteng.com/images/stepline.png
Edit:I tried to set up my chart as a composite chart through code, as explained in infragistics documentation and splitted purchases and sales in 2 different datatables, but without succes. I can only see an empty chart with an Y axis vith values between -1 and 1
Max Rivlin said:ultraChart1.Axis.X.TimeAxisStyle.TimeAxisStyle = RulerGenre.Discrete;
Max Rivlin said: series1.DataBind();series2.DataBind();
Thanks a lot Max.
Using a composite chart or a simple chart with 2 numeric time series should work equally well. Here's a code snippet that should address both your questions.
DataTable dt = new DataTable();dt.Columns.Add("date", typeof(DateTime));dt.Columns.Add("value1", typeof(double));dt.Columns.Add("value2", typeof(double));
dt.Rows.Add(new object[] { DateTime.Now.AddDays(0), 50, 30 });dt.Rows.Add(new object[] { DateTime.Now.AddDays(2), 60, 40 });dt.Rows.Add(new object[] { DateTime.Now.AddDays(5), 80, 20 });dt.Rows.Add(new object[] { DateTime.Now.AddDays(6), 30, 15 });dt.Rows.Add(new object[] { DateTime.Now.AddDays(8), 60, 25 });dt.Rows.Add(new object[] { DateTime.Now.AddDays(9), 100, 20 });
ultraChart1.ChartType = ChartType.StepLineChart;ultraChart1.Axis.X.TimeAxisStyle.TimeAxisStyle = RulerGenre.Discrete;
NumericTimeSeries series1 = new NumericTimeSeries();series1.Data.DataSource = dt;series1.Data.TimeValueColumn = "date";series1.Data.ValueColumn = "value1";ultraChart1.Series.Add(series1);
NumericTimeSeries series2 = new NumericTimeSeries();series2.Data.DataSource = dt;series2.Data.TimeValueColumn = "date";series2.Data.ValueColumn = "value2";ultraChart1.Series.Add(series2);
series1.DataBind();series2.DataBind();
I made some progress but still i'm not getting what I want.
The problem comcerning wrong data on the Y axis is solved. I just didn't used NumercTimeSeries.I can display 2 lines from 2 different series initialized from the same DataTable, but: