UNPKG

@progress/kendo-angular-charts

Version:

Kendo UI Charts for Angular - A comprehensive package for creating beautiful and interactive data visualization. Every chart type, stock charts, and sparklines are included.

76 lines (75 loc) 3.62 kB
/**----------------------------------------------------------------------------------------- * Copyright © 2025 Progress Software Corporation. All rights reserved. * Licensed under commercial license. See LICENSE.md in the project root for more information *-------------------------------------------------------------------------------------------*/ import { Directive, EventEmitter, Input, Output } from "@angular/core"; import { isChanged } from "@progress/kendo-angular-common"; import { getter } from "@progress/kendo-common"; import { SankeyComponent } from "../../sankey.component"; import { createSankeyData } from "@progress/kendo-charts"; import { SankeyFlatBindingDataBoundEvent } from "./flat-binding.event"; import * as i0 from "@angular/core"; import * as i1 from "../../sankey.component"; /** * Represents a directive that encapsulates the retrieval of the nodes and links when flat data is provided. * * See [Data Binding - Binding to Flat Data]({% slug data_binding_sankey %}#toc-binding-to-flat-data). */ export class SankeyFlatBindingDirective { sankey; /** * Specifies the data that the Sankey diagram displays. */ data; /** * Sets the fields that identify the nodes. */ dimensionFields = []; /** * Sets the unique field that represents the link value between nodes. */ valueField; /** * Fires when the flat data has been converted to `SankeyData`. * * Modify the data to customize the created nodes and links. */ dataBound = new EventEmitter(); constructor(sankey) { this.sankey = sankey; } ngOnChanges(changes) { if (!isChanged('data', changes, false)) { return; } if (this.dimensionFields?.length === 0) { throw new Error('kendoSankeyFlatBinding: dimensionFields is required'); } if (!this.valueField) { throw new Error('kendoSankeyFlatBinding: valueField is required'); } const dimensions = this.dimensionFields.map(field => ({ value: getter(field) })); const measure = { value: getter(this.valueField) }; const data = createSankeyData(this.data, dimensions, measure); this.dataBound.emit(new SankeyFlatBindingDataBoundEvent(data)); this.sankey.notifyChanges({ data }); } static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SankeyFlatBindingDirective, deps: [{ token: i1.SankeyComponent }], target: i0.ɵɵFactoryTarget.Directive }); static ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "16.2.12", type: SankeyFlatBindingDirective, isStandalone: true, selector: "[kendoSankeyFlatBinding]", inputs: { data: ["kendoSankeyFlatBinding", "data"], dimensionFields: "dimensionFields", valueField: "valueField" }, outputs: { dataBound: "dataBound" }, usesOnChanges: true, ngImport: i0 }); } i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "16.2.12", ngImport: i0, type: SankeyFlatBindingDirective, decorators: [{ type: Directive, args: [{ selector: '[kendoSankeyFlatBinding]', standalone: true }] }], ctorParameters: function () { return [{ type: i1.SankeyComponent }]; }, propDecorators: { data: [{ type: Input, args: ['kendoSankeyFlatBinding'] }], dimensionFields: [{ type: Input }], valueField: [{ type: Input }], dataBound: [{ type: Output }] } });