Closed marioleed closed 5 years ago
This is strange indeed. Could you make also live for native highcharts (forked from this for example http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/highcharts/demo/line-basic/ ) so that we can find out whose the bug is.
Sure, couldn't reproduce the bug there, though, so it seems like the bug is not in the native highcharts.
Here's a jQuery version with JavaScript: http://jsfiddle.net/qwbyf8m9/
And here's one with TypeScript: http://jsfiddle.net/utvko3ee/1/
It doesn't seem like jQuery or plain Javascript or TypeScript does anything strange, but maybe it's angular, I don't know.
thanks. looks like it is the bug.
@gevgeny, Any updates?
sorry. busy with other project now.
Hi @marioleed did you find any workaround to prevent this bug? I also need the exporting feature. Thanks for your feedback.
The only workaround for now is to store the original chartObject
before call exportChartLocal
and restore right after, I hope this helps.
Hey @attilacsanyi, no, unfortunately I haven't had the time (or priority from the customer) to fix this yet. But if you found a workaround, I'll apply it myself if it's quick =) Thanks!
Sorry for the late answer @marioleed I am using the following method for exporting:
exportChartLocal = (type = 'image/png', options = this.chartOptions) => {
const oldChartObject = this.chartObject;
this.chartObject.exportChartLocal({
sourceWidth: 2048,
type: type,
filename: 'my-chart'
}, options);
/**
* ISSUE: https://github.com/gevgeny/angular2-highcharts/issues/158
* Workaround is to store the original chartObject before export and restore after
*/
this.chartObject = _.cloneDeep(oldChartObject);
}
Beside this I have couple of issues during export, I mean not consistent, for example JPEG or PDF exported format is different in styles, it might due to my wrong implementation or this workaround, not figured it out yet...
I encountered this at work this week. I had some code pushing the context instance into an array for a specific situation where the same options were used in different views for a wizard but required access. Even outside of the wizard it would add an extra instance. After 2 manual getSVG calls for a custom full page pdf export it would delete the oldest instance which was being used and had the correct object. Haven't looked into the angular2-highcharts library yet, but may this weekend to see if there's a simple fix.
A work around is to put a condition in the (load) callback. The issue is that on exportation(which generally uses getSVG I think) it calls the (load) callback again with seemingly a copy that's missing details. You can see it being called constantly by putting a basic console log in the (load) callback.
For the time being, something like the following should fix the issue of the context being overwritten, while avoiding the need for a deep clone.
callback(instance)
if (!this.chartObject) {
this.chartObject = instance;
}
Hi Guys!any update on this bug?
Hello Guys, any update on this bug, i am also facing the same problem?
@Anj21 my solution was to change to https://github.com/highcharts/highcharts-angular .Highcharts official wrapper for Angular.
@loonix <highcharts-chart [Highcharts]="highcharts" [options]="chartOptions">
console.log("highcharts charts => ", Highcharts); //This one give highchart object as output in console. console.log("highcharts charts => ", Highcharts.charts); //Highcharts.charts give charts object as output in console. Array(0) => 0: a.Chart {renderTo: highcharts-chart, exporting: {…}, navigation: {…}, userOptions: {…}, margin: Array(4), …} length: 1 proto: Array(0)
console.log("highcharts charts[0] => ", Highcharts.charts.length, Highcharts.charts[0]); Now in this, when i am trying to access Highcharts.charts[0] it give undefined why? Can Anyone please help me to figure out this, i want to get Highcharts.charts[0].series to re-render the chart for live polling.
In AngularJs we can do like that, but i am not finding any lead for Angular7. var chart = $('#theChart').highcharts(); chart.series[0].update({ color: '#d14242' }); This is how, we can do in AngularJs, but In angular7, I am not getting. Can anyone Please help.
@loonix here is the sanpshot for the same.
@Anj21 my solution was to change to https://github.com/highcharts/highcharts-angular .Highcharts official wrapper for Angular.
Thanks for the link, now i finally added the message to the readme https://github.com/gevgeny/angular2-highcharts#%EF%B8%8F-not-supported-anymore--consider-using-the-offical-highcharts-wrapper-for-angular
@loonix <highcharts-chart [Highcharts]="highcharts" [options]="chartOptions">
console.log("highcharts charts => ", Highcharts); //This one give highchart object as output in console. console.log("highcharts charts => ", Highcharts.charts); //Highcharts.charts give charts object as output in console. Array(0) => 0: a.Chart {renderTo: highcharts-chart, exporting: {…}, navigation: {…}, userOptions: {…}, margin: Array(4), …} length: 1 proto: Array(0)
console.log("highcharts charts[0] => ", Highcharts.charts.length, Highcharts.charts[0]); Now in this, when i am trying to access Highcharts.charts[0] it give undefined why? Can Anyone please help me to figure out this, i want to get Highcharts.charts[0].series to re-render the chart for live polling.
In AngularJs we can do like that, but i am not finding any lead for Angular7. var chart = $('#theChart').highcharts(); chart.series[0].update({ color: '#d14242' }); This is how, we can do in AngularJs, but In angular7, I am not getting. Can anyone Please help.
You should be able to use the official plugin without much problems. Just take a look at the documentation and adapt to your project, I've done the same and it worked out just fine.
I don't know if this is a bug in Highcharts or in angular2-highcharts, but the saveInstance part doesn't apply to the Highcharts lib, so I'm starting the issue here.
It seems like there's a bug (and hopefully not by design) that if you save an instance of the chart object and include the exporting module and do an export (the burger menu on the top left corner - Download PNG image, etc) the chart object changes to something else. (You can cancel the File download dialog and the bug will still be there.)
Demo: http://plnkr.co/edit/KtNgEC8WtRaqdVxnawQh?p=preview
Of course, this is not good, since I need to update values on the chart, even if the user exports.
Here are the important parts:
And also include the exporting module:
Before exporting,
console.log(this.chart);
produces:After exporting,
console.log(this.chart);
produces:As you can see, there are no properties on the Chart object anymore.