1

I would appreciate if someone could help me with this. It's for a job interview so quite important.

I have a JavaScript function at the top of my .aspx that draws a chart on the page (downloaded from Google Charts).

function drawChart() { 
    var **data** = google.visualization.arrayToDataTable([
      ['Mon', 20, 28, 38, 45],
      ['Tue', 31, 38, 55, 66],
      ['Wed', 50, 55, 77, 80],
      ['Thu', 77, 77, 66, 50],
      ['Fri', 68, 66, 22, 15]
      // Treat first row as data as well.
    ], true);
var chart = new  google.visualization.CandlestickChart(document.getElementById('chart_div'));

    chart.draw(data, options);

...}

As you can see, the variable data here is used to create the chart.

If I have a C# DataTable object I want to pass to this function and use it instead, how do I do it?

Many thanks

Vhov
  • 11
  • 2
  • So you want to send a property from your code-behind to some JS? Is it MVC, WebForms, or? – Don Cheadle Aug 03 '16 at 19:48
  • right now drawChart() doesn't have any parameters so add a DataTable called 'data' to the function parameter list. – jdweng Aug 03 '16 at 19:51
  • 4
    Possible duplicate of [How do I pass data from c# to jquery/javascript?](http://stackoverflow.com/questions/18986041/how-do-i-pass-data-from-c-sharp-to-jquery-javascript) – WhiteHat Aug 03 '16 at 19:52
  • [link]https://developers.google.com/chart/interactive/docs/gallery/candlestickchart – Roman Aug 03 '16 at 20:31

0 Answers0