Search code examples
javascriptjquerycolorsfilldygraphs

How to set custom fill color in dygraph


By setting the property fillGraph: true , we can fill the dygraph with its default color. But how to fill it with a custom color?


Solution

  • The fill color is always the same as the series color (which you can control via the colors option) but with a lower opacity, controllable by the fillAlpha option.

    If you need more flexibility than this, you have two options:

    1. Create two series, one with fill and one without. You can use CSS to hide one from the legend. Demo here.
    2. Create a custom plotter that uses the colors you want. Read more about how to do that here.