Raúl Roa Raúl Roa - 15 days ago 4
C# Question

How to create the Google DataTable JSON expected source using C#?

How can I create the JSON source expected by the google.visualization.datatable using C#? Obviously using the

is out of the question since the expected JSON has a weird structure as described on the documentation:

var dt = new google.visualization.DataTable(
cols: [{id: 'task', label: 'Task', type: 'string'},
{id: 'hours', label: 'Hours per Day', type: 'number'}],
rows: [{c:[{v: 'Work'}, {v: 11}]},
{c:[{v: 'Eat'}, {v: 2}]},
{c:[{v: 'Commute'}, {v: 2}]},
{c:[{v: 'Watch TV'}, {v:2}]},
{c:[{v: 'Sleep'}, {v:7, f:'7.000'}]}


Though I'm not familiar in the .NET environment, there is a .NET helper for the Google Visualization API called bortosky-google-visualization. The library writes a JSON Google DataTable from a System.Data.DataTable object.