Trying that again (Google Chrome and Forum are not friends)
Hi all, I am having a hard time figuring out how to setup and populate a scatterlinechart. I am working within a chartfactory that currently produces BarCharts and areacharts by passing a DataRow object to the UpdateChart method. I have many XY points on each 'line' and expect to plot 2 lines. Any help greatly appreciated. thx
InitializeChart() case Shared.EChartType.Scatter: this.Chart.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.ScatterLineChart; this.dataSetMonitorSailMap.Tables.Clear(); this.dataSetMonitorSailMap.Tables.Add(); this.dataSetMonitorSailMap.Tables[0].Clear(); { this.dataSetMonitorSailMap.Tables[0].Columns.Add("ColumnX", typeof(double)); this.dataSetMonitorSailMap.Tables[0].Columns.Add("ColumnY", typeof(double)); ...
InitializeRowData() case Shared.EChartType.Scatter: //rowData is an empty ArrayList[2] object // Add Row(s) to DataSet Table rowData[0] = new ArrayList(); rowData[1] = new ArrayList();
for (int i = 0; i < sensorCount; i++) { rowData[0].Add((double)i); rowData[1].Add((double)i); }
row = this.dataSetMonitorSailMap.Tables[0].NewRow(); row.ItemArray = rowData[0].ToArray(); this.dataSetMonitorSailMap.Tables[0].Rows.Add(row); row = this.dataSetMonitorSailMap.Tables[0].NewRow(); row.ItemArray = rowData[1].ToArray(); this.dataSetMonitorSailMap.Tables[0].Rows.Add(row);...
UpdateChart(){????}
possibly you should try using a ScatterChart with ScatterChart.ConnectWithLines set to True ... instead of a ScatterLineChart.
i'm not sure what you're asking here, though. have you tried creating a chart from this data? if so, does it render OK, do you get an error, or just unexpected results?
pass in false instead of true for the 4th argument in the XYDataPoint constructor.
Hi, thanks for picking this thread up. I have used your suggestions and got a bit further. Now it compiles and runs successfully, however the graph is empty. I am not sure if I have got the bounds wrong or colors are white or if I'm still having trouble actually adding data.
I have paraphrased my code below. Three lines each with multiple points. Can anyone see my mistake(s)?
tia.
Defining the chart:
this.Chart.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.ScatterChart; XYSeries mySeries = new XYSeries(); for (int i = 0; i < 3; i++) {this.Chart.Series.Add(mySeries); }this.Chart.Axis.X.RangeMax = (double)1; this.Chart.Axis.X.RangeMin = (double) 0;this.Chart.Axis.Y.RangeMax = 50; this.Chart.Axis.Y.RangeMin = 0;this.Chart.ScatterChart.UseGroupByColumn = true; this.Chart.ScatterChart.GroupByColumn = 3;this.Chart.ScatterChart.ColumnX = 0; this.Chart.ScatterChart.ColumnY = 1; this.Chart.ScatterChart.ConnectWithLines = true;
this.Chart.ChartType = Infragistics.UltraChart.Shared.Styles.ChartType.ScatterChart;
{
}
this.Chart.Axis.X.RangeMin = (double) 0;
this.Chart.Axis.Y.RangeMin = 0;
this.Chart.ScatterChart.GroupByColumn = 3;
this.Chart.ScatterChart.ConnectWithLines = true;
rowData = new ArrayList[3]; xys = new XYSeries[3];for (int i = 0; i < 3; i++) {xys[i] = new XYSeries(this.Chart); for (int j = 0; j < 4; j++) {xys[i].Points.Add(new XYDataPoint(0, 0, "BM"+i, true)); }this.Chart.Series[i] = xys[i]; }
xys = new XYSeries[3];
Refresh Data ...(called within an while loop)
xys[BM_id].Points.Clear();
for (int i = 0; i < 4; i++) {x = Convert.ToDouble(i / 4); y = Convert.ToDouble(i*i*rnd.Next(0,10));xys[BM_id].Points.Add(new XYDataPoint(x, y, "BM" + BM_id.ToString(), true)); } this.Chart.Series[BM_id] = xys[BM_id]; this.Chart.DataBind();
y = Convert.ToDouble(i*i*rnd.Next(0,10));
this.Chart.Series[BM_id] = xys[BM_id];
this.Chart.DataBind();
this.Chart.ScatterChart.ColumnY = 1;
for (int j = 0; j < 4; j++)
if you have multiple lines, the best way to define the table is like this:
GroupByColumn (string) ; ColumnX (double) ; ColumnY (double)
Line A ; 1 ; 1
Line A ; 1 ; 2
Line A ; 1 ; 3
Line B ; 1 ; 1
Line B ; 2 ; 1
Line B ; 3 ; 1
then set ScatterChart.UseGroupByColumn = true, ScatterChart.GroupByColumn = 0, ScatterChart.ColumnX = 1, ScatterChart.ColumnY = 2, ScatterChart.ConnectWithLines = true