@amcharts/amcharts5
Version:
amCharts 5
52 lines • 2.17 kB
JavaScript
import { SerialChart } from "./SerialChart";
import { ZoomableContainer } from "./ZoomableContainer";
import { p100 } from "../../core/util/Percent";
/**
* A [[SerialChart]] whose `seriesContainer` is a [[ZoomableContainer]], so that
* the chart contents can be zoomed and panned.
*
* Unlike the abstract [[SerialChart]], this chart attaches its
* `seriesContainer` to the display tree on its own, so it can be instantiated
* and used directly.
*
* #since 5.20.2
*/
export class SerialChartContainer extends SerialChart {
constructor() {
super(...arguments);
/**
* A [[ZoomableContainer]] which holds chart's `seriesContainer` so it can
* be zoomed and panned.
*/
this.zoomableContainer = ZoomableContainer.new(this._root, { width: p100, height: p100, isMeasured: false })._markC("width", "height", "isMeasured");
}
_afterNew() {
super._afterNew();
this.addTag("serialchartcontainer");
this.zoomableContainer.contents.children.push(this.seriesContainer);
// Bullets sit alongside the series, so they zoom and pan with it and stay
// drawn on top of it
this.zoomableContainer.contents.children.push(this.bulletsContainer);
this.chartContainer.children.push(this.zoomableContainer);
}
_prepareChildren() {
super._prepareChildren();
if (this.isDirty("zoomTools")) {
const previous = this._prevSettings.zoomTools;
const zoomTools = this.get("zoomTools");
if (zoomTools !== previous) {
if (previous) {
previous.dispose();
}
if (zoomTools) {
zoomTools.set("target", this.zoomableContainer);
this.children.push(zoomTools);
}
this._prevSettings.zoomTools = zoomTools;
}
}
}
}
SerialChartContainer.className = "SerialChartContainer";
SerialChartContainer.classNames = SerialChart.classNames.concat([SerialChartContainer.className]);
//# sourceMappingURL=SerialChartContainer.js.map