leeoniya / uPlot

📈 A small, fast chart for time series, lines, areas, ohlc & bars
MIT License
8.84k stars 385 forks source link

lineInterpolation not working #946

Closed quadriq closed 7 months ago

quadriq commented 7 months ago

Hi,

here my uplot opts:

  const opts = {
    title: "Real User-Allocations Last 24 Hours",
    id: "chart",
    width: 1000,
    height: 600,
    series: [
      {
        label: "Time"
      },
      {
        label: "Allocations",
        show: true,
        stroke: "rgb(183, 119, 216)",
        width: 2,
        fill: "rgb(183, 119, 216, 0.3)",
        lineInterpolation: 3
      },
    ],
  };

however I do not see smooth lines.. I tried different values from example here: https://leeoniya.github.io/uPlot/demos/line-paths.html

any idea what am I doing whrong?

leeoniya commented 7 months ago

lineInterpolation is not part of the core API, it is part of the demo example you linked. you have to use the code in that demo for that option to work.

the way to make a spline path in the core is like this: https://jsfiddle.net/okzhg79u/

let data = [
  [0, 1, 2],
  [2, 1, 5],
];

const opts = {
  width: 600,
  height: 400,
  scales: {
    x: {
      time: false,
    },
  },
  series: [
    {},
    {
      stroke: "red",
      paths: uPlot.paths.spline(),
    },
  ],
};

let u = new uPlot(opts, data, document.body);