1

I have an embedded line chart on Google Sheets.

I take data for the chart from the other tab of the same sheet.

I create notes in cells which I take data from.

It would be great to have notes be shown as popup tooltips when hovering over each data point.

The mechanism already has tooltips for each data point. It shows names of my horizontal axes now: "January", "February" etc.

Is there a way to show notes as tooltips and push my data to tooltips?

Here's my code:

//I can possibly use this more for tooltips
var options = {
    selectionMode: 'multiple',
    tooltip: {trigger: 'selection'},//or focus I guess
    aggregationTarget: 'series',
};
    
   
   //builds a chart
   var chart = sheet.newChart()
        .setChartType(Charts.ChartType.LINE)
        .addRange(range).setTransposeRowsAndColumns(true)
        .setPosition(2, 4, 0, 0)
        .setOption("title", name)
        .setOption('series.0.dataLabel', 'value') //shows data on the line
  //styling, but possibly can add some important data here?
        .setOption('tooltip', {0:{textStyle: {color: '#8A0829'}, showColorCode: true}}) 
        .setOption('aggregationTarget', options)
        .build();

    sheet.insertChart(chart);
kiki
  • 199
  • 4
  • 20
  • 1
    Forget charts. How will you get the comments into apps script? – TheMaster Apr 15 '19 at 08:46
  • haha I see. Let's apply this to notes then!) – kiki Apr 15 '19 at 08:59
  • Have you seen this answer https://stackoverflow.com/a/13652972/ ? `mechanism already has tooltips for each data point. It shows names of my horizontal axes now: "January", "February" etc.` What seems to be the data point for tooltips on reverse engineering? – TheMaster Apr 15 '19 at 09:05
  • That's a different thing, labels are static data presented on a chart (my statistics). I need other data as popups. Like when I hover over or click on points I would got customized tooltips instead of default tooltips that show horizontal axis data now. – kiki Apr 15 '19 at 09:12
  • 1
    Are you saying you can't do this with the inbuilt editor? If that's not possible, I don't think it'll be possible with scripts either. If however it is possible, then you reverse engineer the data points as shown in the linked question above. You might be better off showing your chart in a sidebar/dialog/web -app, where all options are [customizable](https://developers.google.com/chart/interactive/docs/customizing_tooltip_content) – TheMaster Apr 15 '19 at 09:37
  • 2
    have a look at the [data format](https://developers.google.com/chart/interactive/docs/gallery/linechart#data-format) for a `LineChart`, you can use a [tooltip](https://developers.google.com/chart/interactive/docs/roles#tooltiprole) column role, add the note data to a column directly after the series data in the data table and change the role to `'tooltip'`... – WhiteHat Apr 15 '19 at 11:29
  • @TheMaster yeah, that's an alternative way. – kiki Apr 15 '19 at 19:18
  • @WhiteHat can you please give an example of such code in a separate answer? I'm kinda novice in this. And what do you mean by "add the note data to a column directly"? – kiki Apr 15 '19 at 19:18
  • How to customize tooltips for the Embedded chart? @WhiteHat Can anyone help please?) – kiki Apr 19 '19 at 15:29

0 Answers0