1

line graph column graph

My graph keeps call Controller to get recent info in Database time by time.

There are two lines so I want to show the name of each lines(columns) like red=counts of something // brown=counts of something else.

My other bar graph has line info with color, and column name(highligted).

How can I add that information??

My line graph codes,

o.data = new google.visualization.DataTable();
        o.data.addColumn('string', 'time');
        o.data.addColumn('number', o.name);
        o.data.addColumn('number', o.name2);
        o.data.addRow(['', 0, 0]);
choky7
  • 33
  • 4

1 Answers1

0

I'm not sure if I understand you correctly, but according to the docs you have to create options object and coufigure your chart as you like, e.g. add a legend to your bars or lines.

Example from the google chart documentation:

google.charts.load("current", {packages:["corechart"]});
google.charts.setOnLoadCallback(drawChart);

function drawChart() {

  var data = google.visualization.arrayToDataTable([
    ['Genre', 'Fantasy & Sci Fi', 'Romance', 'Mystery/Crime', 'General',
     'Western', 'Literature', { role: 'annotation' } ],
    ['2010', 10, 24, 20, 32, 18, 5, ''],
    ['2020', 16, 22, 23, 30, 16, 9, ''],
    ['2030', 28, 19, 29, 30, 12, 13, '']
  ]);

  var options = {
    width: 600,
    height: 400,
    legend: { position: 'top', maxLines: 3 },
    bar: { groupWidth: '75%' },
    isStacked: true,
  };

  var view = new google.visualization.DataView(data);

  var chart = new google.visualization.BarChart(document.getElementById("barchart_values"));
  chart.draw(view, options);
}

Fiddle: https://jsfiddle.net/b0jghv4z/

Mat.Now
  • 1,715
  • 3
  • 16
  • 31