How to style function-plot.js

Im using function-plot.js lib to draw some functions and I want to match the theme im using. I wnat to change grid,label’s color but coudnt find proper documentaion.

Answer

To change the color of a function:

functionPlot({
  target: "#root",
  width,
  height,
  yAxis: { domain: [-1, 9] },
  grid: true,
  data: [
    {
      fn: "x^2",
      derivative: {
        fn: "2 * x",
        updateOnMouseMove: true
      },
      color: "32cb74" // add a color value
    },
    {fn: "x+1", color: "#ffffff"},
  ]
});

this can be any hex value.


You can style the grid, background, etc. in a css file. Example:

.function-plot {
 background: #fafafa // background color of the whole graph
}

.x.axis .tick line {
 stroke: aqua; // color of the vertical lines
}

To get the css selectors you can inspect the graph using devtools.