score:7
Accepted answer
Your question is a bit unclear. Your eventual plot call doesn't match what I assume you want on your plot - two series, one for Bob and one for Tim.
So let's start with with basics and get your database data into an array of Highchart series objects using JSON:
Assuming your first data structure coming back from the database:
name 1 2 3 4 5 6 7 8 9 10
Bob 4 5 6 7 8 9 9 9 0 0
tim 4 5 6 7 4 3 2 5 6 3
This:
List<Dictionary<string, object>> allSeries = new List<Dictionary<string,object>>();
foreach (DataRow dr1 in table.Rows)
{
Dictionary<string, object> aSeries = new Dictionary<string,object>();
aSeries["name"] = dr1["name"];
aSeries["data"] = new List<int>();
int N = dr1.ItemArray.Length;
for (int i = 1; i < N; i++)
{
((List<int>)aSeries["data"]).Add((int)dr1[i]);
}
allSeries.Add(aSeries);
}
string jsonSeries = Newtonsoft.Json.JsonConvert.SerializeObject(allSeries);
in the jsonSeries string variable produces:
[{"name":"Bob","data":[4,5,6,7,8,9,9,9,0,0]},{"name":"Tim","data":[4,5,6,7,4,3,2,5,6,3]}]
This for Highcharts is an array of series objects.
You could then use this in a Highcharts call as:
$('#chartContainer').highcharts({
chart: {
type: 'column'
},
series: <%= jsonSeries %>
});
Which creates:
Source: stackoverflow.com
Related Query
- Highcharts C# To JSON - Structuring Series Data
- Highcharts displays series names but missing data points from json source
- Highcharts with JSON data and multiple series
- How to construct HighCharts data series to match returned Json via ajax call
- Extract data series from a JSON array for a Highcharts chart with 2 y-axis
- Highcharts Single Line series JSON date data format
- Highcharts series visibility with csv data source
- Highcharts - JSON series data not showing correctly
- Loading json data to highcharts with multiple series
- How to have multiple highcharts with different series data in vuejs without repeating code
- Highcharts loop JSON Object to fill data series
- HighCharts Bubble graph JSON as data source
- Highcharts Series data as JSON doesn't render
- Highcharts pie/bar combo. How to load json and how are the data series expressed
- Highcharts Pulling JSON data into series names dynamically
- Set Additional Data to highcharts series
- Proper way to remove all series data from a highcharts chart?
- Reload chart data via JSON with Highcharts
- Changing data dynamically for a series in Highcharts
- Add additional data to a Highcharts series for use in formatters
- Get Highcharts Series Data after Load
- Highcharts doesn't display series with lots of data points
- Highcharts data series issue with ajax/json and PHP
- adding series to highcharts from JSON
- Changing Highcharts data series type dynamically
- Highcharts series data array
- How to pass json data to highcharts series?
- Use an array of objects for series data in Highcharts
- Send JSON data to highcharts pie from asp.net MVC controller in C#
- Highcharts how to use JavaScript variable as series data source?
More Query from same tag
- implementing HighCharts-xrange in angular4
- HighCharts - applying a formatting function over plot options
- Manually load and unload external javascript in AngularJS
- how to have a chart with no spline and no interpolation in Highcharts?
- Does HighCharts have a fundamental minimum height before it's rendering behaviour changes?
- Pie chart Slice color Change Dynamically in Highcharts
- Highcharts not rendering
- C# HighCharts X Axis
- Structure Data timeintervals in Highcharts
- Show label of stacked columns only on hover (and also the previous and next column)
- Highcharts: Getting average values for selection in line graph
- Highcharts adding additional blank series from csv
- HighCharts - compare series with values instead of percentage
- Highcharts: zero-align y-axes angular 6
- Can I color points in highcharts time series?
- Highcharts datalabels outside of plot area?
- Highcharts gauge fill to 100% of container
- Add a colored text in italic to Highchart plot
- Average values based on date from json to array of arrays
- Highcharts: remove 1 label from windrose chart
- append the min max value lableof solidguage with string in highchart
- Box plot with Highcharts - TypeError: 'undefined' is not a constructor
- Add two json data series in one highchart
- Getting error when using angular2-highcharts in angular2 project
- Highcharts.js combined bar/line chart with timespan bars
- HighChart flags Data load issues
- Highcharts Datetime axis
- Highchart Treemap: forcing layout on 3 lines
- Treemap with Multiple Series
- Displaying Stack name as legend key