javascript - How to add data column wise dynamic in for a row? -


This issue is about the Google line chart, which appears according to the different lines i.e. the cycle

I have an array of data, and length is unknown, i.e. Cycle_x

I will dynamically get under data

  arrayCycleName = ['Cycle_1', 'Cycle_3', 'Cycle_3' 'Cycle_4', ....]; arrayModNames = ['mod_1', 'mod_2', 'mod_3', 'mod_4']; ArrayCycle_1_Data = [50,30,10,15]; ArrayCycle_2_Data = [40,20,42,44]; ArrayCycle_3_Data = [30,34,36,40]; On this ..   

I am using datatylet

  var data = new google.visualization.DataTable (); Var chart = new google.visualization.LineChart (document .getElementById ('chart')); Data.addColumn ('string', 'module name'); (I = 0; i & lt; array cache name; ling; i ++) data for. AddColumn ('number', array name [i]);   

The question now is how do I get the data given below using any of the loops?

  data = [['' circle name ',' cyclist_1 ',' chakra_2 ',' psycho_3 '], [' mod_1 ', 50, 40, 30], [' mod_2 ', 30, 20, 34], ['mod_3', 10, 42, 36], ['mod_4', 15, 44, 40]]   

so I can call

  chart.draw (data, {title: 'chart'});    

A possible solution:

  function drawChart ( ) {Var data = new google.visualization.DataTable (); Var array parameter = ['Cycle_1', 'Cycle_3', 'Cycle_3']; Var array name name = ['mod_1', 'mod_2', 'mod_3', 'mod_4']; Var array CEIKAL_1_Data = [50,30,10,15]; Var ArrayCry2_2 Data = [40,20,42,44]; Var ArrayCrylon_3_ Data = [30,34,36,40]; Var array activities = [array_1_ data, array_capital__2 data, array3_3_ data] data. Add column ('string', 'cyan name'); (Var i = 0; i & lt; array cakelam.length; ++ i) {data.addColumn ('number', array of work [i]); } (Var i = 0; i   



Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -