Click here to Skip to main content
15,888,142 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
buyer1 buyer2 buyer3
1 2014-01-01 48556.4 0 60861
2 2014-02-01 34002.9 0 10120
3 2014-03-01 151749.28 0 138680.8
4 2014-04-01 325300.69 0 74245.5
5 2014-05-01 32511.6 0 29583.3
6 2014-06-01 97112.6 0 0
7 2014-07-01 108101.32 5280 93197.72
8 2014-08-01 155682.13 0 167606.1
9 2014-09-01 162979.85 12125 119540.5
10 2014-10-01 42635.5 19797.6 372881.92
11 2014-11-01 67300.6 0 360722.9
12 2014-12-01 35705.3 7131.5 86175
13 2015-01-01 0 3560 0


Hi.
I am trying to make stacked column chart about order statistics.
I have datatable like above.

I success to print datetime at xAxis

C#
List<string> lstXaxis = new List<string>();
        for (int i = 0; i < dt.Rows.Count; i++)
        {
            lstXaxis.Add(dt.Rows[i][0].ToString().Substring(0,7));
        }

 DotNet.Highcharts.Highcharts chart = new DotNet.Highcharts.Highcharts("chart1")
         .InitChart(new Chart { DefaultSeriesType = DotNet.Highcharts.Enums.ChartTypes.Column })
         .SetTooltip(new Tooltip { Formatter = "function() { return '' + this.x + '<br/>' + this.series.name + ': ' + this.y + '<br/>' + 'Total: ' + this.point.stackTotal;}" })
         .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Amount" }, Min = 0 })
         .SetPlotOptions(new PlotOptions { Column = new PlotOptionsColumn { Stacking = Stackings.Normal } })

         .SetTitle(new Title { Text = "ORDER STATISTICS" })
         .SetXAxis(new XAxis
         {
             Categories = lstXaxis.ToArray()
         })


and I have problem with series data
how can I push multi series to chart?

C#
Series[] series = new Series[dt.Columns.Count];
       for (int j = 0; j <= dt.Columns.Count - 1; j++)
       {
          series[j] = new Series
               {
                   Name = dt.Columns[j].ColumnName.ToString(),
                   for (int k = 1; k < dt.Rows.Count; k++)
                   {
                   Data = new Data(new object[] { dt.Columns[j]("Page Visits") })
               };
           }
       }
Posted

1 solution

I have worked on Stacked column series charts in WPF, the given logic may be useful for scenario.

Quote:
foreach (String str in lstChartSeries.SelectedItems)
{
List<keyvaluepair><string,>> test = new List<keyvaluepair><string,>>();
foreach (DataRow dr in dt.Rows)
{
test.Add(new KeyValuePair<string,>(dr["PROJECT"].ToString(), Convert.ToDouble(dr[str].ToString())));
}

ListSeriesDef[i + 1].Visibility = Visibility.Visible;
ListSeriesDef[i + 1].DataContext = test;
i = i + 1;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900