Skip to content
Advertisement

trying to create line down a graph in nivo at set time intervals

I’m using nivo charts to visualize some sick datasets.

The example is like this,

JavaScript

With the data simply like this,

JavaScript

I want to really simply add in a at time 10, 14, 18 a line for when i exercise. Ideally, I’d like to be able to shade the area beneath that line for 4 hours afterwards, in a sort of parabola (or a specific shape really), having the shading finish at 4 hours after.

I’m quite lost on how to achieve this with Nivo Charts. I suppose this isn’t a normal functionality but was wondering if there was something I was missing that I could work in?

A good example of what I’m trying to achieve is like this sandbox,

https://codesandbox.io/s/simple-composed-chart-forked-b0bfi

I’d be happy to use this sandboxes code if it could be a bit more visually appealing, ideally like to stick with nivo though!

Thanks!

Advertisement

Answer

You can do this using a custom area layer. https://nivo.rocks/storybook/?path=/story/line–custom-layers

Here is a working example based on your initial example. The added area layer parts are commented:

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement