chartjs / chartjs-chart-financial

Chart.js module for charting financial securities
MIT License
743 stars 199 forks source link

First (left) and last (right) candle are truncated, draw outside #42

Closed sgornick closed 5 years ago

sgornick commented 6 years ago

The candlestick chart doesn't render the first and last candle well. It centers the candlestick but only draws the part of the candle that fits inside the chart.

Using the sample ( https://www.chartjs.org/chartjs-chart-financial/ ) the April 1st candle only shows from the center of the candle and to the right (cutting off the left side). The Jun 22nd candle only shows from the center of the candle and to the left (cutting off the right side).

Shouldn't there be a whitespace border to allow the full candle to be rendered?

muthu0101 commented 6 years ago

It'll be good if this issue is fixed soon.

Griffork commented 6 years ago

If you're using the category scale then you can set offset to true in the scale's options to get the outsides rendering. Don't know if this works with the time scale. example code

amirderakh commented 5 years ago

I'm struggling with this issue, too. I guess most people use "type: 'time', distribution: 'series',". If you add "offset: true" here, a seemingly random amount off space is added to the left and right. Sometimes one candle, sometimes 2, sometimes 5.

It's important that the offset option works properly and always only adds space for half a candle to the left and right.

benmccann commented 5 years ago

I've updated the chart to set offset: true by default which addresses this issue. https://github.com/chartjs/chartjs-chart-financial/commit/333404af31aaaf03936ae20191bd92850b6d4680

@amirderakh I haven't seen the issue you're describing with offset: true. If anyone encounters that please open a new issue with a way to reproduce and I will take a look at it