Closed nagix closed 5 years ago
Thanks for this!
I wonder also if it'd be nice to update getCenterPoint
. It currently does y = (vm.candleHigh + vm.candleLow) / 2;
, which centers it between the tips as shown below
But maybe it'd be better to center it on the fat part of the bar instead? (i.e. use the average of the open and close)
For getCenterPoint
, which is used to find nearest element(s), I would keep using (vm.candleHigh + vm.candleLow) / 2
. But for tooltipPosition
, which gives the tooltip position, I agree that (vm.candleOpen + vm.candleClose) / 2
is better.
Thanks again @nagix ! I'm curious what led you to try out this chart. Are you using it for anything?
I have integrated chartjs-plugin-streaming with chartjs-chart-finance (demo), and there was an issue report today (nagix/chartjs-plugin-streaming#65).
That's great!
Btw, I noticed the first couple seconds of the demo things move around a lot. It might be nice to start the chart with some bars already present instead of starting with an empty chart. In any case, I think this is a very cool demo and it's awesome to see!
Thanks for your feedback🙂 I will update it in the next commit.
Description
When
options.tooltips.position
is set to'average'
or not specified, the tooltip won't appear. Whenoptions.tooltips.position
is set to'nearest'
, the tooltip will appear but not be centered on the candle.This happens because the default
Element.hasValue
checks_model.x
and_model.y
, butelements.Financial
doesn't have_model.y
property. This PR addshasValue
method toelements.Financial
, which checks_model.x
,_model.candleOpen
,_model.candleHigh
,_model.candleLow
and_model.candleClose
.Edit: For
tooltipPosition
,(vm.candleOpen + vm.candleClose) / 2
is used instead of(vm.candleHigh + vm.candleLow) / 2
so that the tooltip is centered on the fat part of the bar.Testing
The screenshots below are examples with
options.tooltips.position = 'nearest'
Master: https://jsfiddle.net/nagix/ub8m5tzk/
This PR: https://jsfiddle.net/nagix/dsx4vb6h/