简体   繁体   中英

Google Charts creates a new line in graph instead of a Tooltip message.

Originally, I had aa chart for temperature_array that was an array that contains an array of the date and the temperature_value

temperature_array[0] = Oct 17 2017 11:42:00 GMT-0400 (EDT), 35.6]

And it was giving me a nice and simple graph, but now, I realize I need a String message for when there was an event. For example, if there was a message at 11:42, I want my temperature graph to take not.

Initially, I assumed that maybe if I add an event_value in the temperature_array , it will work...

temperature_array = [date, temperature_value, event_value] , but now...

这就是现在的样子:(

Basically, it created it's own line because of the Google arrayToDataTable , and since it's a String, it can't equate to a numerical value.

So here's the problem , what I would like to do is have the event String appear in the Tooltip as a message (instead of it's own line), but I am very confused with the Google Charts Documentations.

var thermocouple_chart_options = {
  title: 'The Thermocouple Temperature',
  hAxis: {title: 'Date',  titleTextStyle: {color: '#333'},
  slantedText:true
},
vAxis: {minValue: 0},
explorer: { 
  actions: ['dragToZoom', 'rightClickToReset'],
  axis: 'horizontal',
  keepInBounds: true,
  maxZooImn: 6.0},
  colors: ['#D44E41'],
};

you need to use the tooltip column role

not sure how you're creating the data table

1) if you're using arrayToDataTable
add the role in the headings row...

['Date', 'Temperature', {role: 'tooltip', type: 'string'}]

2) if you're using addColumn

data.addColumn('date', 'Date');
data.addColumn('number', 'Temperature');
data.addColumn({role: 'tooltip', type: 'string'});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM