0

Here is the sandbox link: https://codesandbox.io/s/chartjs-plugin-zoom-touch-scroll-y-forked-6q5li4?file=/src/components/ChartLine.vue

I am trying to build a chart out of some time-series data that I have.

I have a picker to select the scale: hour, day, week, and month, and the data can span up to 4 months. I start on the hour scale, but a visual problem I have is that I initially want the chart to focus on the last n hours/days/weeks instead of the current behavior where the chart shows the entire x-axis so the hour unit doesn't really make sense without tooltips.

How can I set limits using a UNIX timestamp of the min and max, and have the chart initially focus on the last n units? Like the last 4 hours or 4 days or 4 weeks or 4 months?

Blaine
  • 576
  • 9
  • 30
  • You could set min option of the X time scale with the epoch, calculated when the time unit changes, and then invoke chart.update. – user2057925 Oct 10 '22 at 12:56

0 Answers0