Chris
Chris

Reputation: 59541

Google Charts - dont link 2 points

I have a line in my Chart that represent a stat that always resets at 8am. Is there anyway I can prevent the Chart from connecting the 2 points in that particular position?

I have not been able to find such setting or property for LineCharts.

The pic shows how my graph looks now (top) and how I want it to look (bottom).

enter image description here

Upvotes: 1

Views: 55

Answers (1)

dlaliberte
dlaliberte

Reputation: 3260

You could add an intermediate row, with a domain value between the two points where you want the non-connection, with null values for some or all of your series values, and then make sure you have interpolateNulls:false in your options. The domain value could be equal to one of your two points.

Alternatively, you could set a style for each segment, using the role:'style', and give any segment an invisible color with stroke-color:transparent. Here is an example that shows this: http://jsfiddle.net/dlaliberte/kyq03g12/

// Add a 'style' role column.
data.addColumn({type: 'string', role: 'style'});
...
data.addRows([
      [0, 0, '', 80],   
      [1, 10,'', 75],  
      [2, 23, 'stroke-color:transparent',72],
      [3, 44, '', 37]
  ]);

Read more about the style role here: https://developers.google.com/chart/interactive/docs/roles#stylerole

Upvotes: 1

Related Questions