highcharts / highcharts-editor

https://www.highcharts.com/products/highcharts-editor
Other
250 stars 96 forks source link

Editor gives Formatter issue #221

Open tomlinsonml opened 4 hours ago

tomlinsonml commented 4 hours ago

Expected behaviour //save proj var projectStr = chartEditor.editor.chart.toProjectStr();

//load proj chartEditor.editor.chart.loadProject(chartProjectJson);

my previously built chart should load just fine

Actual behaviour Pulling project backup after saving a project results in formatter error: TypeError: (c[(t.formatPrefix + "Formatter")] || c.formatter).call is not a function

if i remove the formatter manually from my project json and load back into the editor everything works just fine. "formatter": "function(){let{numberFormatter:t}=this.series.chart;return"number"!=typeof this.y?"":t(this.y,-1)}",

Live demo with steps to reproduce Product version editor 2.2 and highcharts version Highcharts JS v11.4.8 (2024-08-29)

Affected browser(s) Chrome

tomlinsonml commented 4 hours ago

Temporary quick fix before loading up the project json object in order to get this to work:

                if (chartProjectJson["options"].hasOwnProperty("series")) {
                    for (var i = 0; i < chartProjectJson["options"]["series"].length; i++) {
                        if (chartProjectJson["options"]["series"][i].hasOwnProperty("dataLabels")) {
                            var dataLabel = chartProjectJson["options"]["series"][i]["dataLabels"];
                            if (dataLabel.hasOwnProperty("formatter")) {
                                delete chartProjectJson["options"]["series"][i]["dataLabels"].formatter;
                            }
                        }
                    }
                }