Search code examples
c#.netdatasetchartfx

Add other dataset to display a combination chart


Chart chart1 = new Chart();  //ChartFX
chart1.DataSourceSettings.DataSource = dset.Tables[0];
chart1.Data.Series = 2;
DataSetDataValuesTableAdapters.DataValuesTableAdapter adapter = 
    new DataSetDataValuesTableAdapters.DataValuesTableAdapter();
DataSetDataValuesTableAdapters.DataValuesTableAdapter adapter2 = 
    new DataSetDataValuesTableAdapters.DataValuesTableAdapter();
DataSet dset = new DataSet();
DataTable datos1 = adapter.GetDataCaudal();
DataTable datos2 = adapter2.GetDataByPluvio();

dset.Tables.Add(datos1);
dset.Tables[0].TableName = "Table1";
dset.Tables.Add(datos2);
dset.Tables[1].TableName = "Table2";

I can only display one data series in the chartFX chart. I need to connect another DataSource to the chart so I can display two series of data combined.

Here's an example of what I want to get:

Is there anyone who can help me?


Solution

  • I don't have this module so I can't test any code. But it seems you should make a combination chart: http://community.softwarefx.com/forums/p/8501/19692.aspx

    First you need to create a crosstab to pass the data to this chart so that a series is created for each distinct value in the Product Column (Column Header). Check the programmer's guide on the Cross Tab provider for more details. You can also do this using the Chart FX Wizard.

    After the data is setup, all you need to do is set the gallry for each series. You can do this in code or using the property grid at desing-time. In code it's something like:

    chart.AllSeries.Gallery = Gallery.Bar;
    
    chart.Series[2].Gallery = Gallery.Lines; // Third series is the Line