artakserkses
Posts: 51
Joined: Tue Feb 23, 2021 11:23 am

Moving point between series

Hi again :)

I have another problem, cause since i cannot move points between charts (in easy way) i wanted to move them between series.
So i have drop event like this:

Code: Select all

            drop: data => {
              this.callbackFunction(this, data);
              console.log('DROP EVENT');
              const oldSeries = this.chartRef.series.find(ser => ser.data.find(p => p === data.target));
              const newSeries = this.chartRef.series[data.target.y];
              // data.target.series = newSeries;
              const pointOptionsObject = oldSeries.getValidPoints().find(p => p === data.target).options;
              newSeries.addPoint(pointOptionsObject);
              oldSeries.removePoint(data.target.index);
            },
and everythin (almost) works fine, after drop point is added in newSeries, and is removed in oldSeries, but i got errors when i move pointer on the chart (it seems that after oldSeries.removePoint() chart thinks that i am dragging this point, which is now undefined)

Code: Select all

core.js:6241 ERROR TypeError: Cannot read property 'options' of null
    at T (draggable-points.js:15)
    at HTMLDivElement.U.y.passive (draggable-points.js:19)
    at ZoneDelegate.invokeTask (zone-evergreen.js:399)
    at Object.onInvokeTask (core.js:41645)
    at ZoneDelegate.invokeTask (zone-evergreen.js:398)
    at Zone.runTask (zone-evergreen.js:167)
    at ZoneTask.invokeTask [as invoke] (zone-evergreen.js:480)
    at invokeTask (zone-evergreen.js:1621)
    at HTMLDivElement.globalZoneAwareCallback (zone-evergreen.js:1658)
defaultErrorLogger @ core.js:6241
handleError @ core.js:6294
next @ core.js:42627
schedulerFn @ core.js:37132
__tryOrUnsub @ Subscriber.js:183
next @ Subscriber.js:122
_next @ Subscriber.js:72
next @ Subscriber.js:49
next @ Subject.js:39
emit @ core.js:37092
(anonymous) @ core.js:41707
invoke @ zone-evergreen.js:364
run @ zone-evergreen.js:123
runOutsideAngular @ core.js:41501
onHandleError @ core.js:41704
handleError @ zone-evergreen.js:368
runTask @ zone-evergreen.js:170
invokeTask @ zone-evergreen.js:480
invokeTask @ zone-evergreen.js:1621
globalZoneAwareCallback @ zone-evergreen.js:1658
And my question is how to do it in proper way?
artakserkses
Posts: 51
Joined: Tue Feb 23, 2021 11:23 am

Re: Moving point between series

I got something like solution, but i don't think that it should be like that :)

Code: Select all

drop: data => {
              console.log('DROP EVENT');
              const oldSeries = data.target.series;
              const newSeries = this.chartRef.series[data.target.y];
              newSeries.addPoint(data.target.options);
              setTimeout(() => oldSeries.removePoint(data.target.index), 100); // <- brutal, but works :D
            },
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Moving point between series

Hi,

It's look bit complicated, could you share and simplified this example on online code editor?
That will help to work with this case :)

Best regards.
Sebastian Hajdus
Highcharts Developer
artakserkses
Posts: 51
Joined: Tue Feb 23, 2021 11:23 am

Re: Moving point between series

sebastian.h wrote: Thu Mar 04, 2021 3:42 pm Hi,

It's look bit complicated, could you share and simplified this example on online code editor?
That will help to work with this case :)

Best regards.
Sure its complicated :) With simple tasks i wouldn't write to you :)

https://jsfiddle.net/fLhn2t76/ <- this was complicated also, so i did it in js, not in angular, but it shows the problem

When you comment line 200 and uncomment line 197 it will work well.

See you soon (with new problem :twisted: )
User avatar
sebastian.h
Posts: 1734
Joined: Fri Aug 07, 2020 7:08 am

Re: Moving point between series

Hi,
Thanks for share your solution with us.
Go ahead, I will be waiting for your questions :)

Best regards.
Sebastian Hajdus
Highcharts Developer

Return to “Highcharts Gantt”