syampillai/SOCharts

Chart dark mode

Closed this issue · 1 comments

Add the ability to use dark mode for chart. Something like:

updateChart(full, options, darkMode) {
        if(full) {
            this.allOptions = options;
        }
        var json = JSON.parse(options);
        this._stuff(json);
        if(!this.chart || this.chart == null) {
            darkMode = typeof darkMode !== "undefined" ? darkMode : null;
            this.chart = echarts.init(this.shadowRoot.getElementById(this.idChart), darkMode);
        }
        this.events.forEach(event => {
            this.chart.on(event.event, {name: event.data}, params => {
               console.log(event.event);
               console.log(event.data);
               this.$server.runEvent(event.event, event.data);
           })
        });
        this.chart.setOption(json);
    }

and call

executeJS("updateChart", !skipData, customizeJSON(sb.toString()));

or

executeJS("updateChart", !skipData, customizeJSON(sb.toString()), "dark");

Thanks

You can use the SOChart.setDarkMode() method available in the latest version.
Thanks for the example code.