constructor()

in src/visualComponent/mainChart/chartComponent.ts [105:176]


    constructor(options: IVisualComponentConstructorOptions) {
        super();

        this.initElement(
            options.element,
            this.className,
            "svg",
        );

        this.constructorOptions = {
            ...options,
            element: this.element,
            id: this.className,
        };

        this.lineComponent = new LineComponent(this.constructorOptions);
        this.axisComponent = new AxisComponent(this.constructorOptions);

        this.components = [
            this.lineComponent,
            this.axisComponent,
        ];

        this.zeroLineSelection = this.element
            .append("path")
            .attr("class", "zero-axis");

        this.dynamicComponents = [
            new VerticalReferenceLineComponent(this.constructorOptions),
            new HoverLabelComponent(options),
        ];

        this.hideComponents();

        this.constructorOptions.eventDispatcher
            .on(`${EventName.onMouseMove}.${this.className}`, ([leftPosition]) => {
                const index: number = this.getDataPointIndexByPosition(leftPosition);

                this.constructorOptions.eventDispatcher.call(
                    EventName.onCurrentDataPointIndexChange,
                    undefined,
                    index,
                );
            });

        this.constructorOptions.eventDispatcher.on(
            `${EventName.onMouseOut}.${this.className}`,
            () => {
                const latestDataPoint: IDataRepresentationPoint = this.renderOptions
                    && this.renderOptions.series
                    && this.renderOptions.series.current;

                this.constructorOptions.eventDispatcher.call(
                    EventName.onCurrentDataPointIndexReset,
                    undefined,
                    latestDataPoint
                        ? latestDataPoint.index
                        : NaN,
                );
            },
        );

        this.constructorOptions.eventDispatcher.on(
            `${EventName.onCurrentDataPointIndexChange}.${this.className}`,
            this.renderDynamicComponentByDataPointIndex.bind(this),
        );

        this.constructorOptions.eventDispatcher.on(
            `${EventName.onCurrentDataPointIndexReset}.${this.className}`,
            this.hideComponents.bind(this),
        );
    }