Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
martingrossmann committed Jul 21, 2023
2 parents 1ed75c3 + c3b9bcf commit 337e936
Showing 1 changed file with 19 additions and 15 deletions.
34 changes: 19 additions & 15 deletions src/components/echart/echart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,38 +20,42 @@ export class Echart {
class:string;

private readonly onResize= () => {
this.chart?.resize();
this.chart.resize()
}

bind() {
this._createChart()
}

attached() {
if (this.options) {
this._createChart();
this.chart.setOption(this.options)
this.chart.resize()
}
window.addEventListener("resize", this.onResize);
window.addEventListener("resize", this.onResize)
}

detached() {
if (this.chart) {
this.chart.dispose();
this.chart = null;
}
window.removeEventListener("resize", this.onResize);
window.removeEventListener("resize", this.onResize)
}

unbind() {
this.chart.dispose()
this.chart = null
}

optionsChanged(newOptions:ECBasicOption) {
if (this.chart) {
this.chart.setOption(newOptions, true);
} else {
this._createChart();
if (!this.chart) {
this._createChart()
}
this.chart.setOption(newOptions, true)
this.chart.resize()
}

private _createChart() {
if (!this._container) {
return;
}

this.chart = echarts.init(this._container);
this.chart.setOption(this.options);
this.chart = echarts.init(this._container)
}
}

0 comments on commit 337e936

Please sign in to comment.