DEV: drops jquery usage in stacked chart (#14946)
This commit is contained in:
parent
43659a6de2
commit
c768c2ab3a
|
@ -5,28 +5,21 @@ import loadScript from "discourse/lib/load-script";
|
|||
import { makeArray } from "discourse-common/lib/helpers";
|
||||
import { number } from "discourse/lib/formatter";
|
||||
import { schedule } from "@ember/runloop";
|
||||
import { bind } from "discourse-common/utils/decorators";
|
||||
|
||||
export default Component.extend({
|
||||
classNames: ["admin-report-chart", "admin-report-stacked-chart"],
|
||||
|
||||
init() {
|
||||
this._super(...arguments);
|
||||
|
||||
this.resizeHandler = () =>
|
||||
discourseDebounce(this, this._scheduleChartRendering, 500);
|
||||
},
|
||||
|
||||
didInsertElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
$(window).on("resize.chart", this.resizeHandler);
|
||||
window.addEventListener("resize", this._resizeHandler);
|
||||
},
|
||||
|
||||
willDestroyElement() {
|
||||
this._super(...arguments);
|
||||
|
||||
$(window).off("resize.chart", this.resizeHandler);
|
||||
|
||||
window.removeEventListener("resize", this._resizeHandler);
|
||||
this._resetChart();
|
||||
},
|
||||
|
||||
|
@ -36,6 +29,11 @@ export default Component.extend({
|
|||
discourseDebounce(this, this._scheduleChartRendering, 100);
|
||||
},
|
||||
|
||||
@bind
|
||||
_resizeHandler() {
|
||||
discourseDebounce(this, this._scheduleChartRendering, 500);
|
||||
},
|
||||
|
||||
_scheduleChartRendering() {
|
||||
schedule("afterRender", () => {
|
||||
if (!this.element) {
|
||||
|
@ -149,9 +147,7 @@ export default Component.extend({
|
|||
},
|
||||
|
||||
_resetChart() {
|
||||
if (this._chart) {
|
||||
this._chart.destroy();
|
||||
this._chart = null;
|
||||
}
|
||||
this._chart?.destroy();
|
||||
this._chart = null;
|
||||
},
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue