jahnvi25
Posts: 284
Joined: Thu Oct 04, 2012 12:16 pm

Annotation one end out of the plot area and mix period issue

I have highstock candlestick chart.. which shows weekly,monthly and daily candles ( one candle == 1 day or week or month)

lets say user is looking at weekly candles. and draws line.. then switches the period to Daily.. in this situation line does appear,
but it does not extend/draw properly and sometimes it draws duplicate when i try to drag..

i Hope this make sense.. video below will show you my issue..

https://vimeo.com/646512570

there is one more issue.. in the demo link ( https://jsfiddle.net/pad4o6n5/ )

select YTD display.. and then draw trendline from almost lower end of chart to upper end.. then switch chart to 3m.. you will see only one end of trendline is now visible.. if you select this and try to drag it.. then it would either mess up or disappear altogether..

is there a way to fix these issues ?
Thanks
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Annotation one end out of the plot area and mix period issue

Hello jahnvi25,

Thanks for contacting us with your issue.

The video that you shared seems to be private or only available for logged in users. Could try to change it to completely public so I can take a look at it? Thanks in advance.

Regards!
Mateusz Bernacik
Highcharts Developer
jahnvi25
Posts: 284
Joined: Thu Oct 04, 2012 12:16 pm

Re: Annotation one end out of the plot area and mix period issue

sorry about that.. Link should work now..
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Annotation one end out of the plot area and mix period issue

Hello jahnvi25,

Thanks for the vid and description, it was really helpful.

The second issue is definitely a bug, I'm going to create a ticket on github. I don't have working workaround at the moment but disabling ordinal option seems to help: https://jsfiddle.net/BlackLabel/dz8ygt0n/ I know that it is required for some charts though.

Now when it comes to video and related problem, duplicated line is most likely a bug, but I'm not quite sure what about extending and drawing. Sorry if I have missed something but the line seems to be positioned correctly when changed to smaller time frame (lookint at X and Y axes). Dragging handle seems to follow the cursor correctly. Please tell me if I have missed something here. Also, the video is certainly helpful but do you think you could reproduce that issue? It is required to create a bug report. Thanks in advance!

Just one more thing, please just to test set ordinal: false to see if the problem still occurs.

Regards!
Mateusz Bernacik
Highcharts Developer
jahnvi25
Posts: 284
Joined: Thu Oct 04, 2012 12:16 pm

Re: Annotation one end out of the plot area and mix period issue

Thanks for giving some pointers.. i started debugging more and see that drawing lines does not snap with candle.. so sometimes it falls on saturday.. and then user changes the timeline and saturday might not be there.. and that would mess up the timeline and create the issue..so using cardinal:false is better.. but we can not use that.. i
is there a way to snap lines to candles ? or points on charts.. to void this issue ?

i think there is one more issue.. we need to save user's annotation and i am following the code of 'save chart' from stock-tools.src..
as follows..

Code: Select all

chart.annotations.forEach(function (annotation, index) {
			let userOptions = annotation.userOptions;
			let copyUserOpts = $.extend({}, userOptions);
			delete copyUserOpts.events; // i do have custom events override for add,delete and drag
			annAry[index] = copyUserOpts;
		});
then while loading annotation i am using

Code: Select all

for(let ann of annAry){
							//console.log('here is the annotation..',ann);
							//ann.events = self.getAnnotationBuiltInEvents(self);
							//add annotation events back..
							chart.addAnnotation(ann,false);
						}
						//redraw he chart finally
this is mostly working.. but sometimes it fails with following exception

Code: Select all

annotations-advanced.src.js:381 Uncaught (in promise) TypeError: this.options.positioner.call is not a function
    at ControlPoint.redraw (annotations-advanced.src.js:381)
    at annotations-advanced.src.js:1112
    at Array.forEach (<anonymous>)
    at CrookedLine.redraw (annotations-advanced.src.js:1111)
    at CrookedLine.Annotation.redraw (annotations-advanced.src.js:2688)
    at annotations-advanced.src.js:3609
    at Array.forEach (<anonymous>)
    at a.drawAnnotations (annotations-advanced.src.js:3608)
    at highstock.js:19
    at Array.forEach (<anonymous>)
ControlPoint.redraw @ annotations-advanced.src.js:381
(anonymous) @ annotations-advanced.src.js:1112
redraw @ annotations-advanced.src.js:1111
Annotation.redraw @ annotations-advanced.src.js:2688
(anonymous) @ annotations-advanced.src.js:3609
drawAnnotations @ annotations-advanced.src.js:3608
(anonymous) @ highstock.js:19
q @ highstock.js:19
a.redraw @ highstock.js:355
(anonymous) @ chartprofileview.js:3986
Promise.then (async)
loadAnnotations @ chartprofileview.js:3973
(anonymous) @ chartprofileview.js:4049
Promise.then (async)
saveAnnotations @ chartprofileview.js:4045
deselectButton @ chartprofileview.js:1156
(anonymous) @ highstock.js:19
q @ highstock.js:19
NavigationBindings.bindingsChartClick @ annotations-advanced.src.js:6409
(anonymous) @ annotations-advanced.src.js:6287
and i cant figure out how to avoid that ..

any idea ?? or help.. i am really stuck here..
Thanks
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Annotation one end out of the plot area and mix period issue

Hello jahnvi25,

Could you explain what exactly do you mean by snap? Would you like annotations to attach automatically to nearby point or something like that? I need some additional details.

When it comes to your loading issue could you try to reproduce it somehow? I think you could try to get your annotations from local storage, stringify it and then apply it with addAnnotation function, exactly has you have shown in that example. Such issue example would be really helpful.

Regards!
Mateusz Bernacik
Highcharts Developer
jahnvi25
Posts: 284
Joined: Thu Oct 04, 2012 12:16 pm

Re: Annotation one end out of the plot area and mix period issue

yes.. i would like annotations to attach automatically to nearby point. (like close price).. is this possible ? this would avoid lot of confusion and possible issues.

for loading issue, i am creating sample program which i can send it over for you to look at that..
that will take some time.. sorry for delay
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Annotation one end out of the plot area and mix period issue

Hi jahnvi25,

Something like that is not implemented yet. If you would like to see such feature then you should create a feature request on our github: https://github.com/highcharts/highchart ... new/choose

When it comes to sample loading program take your time. I was thinking about the code that you have shared and maybe a proper conditional statement inside for loop would help? Something that could sort TypeError: this.options.positioner.call is not a function error.

Regards!
Mateusz Bernacik
Highcharts Developer
jahnvi25
Posts: 284
Joined: Thu Oct 04, 2012 12:16 pm

Re: Annotation one end out of the plot area and mix period issue

actually i was able to modify my code, and only save on *user action* then things are working fine. even with mix periods.. but automatic saving when annotations fires events are not working..may be events are getting fired too early or something..
i was trying to save annotations on 'Add' ,'afterUpate' (with some conditions to it will not try to save multiple time when user is moving annotations on screen).. but thats not working properly..
mateusz.b
Posts: 2006
Joined: Tue Jul 13, 2021 11:34 am

Re: Annotation one end out of the plot area and mix period issue

Hi jahnvi25,

Sorry for longer response time.

Here you can find a ticket related to one of bugs reported in this topic: https://github.com/highcharts/highcharts/issues/16784

If you have any examples where you try to save annotation on add or afterUpdate events, feel free to share. I will take a look and report if necessary. Thanks for reporting them!

Regards!
Mateusz Bernacik
Highcharts Developer

Return to “Highcharts Stock”