@carbon/charts 0.51.4 → 0.52.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +38 -0
- package/build/demo/data/alluvial.d.ts +34 -2
- package/build/demo/data/meter.d.ts +22 -0
- package/build/src/components/essentials/modal.d.ts +0 -1
- package/build/src/components/graphs/alluvial.d.ts +1 -0
- package/build/src/configuration-non-customizable.d.ts +1 -0
- package/build/src/services/essentials/files.d.ts +1 -1
- package/bundle.js +1 -1
- package/chart.js +1 -0
- package/chart.js.map +1 -1
- package/charts/combo.js.map +1 -1
- package/components/component.js +6 -2
- package/components/component.js.map +1 -1
- package/components/essentials/modal.d.ts +0 -1
- package/components/essentials/modal.js +0 -5
- package/components/essentials/modal.js.map +1 -1
- package/components/essentials/title-meter.js +7 -4
- package/components/essentials/title-meter.js.map +1 -1
- package/components/graphs/alluvial.d.ts +1 -0
- package/components/graphs/alluvial.js +46 -4
- package/components/graphs/alluvial.js.map +1 -1
- package/components/graphs/bar-stacked.js +1 -1
- package/components/graphs/bar-stacked.js.map +1 -1
- package/components/graphs/meter.js +9 -5
- package/components/graphs/meter.js.map +1 -1
- package/configuration-non-customizable.d.ts +1 -0
- package/configuration-non-customizable.js +1 -0
- package/configuration-non-customizable.js.map +1 -1
- package/demo/data/alluvial.d.ts +34 -2
- package/demo/data/alluvial.js +175 -17
- package/demo/data/alluvial.js.map +1 -1
- package/demo/data/bundle.js +1 -1
- package/demo/data/hightlight.js +1 -1
- package/demo/data/hightlight.js.map +1 -1
- package/demo/data/index.js +11 -1
- package/demo/data/index.js.map +1 -1
- package/demo/data/meter.d.ts +22 -0
- package/demo/data/meter.js +32 -0
- package/demo/data/meter.js.map +1 -1
- package/demo/styles.css +4 -0
- package/demo/styles.css.map +1 -1
- package/demo/styles.min.css +1 -1
- package/demo/styles.min.css.map +1 -1
- package/demo/tsconfig.tsbuildinfo +6 -6
- package/model/meter.js +11 -2
- package/model/meter.js.map +1 -1
- package/package.json +1 -1
- package/services/essentials/files.d.ts +1 -1
- package/services/essentials/files.js +4 -4
- package/services/essentials/files.js.map +1 -1
- package/services/service.js +6 -2
- package/services/service.js.map +1 -1
- package/styles/components/_highlights.scss +1 -0
- package/styles-g10.css +1 -0
- package/styles-g10.css.map +1 -1
- package/styles-g10.min.css +1 -1
- package/styles-g10.min.css.map +1 -1
- package/styles-g100.css +1 -0
- package/styles-g100.css.map +1 -1
- package/styles-g100.min.css +1 -1
- package/styles-g100.min.css.map +1 -1
- package/styles-g90.css +1 -0
- package/styles-g90.css.map +1 -1
- package/styles-g90.min.css +1 -1
- package/styles-g90.min.css.map +1 -1
- package/styles.css +1 -0
- package/styles.css.map +1 -1
- package/styles.min.css +1 -1
- package/styles.min.css.map +1 -1
- package/tsconfig.tsbuildinfo +16 -16
package/chart.js
CHANGED
|
@@ -24,6 +24,7 @@ var Chart = /** @class */ (function () {
|
|
|
24
24
|
canvasZoom: CanvasZoom,
|
|
25
25
|
};
|
|
26
26
|
this.model = new ChartModel(this.services);
|
|
27
|
+
// do nothing.
|
|
27
28
|
}
|
|
28
29
|
// Contains the code that uses properties that are overridable by the super-class
|
|
29
30
|
Chart.prototype.init = function (holder, chartConfigs) {
|
package/chart.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chart.js","sourceRoot":"","sources":["chart.ts"],"names":[],"mappings":";;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAGN,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,MAAM,IAAI,WAAW,EACrB,WAAW,GACX,MAAM,cAAc,CAAC;AAEtB,OAAO;AACP,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAEN,KAAK,EACL,KAAK,EACL,MAAM,EACN,eAAe,EACf,OAAO,EACP,OAAO,EACP,MAAM,EACN,eAAe,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,M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5PD,IA4PC","sourcesContent":["// Internal Imports\nimport {\n\tChartConfig,\n\tBaseChartOptions,\n\tLayoutGrowth,\n\tLayoutAlignItems,\n\tLayoutDirection,\n\tLegendOrientations,\n\tEvents as ChartEvents,\n\tRenderTypes,\n} from './interfaces';\n\n// Misc\nimport { ChartModel } from './model/model';\nimport {\n\tComponent,\n\tModal,\n\tTitle,\n\tLegend,\n\tLayoutComponent,\n\tToolbar,\n\tTooltip,\n\tSpacer,\n\tCanvasChartClip,\n} from './components';\nimport { Tools } from './tools';\n\n// Services\nimport {\n\tCanvasZoom,\n\tDOMUtils,\n\tEvents,\n\tFiles,\n\tGradientUtils,\n\tTransitions,\n} from './services/index';\n\nexport class Chart {\n\tcomponents: Component[];\n\tservices: any = {\n\t\tdomUtils: DOMUtils,\n\t\tfiles: Files,\n\t\tevents: Events,\n\t\tgradientUtils: GradientUtils,\n\t\ttransitions: Transitions,\n\t\tcanvasZoom: CanvasZoom,\n\t};\n\tmodel: ChartModel = new ChartModel(this.services);\n\n\tconstructor(holder: Element, chartConfigs: ChartConfig<BaseChartOptions>) {}\n\n\t// Contains the code that uses properties that are overridable by the super-class\n\tinit(holder: Element, chartConfigs: ChartConfig<BaseChartOptions>) {\n\t\t// Store the holder in the model\n\t\tthis.model.set({ holder }, { skipUpdate: true });\n\n\t\t// Initialize all services\n\t\tObject.keys(this.services).forEach((serviceName) => {\n\t\t\tconst serviceObj = this.services[serviceName];\n\t\t\tthis.services[serviceName] = new serviceObj(\n\t\t\t\tthis.model,\n\t\t\t\tthis.services\n\t\t\t);\n\t\t});\n\n\t\t// Call update() when model has been updated\n\t\tthis.services.events.addEventListener(ChartEvents.Model.UPDATE, (e) => {\n\t\t\tconst animate = !!Tools.getProperty(e, 'detail', 'animate');\n\t\t\tthis.update(animate);\n\t\t});\n\n\t\t// Set model data & options\n\t\tthis.model.setData(chartConfigs.data);\n\n\t\t// Set chart resize event listener\n\t\tthis.services.events.addEventListener(ChartEvents.Chart.RESIZE, () => {\n\t\t\tthis.update(false);\n\t\t});\n\n\t\tthis.components = this.getComponents();\n\n\t\tthis.update();\n\t}\n\n\tgetComponents(): any[] {\n\t\tconsole.error('getComponents() method is not implemented');\n\n\t\treturn null;\n\t}\n\n\tupdate(animate = true) {\n\t\tif (!this.components) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update all services\n\t\tObject.keys(this.services).forEach((serviceName) => {\n\t\t\tconst serviceObj = this.services[serviceName];\n\t\t\tserviceObj.update();\n\t\t});\n\n\t\t// Render all components\n\t\tthis.components.forEach((component) => component.render(animate));\n\n\t\t// Asynchronously dispatch a \"render-finished\" event\n\t\t// This is needed because of d3-transitions\n\t\t// Since at the start of the transition\n\t\t// Elements do not hold their final size or position\n\t\tconst pendingTransitions = this.services.transitions.getPendingTransitions();\n\t\tconst promises = Object.keys(pendingTransitions).map((transitionID) => {\n\t\t\tconst transition = pendingTransitions[transitionID];\n\t\t\treturn transition.end().catch((e) => e); // Skip rejects since we don't care about those;\n\t\t});\n\n\t\tPromise.all(promises).then(() =>\n\t\t\tthis.services.events.dispatchEvent(\n\t\t\t\tChartEvents.Chart.RENDER_FINISHED\n\t\t\t)\n\t\t);\n\t}\n\n\tdestroy() {\n\t\t// Call the destroy() method on all components\n\t\tthis.components.forEach((component) => component.destroy());\n\n\t\t// Remove the chart holder\n\t\tthis.services.domUtils.getHolder().remove();\n\n\t\tthis.model.set({ destroyed: true }, { skipUpdate: true });\n\t}\n\n\tprotected getChartComponents(\n\t\tgraphFrameComponents: any[],\n\t\tconfigs?: object\n\t) {\n\t\tconst options = this.model.getOptions();\n\n\t\tconst toolbarEnabled = Tools.getProperty(options, 'toolbar', 'enabled');\n\n\t\tconst legendComponent = {\n\t\t\tid: 'legend',\n\t\t\tcomponents: [new Legend(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\t// if canvas zoom is enabled\n\t\tconst isZoomEnabled = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'canvasZoom',\n\t\t\t'enabled'\n\t\t);\n\n\t\tif (isZoomEnabled && isZoomEnabled === true) {\n\t\t\tgraphFrameComponents.push(\n\t\t\t\tnew CanvasChartClip(this.model, this.services)\n\t\t\t);\n\t\t}\n\n\t\tconst titleAvailable = !!this.model.getOptions().title;\n\t\tconst titleComponent = {\n\t\t\tid: 'title',\n\t\t\tcomponents: [new Title(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t};\n\n\t\tconst toolbarComponent = {\n\t\t\tid: 'toolbar',\n\t\t\tcomponents: [new Toolbar(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\tconst headerComponent = {\n\t\t\tid: 'header',\n\t\t\tcomponents: [\n\t\t\t\tnew LayoutComponent(\n\t\t\t\t\tthis.model,\n\t\t\t\t\tthis.services,\n\t\t\t\t\t[\n\t\t\t\t\t\t// always add title to keep layout correct\n\t\t\t\t\t\ttitleComponent,\n\t\t\t\t\t\t...(toolbarEnabled ? [toolbarComponent] : []),\n\t\t\t\t\t],\n\t\t\t\t\t{\n\t\t\t\t\t\tdirection: LayoutDirection.ROW,\n\t\t\t\t\t\talignItems: LayoutAlignItems.CENTER,\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\tconst graphFrameComponent = {\n\t\t\tid: 'graph-frame',\n\t\t\tcomponents: graphFrameComponents,\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t\trenderType:\n\t\t\t\tTools.getProperty(configs, 'graphFrameRenderType') ||\n\t\t\t\tRenderTypes.SVG,\n\t\t};\n\n\t\tconst isLegendEnabled =\n\t\t\tTools.getProperty(configs, 'excludeLegend') !== true &&\n\t\t\toptions.legend.enabled !== false;\n\t\t// TODORF - REUSE BETWEEN AXISCHART & CHART\n\t\t// Decide the position of the legend in reference to the chart\n\t\tlet fullFrameComponentDirection = LayoutDirection.COLUMN;\n\t\tif (isLegendEnabled) {\n\t\t\tconst legendPosition = Tools.getProperty(\n\t\t\t\toptions,\n\t\t\t\t'legend',\n\t\t\t\t'position'\n\t\t\t);\n\t\t\tif (legendPosition === 'left') {\n\t\t\t\tfullFrameComponentDirection = LayoutDirection.ROW;\n\n\t\t\t\tif (!options.legend.orientation) {\n\t\t\t\t\toptions.legend.orientation = LegendOrientations.VERTICAL;\n\t\t\t\t}\n\t\t\t} else if (legendPosition === 'right') {\n\t\t\t\tfullFrameComponentDirection = LayoutDirection.ROW_REVERSE;\n\n\t\t\t\tif (!options.legend.orientation) {\n\t\t\t\t\toptions.legend.orientation = LegendOrientations.VERTICAL;\n\t\t\t\t}\n\t\t\t} else if (legendPosition === 'bottom') {\n\t\t\t\tfullFrameComponentDirection = LayoutDirection.COLUMN_REVERSE;\n\t\t\t}\n\t\t}\n\n\t\tconst legendSpacerComponent = {\n\t\t\tid: 'spacer',\n\t\t\tcomponents: [new Spacer(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\tconst fullFrameComponent = {\n\t\t\tid: 'full-frame',\n\t\t\tcomponents: [\n\t\t\t\tnew LayoutComponent(\n\t\t\t\t\tthis.model,\n\t\t\t\t\tthis.services,\n\t\t\t\t\t[\n\t\t\t\t\t\t...(isLegendEnabled ? [legendComponent] : []),\n\t\t\t\t\t\t...(isLegendEnabled ? [legendSpacerComponent] : []),\n\t\t\t\t\t\tgraphFrameComponent,\n\t\t\t\t\t],\n\t\t\t\t\t{\n\t\t\t\t\t\tdirection: fullFrameComponentDirection,\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t],\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t};\n\n\t\t// Add chart title if it exists\n\t\tconst topLevelLayoutComponents = [];\n\n\t\tif (titleAvailable || toolbarEnabled) {\n\t\t\ttopLevelLayoutComponents.push(headerComponent);\n\n\t\t\tconst titleSpacerComponent = {\n\t\t\t\tid: 'spacer',\n\t\t\t\tcomponents: [\n\t\t\t\t\tnew Spacer(\n\t\t\t\t\t\tthis.model,\n\t\t\t\t\t\tthis.services,\n\t\t\t\t\t\ttoolbarEnabled ? { size: 15 } : undefined\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t\t};\n\n\t\t\ttopLevelLayoutComponents.push(titleSpacerComponent);\n\t\t}\n\t\ttopLevelLayoutComponents.push(fullFrameComponent);\n\n\t\treturn [\n\t\t\tnew Tooltip(this.model, this.services),\n\t\t\tnew Modal(this.model, this.services),\n\t\t\tnew LayoutComponent(\n\t\t\t\tthis.model,\n\t\t\t\tthis.services,\n\t\t\t\ttopLevelLayoutComponents,\n\t\t\t\t{\n\t\t\t\t\tdirection: LayoutDirection.COLUMN,\n\t\t\t\t}\n\t\t\t),\n\t\t];\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"chart.js","sourceRoot":"","sources":["chart.ts"],"names":[],"mappings":";;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAGN,YAAY,EACZ,gBAAgB,EAChB,eAAe,EACf,kBAAkB,EAClB,MAAM,IAAI,WAAW,EACrB,WAAW,GACX,MAAM,cAAc,CAAC;AAEtB,OAAO;AACP,OAAO,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,EAEN,KAAK,EACL,KAAK,EACL,MAAM,EACN,eAAe,EACf,OAAO,EACP,OAAO,EACP,MAAM,EACN,eAAe,GACf,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAEhC,WAAW;AACX,OAAO,EACN,UAAU,EACV,QAAQ,EACR,MAAM,EACN,KAAK,EACL,aAAa,EACb,WAAW,GACX,MAAM,kBAAkB,CAAC;AAE1B;IAYC,eAAY,MAAe,EAAE,YAA2C;QAVxE,aAAQ,GAAQ;YACf,QAAQ,EAAE,QAAQ;YAClB,KAAK,EAAE,KAAK;YACZ,MAAM,EAAE,MAAM;Y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oBAEpB;oBACC,SAAS,EAAE,2BAA2B;iBACtC,CACD;aACD;YACD,MAAM,EAAE,YAAY,CAAC,OAAO;SAC5B,CAAC;QAEF,+BAA+B;QAC/B,IAAM,wBAAwB,GAAG,EAAE,CAAC;QAEpC,IAAI,cAAc,IAAI,cAAc,EAAE;YACrC,wBAAwB,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;YAE/C,IAAM,oBAAoB,GAAG;gBAC5B,EAAE,EAAE,QAAQ;gBACZ,UAAU,EAAE;oBACX,IAAI,MAAM,CACT,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,QAAQ,EACb,cAAc,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,CAAC,CAAC,SAAS,CACzC;iBACD;gBACD,MAAM,EAAE,YAAY,CAAC,SAAS;aAC9B,CAAC;YAEF,wBAAwB,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;SACpD;QACD,wBAAwB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;QAElD,OAAO;YACN,IAAI,OAAO,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;YACtC,IAAI,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC;YACpC,IAAI,eAAe,CAClB,IAAI,CAAC,KAAK,EACV,IAAI,CAAC,QAAQ,EACb,wBAAwB,EACxB;gBACC,SAAS,EAAE,eAAe,CAAC,MAAM;aACjC,CACD;SACD,CAAC;IACH,CAAC;IACF,YAAC;AAAD,CAAC,AA9PD,IA8PC","sourcesContent":["// Internal Imports\nimport {\n\tChartConfig,\n\tBaseChartOptions,\n\tLayoutGrowth,\n\tLayoutAlignItems,\n\tLayoutDirection,\n\tLegendOrientations,\n\tEvents as ChartEvents,\n\tRenderTypes,\n} from './interfaces';\n\n// Misc\nimport { ChartModel } from './model/model';\nimport {\n\tComponent,\n\tModal,\n\tTitle,\n\tLegend,\n\tLayoutComponent,\n\tToolbar,\n\tTooltip,\n\tSpacer,\n\tCanvasChartClip,\n} from './components';\nimport { Tools } from './tools';\n\n// Services\nimport {\n\tCanvasZoom,\n\tDOMUtils,\n\tEvents,\n\tFiles,\n\tGradientUtils,\n\tTransitions,\n} from './services/index';\n\nexport class Chart {\n\tcomponents: Component[];\n\tservices: any = {\n\t\tdomUtils: DOMUtils,\n\t\tfiles: Files,\n\t\tevents: Events,\n\t\tgradientUtils: GradientUtils,\n\t\ttransitions: Transitions,\n\t\tcanvasZoom: CanvasZoom,\n\t};\n\tmodel: ChartModel = new ChartModel(this.services);\n\n\tconstructor(holder: Element, chartConfigs: ChartConfig<BaseChartOptions>) {\n\t\t// do nothing.\n\t}\n\n\t// Contains the code that uses properties that are overridable by the super-class\n\tinit(holder: Element, chartConfigs: ChartConfig<BaseChartOptions>) {\n\t\t// Store the holder in the model\n\t\tthis.model.set({ holder }, { skipUpdate: true });\n\n\t\t// Initialize all services\n\t\tObject.keys(this.services).forEach((serviceName) => {\n\t\t\tconst serviceObj = this.services[serviceName];\n\t\t\tthis.services[serviceName] = new serviceObj(\n\t\t\t\tthis.model,\n\t\t\t\tthis.services\n\t\t\t);\n\t\t});\n\n\t\t// Call update() when model has been updated\n\t\tthis.services.events.addEventListener(ChartEvents.Model.UPDATE, (e) => {\n\t\t\tconst animate = !!Tools.getProperty(e, 'detail', 'animate');\n\t\t\tthis.update(animate);\n\t\t});\n\n\t\t// Set model data & options\n\t\tthis.model.setData(chartConfigs.data);\n\n\t\t// Set chart resize event listener\n\t\tthis.services.events.addEventListener(ChartEvents.Chart.RESIZE, () => {\n\t\t\tthis.update(false);\n\t\t});\n\n\t\tthis.components = this.getComponents();\n\n\t\tthis.update();\n\t}\n\n\tgetComponents(): any[] {\n\t\tconsole.error('getComponents() method is not implemented');\n\n\t\treturn null;\n\t}\n\n\tupdate(animate = true) {\n\t\tif (!this.components) {\n\t\t\treturn;\n\t\t}\n\n\t\t// Update all services\n\t\tObject.keys(this.services).forEach((serviceName) => {\n\t\t\tconst serviceObj = this.services[serviceName];\n\t\t\tserviceObj.update();\n\t\t});\n\n\t\t// Render all components\n\t\tthis.components.forEach((component) => component.render(animate));\n\n\t\t// Asynchronously dispatch a \"render-finished\" event\n\t\t// This is needed because of d3-transitions\n\t\t// Since at the start of the transition\n\t\t// Elements do not hold their final size or position\n\t\tconst pendingTransitions = this.services.transitions.getPendingTransitions();\n\t\tconst promises = Object.keys(pendingTransitions).map((transitionID) => {\n\t\t\tconst transition = pendingTransitions[transitionID];\n\t\t\treturn transition.end().catch((e) => e); // Skip rejects since we don't care about those;\n\t\t});\n\n\t\tPromise.all(promises).then(() =>\n\t\t\tthis.services.events.dispatchEvent(\n\t\t\t\tChartEvents.Chart.RENDER_FINISHED\n\t\t\t)\n\t\t);\n\t}\n\n\tdestroy() {\n\t\t// Call the destroy() method on all components\n\t\tthis.components.forEach((component) => component.destroy());\n\n\t\t// Remove the chart holder\n\t\tthis.services.domUtils.getHolder().remove();\n\n\t\tthis.model.set({ destroyed: true }, { skipUpdate: true });\n\t}\n\n\tprotected getChartComponents(\n\t\tgraphFrameComponents: any[],\n\t\tconfigs?: object\n\t) {\n\t\tconst options = this.model.getOptions();\n\n\t\tconst toolbarEnabled = Tools.getProperty(options, 'toolbar', 'enabled');\n\n\t\tconst legendComponent = {\n\t\t\tid: 'legend',\n\t\t\tcomponents: [new Legend(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\t// if canvas zoom is enabled\n\t\tconst isZoomEnabled = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'canvasZoom',\n\t\t\t'enabled'\n\t\t);\n\n\t\tif (isZoomEnabled && isZoomEnabled === true) {\n\t\t\tgraphFrameComponents.push(\n\t\t\t\tnew CanvasChartClip(this.model, this.services)\n\t\t\t);\n\t\t}\n\n\t\tconst titleAvailable = !!this.model.getOptions().title;\n\t\tconst titleComponent = {\n\t\t\tid: 'title',\n\t\t\tcomponents: [new Title(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t};\n\n\t\tconst toolbarComponent = {\n\t\t\tid: 'toolbar',\n\t\t\tcomponents: [new Toolbar(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\tconst headerComponent = {\n\t\t\tid: 'header',\n\t\t\tcomponents: [\n\t\t\t\tnew LayoutComponent(\n\t\t\t\t\tthis.model,\n\t\t\t\t\tthis.services,\n\t\t\t\t\t[\n\t\t\t\t\t\t// always add title to keep layout correct\n\t\t\t\t\t\ttitleComponent,\n\t\t\t\t\t\t...(toolbarEnabled ? [toolbarComponent] : []),\n\t\t\t\t\t],\n\t\t\t\t\t{\n\t\t\t\t\t\tdirection: LayoutDirection.ROW,\n\t\t\t\t\t\talignItems: LayoutAlignItems.CENTER,\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\tconst graphFrameComponent = {\n\t\t\tid: 'graph-frame',\n\t\t\tcomponents: graphFrameComponents,\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t\trenderType:\n\t\t\t\tTools.getProperty(configs, 'graphFrameRenderType') ||\n\t\t\t\tRenderTypes.SVG,\n\t\t};\n\n\t\tconst isLegendEnabled =\n\t\t\tTools.getProperty(configs, 'excludeLegend') !== true &&\n\t\t\toptions.legend.enabled !== false;\n\t\t// TODORF - REUSE BETWEEN AXISCHART & CHART\n\t\t// Decide the position of the legend in reference to the chart\n\t\tlet fullFrameComponentDirection = LayoutDirection.COLUMN;\n\t\tif (isLegendEnabled) {\n\t\t\tconst legendPosition = Tools.getProperty(\n\t\t\t\toptions,\n\t\t\t\t'legend',\n\t\t\t\t'position'\n\t\t\t);\n\t\t\tif (legendPosition === 'left') {\n\t\t\t\tfullFrameComponentDirection = LayoutDirection.ROW;\n\n\t\t\t\tif (!options.legend.orientation) {\n\t\t\t\t\toptions.legend.orientation = LegendOrientations.VERTICAL;\n\t\t\t\t}\n\t\t\t} else if (legendPosition === 'right') {\n\t\t\t\tfullFrameComponentDirection = LayoutDirection.ROW_REVERSE;\n\n\t\t\t\tif (!options.legend.orientation) {\n\t\t\t\t\toptions.legend.orientation = LegendOrientations.VERTICAL;\n\t\t\t\t}\n\t\t\t} else if (legendPosition === 'bottom') {\n\t\t\t\tfullFrameComponentDirection = LayoutDirection.COLUMN_REVERSE;\n\t\t\t}\n\t\t}\n\n\t\tconst legendSpacerComponent = {\n\t\t\tid: 'spacer',\n\t\t\tcomponents: [new Spacer(this.model, this.services)],\n\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t};\n\n\t\tconst fullFrameComponent = {\n\t\t\tid: 'full-frame',\n\t\t\tcomponents: [\n\t\t\t\tnew LayoutComponent(\n\t\t\t\t\tthis.model,\n\t\t\t\t\tthis.services,\n\t\t\t\t\t[\n\t\t\t\t\t\t...(isLegendEnabled ? [legendComponent] : []),\n\t\t\t\t\t\t...(isLegendEnabled ? [legendSpacerComponent] : []),\n\t\t\t\t\t\tgraphFrameComponent,\n\t\t\t\t\t],\n\t\t\t\t\t{\n\t\t\t\t\t\tdirection: fullFrameComponentDirection,\n\t\t\t\t\t}\n\t\t\t\t),\n\t\t\t],\n\t\t\tgrowth: LayoutGrowth.STRETCH,\n\t\t};\n\n\t\t// Add chart title if it exists\n\t\tconst topLevelLayoutComponents = [];\n\n\t\tif (titleAvailable || toolbarEnabled) {\n\t\t\ttopLevelLayoutComponents.push(headerComponent);\n\n\t\t\tconst titleSpacerComponent = {\n\t\t\t\tid: 'spacer',\n\t\t\t\tcomponents: [\n\t\t\t\t\tnew Spacer(\n\t\t\t\t\t\tthis.model,\n\t\t\t\t\t\tthis.services,\n\t\t\t\t\t\ttoolbarEnabled ? { size: 15 } : undefined\n\t\t\t\t\t),\n\t\t\t\t],\n\t\t\t\tgrowth: LayoutGrowth.PREFERRED,\n\t\t\t};\n\n\t\t\ttopLevelLayoutComponents.push(titleSpacerComponent);\n\t\t}\n\t\ttopLevelLayoutComponents.push(fullFrameComponent);\n\n\t\treturn [\n\t\t\tnew Tooltip(this.model, this.services),\n\t\t\tnew Modal(this.model, this.services),\n\t\t\tnew LayoutComponent(\n\t\t\t\tthis.model,\n\t\t\t\tthis.services,\n\t\t\t\ttopLevelLayoutComponents,\n\t\t\t\t{\n\t\t\t\t\tdirection: LayoutDirection.COLUMN,\n\t\t\t\t}\n\t\t\t),\n\t\t];\n\t}\n}\n"]}
|
package/charts/combo.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combo.js","sourceRoot":"","sources":["combo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAGN,UAAU,EACV,SAAS,GACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,aAAa;AACb,OAAO,EACN,IAAI,EACJ,UAAU,EACV,SAAS,EACT,UAAU,EACV,IAAI,EACJ,kBAAkB,EAClB,QAAQ,EACR,OAAO,EACP,cAAc,EACd,IAAI,EACJ,WAAW,EACX,KAAK,EACL,YAAY,
|
|
1
|
+
{"version":3,"file":"combo.js","sourceRoot":"","sources":["combo.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,KAAK,aAAa,MAAM,kBAAkB,CAAC;AAClD,OAAO,EAGN,UAAU,EACV,SAAS,GACT,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,aAAa;AACb,OAAO,EACN,IAAI,EACJ,UAAU,EACV,SAAS,EACT,UAAU,EACV,IAAI,EACJ,kBAAkB,EACl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AI,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC,EACvC,IAAI,CAAC,kBAAkB,EAAE,CAC5B,CAAC;QAEF,IAAM,UAAU,GAAU,IAAI,CAAC,sBAAsB,CACpD,oBAAoB,CACpB,CAAC;QAEF,OAAO,UAAU,CAAC;IACnB,CAAC;IACF,iBAAC;AAAD,CAAC,AAnHD,CAAgC,SAAS,GAmHxC","sourcesContent":["// Internal Imports\nimport { AxisChart } from '../axis-chart';\nimport * as Configuration from '../configuration';\nimport {\n\tChartConfig,\n\tComboChartOptions,\n\tChartTypes,\n\tSkeletons,\n} from '../interfaces/index';\nimport { Tools } from '../tools';\n\n// Components\nimport {\n\tGrid,\n\tGroupedBar,\n\tSimpleBar,\n\tStackedBar,\n\tLine,\n\tTwoDimensionalAxes,\n\tZeroLine,\n\tScatter,\n\tStackedScatter,\n\tArea,\n\tStackedArea,\n\tRuler,\n\tStackedRuler,\n\t// the imports below are needed because of typescript bug (error TS4029)\n\tLegend,\n\tLayoutComponent,\n\tSkeleton,\n} from '../components/index';\n\nconst graphComponentsMap = {\n\t[ChartTypes.LINE]: [Line, Scatter],\n\t[ChartTypes.SCATTER]: [Scatter],\n\t[ChartTypes.AREA]: [Area, Line, Scatter],\n\t[ChartTypes.STACKED_AREA]: [\n\t\tStackedArea,\n\t\tLine,\n\t\tStackedScatter,\n\t\tStackedRuler,\n\t],\n\t[ChartTypes.SIMPLE_BAR]: [SimpleBar],\n\t[ChartTypes.GROUPED_BAR]: [GroupedBar, ZeroLine],\n\t[ChartTypes.STACKED_BAR]: [StackedBar, StackedRuler],\n};\n\nexport class ComboChart extends AxisChart {\n\tconstructor(holder: Element, chartConfigs: ChartConfig<ComboChartOptions>) {\n\t\tsuper(holder, chartConfigs);\n\n\t\t// Merge the default options for this chart\n\t\t// With the user provided options\n\t\tconst chartOptions = Tools.mergeDefaultChartOptions(\n\t\t\tConfiguration.options.comboChart,\n\t\t\tchartConfigs.options\n\t\t);\n\n\t\t// Warn user if no comboChartTypes defined\n\t\t// Use skeleton chart instead\n\t\tif (!chartConfigs.options.comboChartTypes) {\n\t\t\tconsole.error('No comboChartTypes defined for the Combo Chart!');\n\t\t\t// add a default chart to get an empty chart\n\t\t\tchartOptions.comboChartTypes = [\n\t\t\t\t{ type: ChartTypes.LINE, correspondingDatasets: [] },\n\t\t\t];\n\t\t}\n\n\t\t// set the global options\n\t\tthis.model.setOptions(chartOptions);\n\n\t\t// Initialize data, services, components etc.\n\t\tthis.init(holder, chartConfigs);\n\t}\n\n\tgetGraphComponents() {\n\t\tconst { comboChartTypes } = this.model.getOptions();\n\t\tlet counter = 0;\n\t\tconst graphComponents = comboChartTypes\n\t\t\t.map((graph) => {\n\t\t\t\tconst type = graph.type;\n\t\t\t\tlet options;\n\n\t\t\t\t// initializes the components using input strings with the base configs for each chart\n\t\t\t\tif (typeof graph.type === 'string') {\n\t\t\t\t\t// check if it is in the components map\n\t\t\t\t\t// if it isn't then it is not a valid carbon chart to use in combo\n\t\t\t\t\tif (!Object.keys(graphComponentsMap).includes(graph.type)) {\n\t\t\t\t\t\tconsole.error(\n\t\t\t\t\t\t\t`Invalid chart type \"${graph.type}\" specified for combo chart. Please refer to the ComboChart tutorial for more guidance.`\n\t\t\t\t\t\t);\n\t\t\t\t\t\treturn null;\n\t\t\t\t\t}\n\t\t\t\t\tlet stacked;\n\t\t\t\t\toptions = Tools.merge(\n\t\t\t\t\t\t{},\n\t\t\t\t\t\tConfiguration.options[\n\t\t\t\t\t\t\t`${Tools.camelCase(graph.type)}Chart`\n\t\t\t\t\t\t],\n\t\t\t\t\t\tthis.model.getOptions(),\n\t\t\t\t\t\tgraph.options\n\t\t\t\t\t);\n\t\t\t\t\t// if we are creating a stacked area, the contained Line chart needs to know it is stacked\n\t\t\t\t\tif (graph.type === ChartTypes.STACKED_AREA) {\n\t\t\t\t\t\tstacked = true;\n\t\t\t\t\t}\n\t\t\t\t\treturn graphComponentsMap[graph.type].map(\n\t\t\t\t\t\t(Component, i) =>\n\t\t\t\t\t\t\tnew Component(this.model, this.services, {\n\t\t\t\t\t\t\t\tgroups: graph.correspondingDatasets,\n\t\t\t\t\t\t\t\tid: counter++,\n\t\t\t\t\t\t\t\toptions: options,\n\t\t\t\t\t\t\t\tstacked,\n\t\t\t\t\t\t\t})\n\t\t\t\t\t);\n\t\t\t\t} else {\n\t\t\t\t\t// user has imported a type or custom component to instantiate\n\t\t\t\t\toptions = Tools.merge(\n\t\t\t\t\t\t{},\n\t\t\t\t\t\tthis.model.getOptions(),\n\t\t\t\t\t\tgraph.options\n\t\t\t\t\t);\n\t\t\t\t\treturn new type(this.model, this.services, {\n\t\t\t\t\t\tgroups: graph.correspondingDatasets,\n\t\t\t\t\t\tid: counter++,\n\t\t\t\t\t\toptions: options,\n\t\t\t\t\t});\n\t\t\t\t}\n\t\t\t})\n\t\t\t.filter((item) => item !== null);\n\n\t\treturn Tools.flatten(graphComponents);\n\t}\n\n\tgetComponents() {\n\t\tconst { comboChartTypes } = this.model.getOptions();\n\t\t// don't add the regular ruler if stacked ruler is added\n\t\tconst stackedRulerEnabled = comboChartTypes.some(\n\t\t\t(chartObject) =>\n\t\t\t\tchartObject.type === ChartTypes.STACKED_BAR ||\n\t\t\t\tchartObject.type === ChartTypes.STACKED_AREA\n\t\t);\n\n\t\t// Specify what to render inside the graph-frame\n\t\tconst graphFrameComponents = [\n\t\t\tnew TwoDimensionalAxes(this.model, this.services),\n\t\t\tnew Grid(this.model, this.services),\n\t\t\tnew Skeleton(this.model, this.services, {\n\t\t\t\tskeleton: Skeletons.GRID,\n\t\t\t}),\n\t\t\t...(stackedRulerEnabled\n\t\t\t\t? []\n\t\t\t\t: [new Ruler(this.model, this.services)]),\n\t\t\t...this.getGraphComponents(),\n\t\t];\n\n\t\tconst components: any[] = this.getAxisChartComponents(\n\t\t\tgraphFrameComponents\n\t\t);\n\n\t\treturn components;\n\t}\n}\n"]}
|
package/components/component.js
CHANGED
|
@@ -23,12 +23,16 @@ var Component = /** @class */ (function () {
|
|
|
23
23
|
this.setParent(select(this.services.domUtils.getMainContainer()));
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
Component.prototype.init = function () {
|
|
26
|
+
Component.prototype.init = function () {
|
|
27
|
+
// do nothing.
|
|
28
|
+
};
|
|
27
29
|
Component.prototype.render = function (animate) {
|
|
28
30
|
if (animate === void 0) { animate = true; }
|
|
29
31
|
console.error('render() method is not implemented');
|
|
30
32
|
};
|
|
31
|
-
Component.prototype.destroy = function () {
|
|
33
|
+
Component.prototype.destroy = function () {
|
|
34
|
+
// do nothing.
|
|
35
|
+
};
|
|
32
36
|
// Used to pass down information to the components
|
|
33
37
|
Component.prototype.setModel = function (newObj) {
|
|
34
38
|
this.model = newObj;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["component.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,KAAK,EAAE,MAAM,UAAU,CAAC;AAEjC,aAAa;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,yCAAyC;AACzC,OAAO,QAAQ,MAAM,0CAA0C,CAAC;AAEhE;IAaC,mBAAY,KAAiB,EAAE,QAAa,EAAE,OAAa;QAXpD,eAAU,GAAG,WAAW,CAAC,IAAI,CAAC;QAM3B,YAAO,GAAQ,EAAE,CAAC;QAM3B,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QACnB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QAEzB,IAAI,OAAO,EAAE;YACZ,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;YACvB,IAAI,IAAI,CAAC,OAAO,CAAC,EAAE,EAAE;gBACpB,IAAM,WAAW,GAAG,KAAK,CAAC,WAAW,CACpC,IAAI,CAAC,KAAK,C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M,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;SAC9D;QAED,OAAO,IAAI,CAAC,MAAM,CAAC;IACpB,CAAC;IAED;;;;OAIG;IACH,8BAAU,GAAV;QACC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACzB,IAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAC1B,EAAE,EACF,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,EACvB,IAAI,CAAC,OAAO,CAAC,OAAO,CACpB,CAAC;YACF,OAAO,OAAO,CAAC;SACf;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;IAChC,CAAC;IACF,gBAAC;AAAD,CAAC,AAtJD,IAsJC","sourcesContent":["// Internal Imports\nimport { ChartModel } from '../model/model';\nimport { DOMUtils } from '../services';\nimport { RenderTypes } from '../interfaces';\nimport { Tools } from '../tools';\n\n// D3 Imports\nimport { select } from 'd3-selection';\n\n// import the settings for the css prefix\nimport settings from 'carbon-components/es/globals/js/settings';\n\nexport class Component {\n\tpublic type: string;\n\tpublic renderType = RenderTypes.HTML;\n\n\tpublic id: string;\n\n\tprotected parent: any;\n\n\tprotected configs: any = {};\n\n\tprotected model: any;\n\tprotected services: any;\n\n\tconstructor(model: ChartModel, services: any, configs?: any) {\n\t\tthis.model = model;\n\t\tthis.services = services;\n\n\t\tif (configs) {\n\t\t\tthis.configs = configs;\n\t\t\tif (this.configs.id) {\n\t\t\t\tconst chartprefix = Tools.getProperty(\n\t\t\t\t\tthis.model.getOptions(),\n\t\t\t\t\t'style',\n\t\t\t\t\t'prefix'\n\t\t\t\t);\n\t\t\t\tthis.id = `${chartprefix}--${this.configs.id}`;\n\t\t\t}\n\t\t}\n\n\t\t// Set parent element to shell SVG if no parent exists for component\n\t\tif (!this.parent) {\n\t\t\tthis.setParent(select(this.services.domUtils.getMainContainer()));\n\t\t}\n\t}\n\n\tinit() {\n\t\t// do nothing.\n\t}\n\n\trender(animate = true) {\n\t\tconsole.error('render() method is not implemented');\n\t}\n\n\tdestroy() {\n\t\t// do nothing.\n\t}\n\n\t// Used to pass down information to the components\n\tsetModel(newObj) {\n\t\tthis.model = newObj;\n\t}\n\n\t// Used to pass down information to the components\n\tsetServices(newObj) {\n\t\tthis.services = newObj;\n\t}\n\n\tsetParent(parent) {\n\t\tconst oldParent = this.parent;\n\t\tthis.parent = parent;\n\n\t\tif (oldParent && oldParent.node() === parent.node()) {\n\t\t\treturn;\n\t\t}\n\n\t\tif (this.type) {\n\t\t\tconst chartprefix = Tools.getProperty(\n\t\t\t\tthis.model.getOptions(),\n\t\t\t\t'style',\n\t\t\t\t'prefix'\n\t\t\t);\n\t\t\tthis.parent.classed(\n\t\t\t\t`${settings.prefix}--${chartprefix}--${this.type}`,\n\t\t\t\ttrue\n\t\t\t);\n\n\t\t\tif (oldParent) {\n\t\t\t\toldParent.classed(\n\t\t\t\t\t`${settings.prefix}--${chartprefix}--${this.type}`,\n\t\t\t\t\tfalse\n\t\t\t\t);\n\t\t\t}\n\t\t}\n\t}\n\n\tgetParent() {\n\t\treturn this.parent;\n\t}\n\n\tgetComponentContainer(configs = { withinChartClip: false }) {\n\t\tif (this.type) {\n\t\t\tconst chartprefix = Tools.getProperty(\n\t\t\t\tthis.model.getOptions(),\n\t\t\t\t'style',\n\t\t\t\t'prefix'\n\t\t\t);\n\n\t\t\tconst idSelector = this.id ? `#${this.id}` : '';\n\t\t\tconst container = DOMUtils.appendOrSelect(\n\t\t\t\tthis.parent,\n\t\t\t\t`${\n\t\t\t\t\tthis.renderType === RenderTypes.SVG ? 'svg' : 'div'\n\t\t\t\t}${idSelector}.${settings.prefix}--${chartprefix}--${this.type}`\n\t\t\t);\n\n\t\t\tif (configs.withinChartClip) {\n\t\t\t\t// get unique chartClipId int this chart from model\n\t\t\t\tconst chartClipId = this.model.get('chartClipId');\n\n\t\t\t\tif (chartClipId) {\n\t\t\t\t\tconst chartClipSelection = select(`#${chartClipId}`);\n\t\t\t\t\tconst chartClipRectSelection = chartClipSelection.select(\n\t\t\t\t\t\t'rect'\n\t\t\t\t\t);\n\n\t\t\t\t\t/*\n\t\t\t\t\t * these checks are needed because of a chrome bug\n\t\t\t\t\t * related to the rendering of the clip path\n\t\t\t\t\t */\n\t\t\t\t\tif (\n\t\t\t\t\t\tchartClipRectSelection.size() !== 0 &&\n\t\t\t\t\t\tparseFloat(chartClipRectSelection.attr('height')) > 0\n\t\t\t\t\t) {\n\t\t\t\t\t\tcontainer.attr('clip-path', `url(#${chartClipId})`);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\n\t\t\treturn container.attr('width', '100%').attr('height', '100%');\n\t\t}\n\n\t\treturn this.parent;\n\t}\n\n\t/**\n\t * graphs used in combo charts share a model with global options but can receive their own local options.\n\t * this function retrieves the global options and merges it with any options passed into this\n\t * component's config.options object.\n\t */\n\tgetOptions() {\n\t\tif (this.configs.options) {\n\t\t\tconst options = Tools.merge(\n\t\t\t\t{},\n\t\t\t\tthis.model.getOptions(),\n\t\t\t\tthis.configs.options\n\t\t\t);\n\t\t\treturn options;\n\t\t}\n\t\treturn this.model.getOptions();\n\t}\n}\n"]}
|
|
@@ -6,7 +6,6 @@ export declare class Modal extends Component {
|
|
|
6
6
|
modal: any;
|
|
7
7
|
constructor(model: ChartModel, services: any, configs?: any);
|
|
8
8
|
handleShowModal: () => void;
|
|
9
|
-
handleHideModal: () => void;
|
|
10
9
|
addEventListeners(): void;
|
|
11
10
|
removeEventListeners(): void;
|
|
12
11
|
getModalHTML(): string;
|
|
@@ -37,21 +37,16 @@ var Modal = /** @class */ (function (_super) {
|
|
|
37
37
|
var modalInstance = CarbonModalComponent.create(_this.modal.node());
|
|
38
38
|
modalInstance.show();
|
|
39
39
|
};
|
|
40
|
-
_this.handleHideModal = function () { };
|
|
41
40
|
_this.init();
|
|
42
41
|
return _this;
|
|
43
42
|
}
|
|
44
43
|
Modal.prototype.addEventListeners = function () {
|
|
45
44
|
// listen to show-modal Custom Events to render the modal
|
|
46
45
|
this.services.events.addEventListener(Events.Modal.SHOW, this.handleShowModal);
|
|
47
|
-
// listen to hide-modal Custom Events to hide the modal
|
|
48
|
-
this.services.events.addEventListener(Events.Modal.HIDE, this.handleHideModal);
|
|
49
46
|
};
|
|
50
47
|
Modal.prototype.removeEventListeners = function () {
|
|
51
48
|
// remove show-modal Custom Events
|
|
52
49
|
this.services.events.removeEventListener(Events.Modal.SHOW, this.handleShowModal);
|
|
53
|
-
// remove hide-modal Custom Events
|
|
54
|
-
this.services.events.removeEventListener(Events.Modal.HIDE, this.handleHideModal);
|
|
55
50
|
};
|
|
56
51
|
Modal.prototype.getModalHTML = function () {
|
|
57
52
|
var options = this.model.getOptions();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"modal.js","sourceRoot":"","sources":["modal.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"modal.js","sourceRoot":"","sources":["modal.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAE1C,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAE1C,eAAe;AACf,OAAO,EAAE,KAAK,IAAI,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AAElE,yCAAyC;AACzC,OAAO,QAAQ,MAAM,0CAA0C,CAAC;AAEhE,aAAa;AACb,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAEtC,OAAO,EAAE,GAAG,EAAE,MAAM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AAQ,CAAC;iBACtB,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC;iBACxB,IAAI,CAAC,iBAAiB,EAAE,aAAa,CAAC;iBACtC,IAAI,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;iBAC7C,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC,CAAC,CAAC;SACvB;IACF,CAAC;IAED,uBAAO,GAAP;QACC,+BAA+B;QAC/B,IAAI,CAAC,oBAAoB,EAAE,CAAC;QAC5B,IAAI,CAAC,oBAAoB,GAAG,KAAK,CAAC;IACnC,CAAC;IACF,YAAC;AAAD,CAAC,AAvHD,CAA2B,SAAS,GAuHnC","sourcesContent":["import { Component } from '../component';\nimport { Tools } from '../../tools';\nimport { DOMUtils } from '../../services';\nimport { ChartModel } from '../../model/model';\nimport { Events } from '../../interfaces';\n\n// Carbon modal\nimport { Modal as CarbonModalComponent } from 'carbon-components';\n\n// import the settings for the css prefix\nimport settings from 'carbon-components/es/globals/js/settings';\n\n// D3 Imports\nimport { select } from 'd3-selection';\n\nimport { get } from 'lodash-es';\n\nexport class Modal extends Component {\n\ttype = 'modal';\n\n\t// flag for checking whether tooltip event listener is added or not\n\tisEventListenerAdded = false;\n\tmodal: any;\n\n\tconstructor(model: ChartModel, services: any, configs?: any) {\n\t\tsuper(model, services, configs);\n\n\t\tthis.init();\n\t}\n\n\thandleShowModal = () => {\n\t\tthis.modal.html(this.getModalHTML());\n\t\tthis.modal\n\t\t\t.select('div.bx--modal-footer button.bx--btn')\n\t\t\t.on('click', () => this.model.exportToCSV());\n\n\t\tconst modalInstance = CarbonModalComponent.create(this.modal.node());\n\t\tmodalInstance.show();\n\t};\n\n\taddEventListeners() {\n\t\t// listen to show-modal Custom Events to render the modal\n\t\tthis.services.events.addEventListener(\n\t\t\tEvents.Modal.SHOW,\n\t\t\tthis.handleShowModal\n\t\t);\n\t}\n\n\tremoveEventListeners() {\n\t\t// remove show-modal Custom Events\n\t\tthis.services.events.removeEventListener(\n\t\t\tEvents.Modal.SHOW,\n\t\t\tthis.handleShowModal\n\t\t);\n\t}\n\n\tgetModalHTML() {\n\t\tconst options = this.model.getOptions();\n\n\t\tconst chartprefix = Tools.getProperty(options, 'style', 'prefix');\n\n\t\tconst tableArray = this.model.getTabularDataArray();\n\n\t\treturn `\n\t\t<div class=\"bx--modal-container\">\n\t\t\t<div class=\"bx--modal-header\">\n\t\t\t\t<p class=\"bx--modal-header__label bx--type-delta\" id=\"modal-title\">Tabular representation</p>\n\t\t\t\t<p class=\"bx--modal-header__heading bx--type-beta\" id=\"modal-description\">${\n\t\t\t\t\toptions.title\n\t\t\t\t}</p>\n\t\t\t\t<button class=\"bx--modal-close\" type=\"button\" data-modal-close aria-label=\"close modal\" data-modal-primary-focus>\n\t\t\t\t\t<svg focusable=\"false\" preserveAspectRatio=\"xMidYMid meet\" xmlns=\"http://www.w3.org/2000/svg\" fill=\"currentColor\" aria-label=\"Close\" width=\"20\" height=\"20\" viewBox=\"0 0 32 32\" role=\"img\" class=\"bx--modal-close__icon\">\n\t\t\t\t\t\t<path d=\"M24 9.4L22.6 8 16 14.6 9.4 8 8 9.4 14.6 16 8 22.6 9.4 24 16 17.4 22.6 24 24 22.6 17.4 16 24 9.4z\"></path>\n\t\t\t\t\t</svg>\n\t\t\t\t</button>\n\t\t\t</div>\n\t\t\t<div class=\"bx--modal-content\"><table class=\"bx--data-table bx--data-table--no-border\">\n\t\t\t\t\t<thead>\n\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t${get(tableArray, 0)\n\t\t\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t\t\t(heading) => `<th scope=\"col\">\n\t\t\t\t\t\t\t\t<div class=\"bx--table-header-label\">${heading}</div>\n\t\t\t\t\t\t\t</th>`\n\t\t\t\t\t\t\t\t)\n\t\t\t\t\t\t\t\t.join('')}\n\t\t\t\t\t\t</tr>\n\t\t\t\t\t</thead>\n\t\t\t\t\t<tbody>${tableArray\n\t\t\t\t\t\t.slice(1)\n\t\t\t\t\t\t.map(\n\t\t\t\t\t\t\t(row) => `\n\t\t\t\t\t\t\t<tr>\n\t\t\t\t\t\t\t\t${row.map((column) => `<td>${column}</td>`).join('')}\n\t\t\t\t\t\t\t</tr>`\n\t\t\t\t\t\t)\n\t\t\t\t\t\t.join('')}\n\t\t\t\t\t</tbody>\n\t\t\t\t</table>\n\t\t\t</div>\n\t\t\t<div class=\"bx--modal-footer\">\n\t\t\t <div class=\"${settings.prefix}--${chartprefix}-modal-footer-spacer\"></div>\n\t\t\t <button class=\"bx--btn bx--btn--primary\" type=\"button\" data-modal-primary-focus>Download as CSV</button>\n\t\t\t</div>\n\t\t</div>`;\n\t}\n\n\trender() {\n\t\tconst options = this.model.getOptions();\n\t\tif (!this.isEventListenerAdded) {\n\t\t\t// Grab the tooltip element\n\t\t\tconst holder = select(this.services.domUtils.getHolder());\n\t\t\tconst chartprefix = Tools.getProperty(options, 'style', 'prefix');\n\t\t\tthis.modal = DOMUtils.appendOrSelect(\n\t\t\t\tholder,\n\t\t\t\t`div.${settings.prefix}--${chartprefix}--modal`\n\t\t\t);\n\n\t\t\tthis.addEventListeners();\n\t\t\tthis.isEventListenerAdded = true;\n\t\t\tthis.modal\n\t\t\t\t.attr('data-modal', true)\n\t\t\t\t.attr('class', 'bx--modal')\n\t\t\t\t.attr('role', 'dialog')\n\t\t\t\t.attr('aria-modal', true)\n\t\t\t\t.attr('aria-labelledby', 'modal-title')\n\t\t\t\t.attr('aria-describedby', 'modal-description')\n\t\t\t\t.attr('tabindex', -1);\n\t\t}\n\t}\n\n\tdestroy() {\n\t\t// remove tooltip eventListener\n\t\tthis.removeEventListeners();\n\t\tthis.isEventListenerAdded = false;\n\t}\n}\n"]}
|
|
@@ -51,9 +51,9 @@ var MeterTitle = /** @class */ (function (_super) {
|
|
|
51
51
|
title.exit().remove();
|
|
52
52
|
// appends the associated percentage after title
|
|
53
53
|
this.appendPercentage();
|
|
54
|
-
// if status ranges are provided (custom or default), display indicator
|
|
55
|
-
this.displayStatus();
|
|
56
54
|
}
|
|
55
|
+
// if status ranges are provided (custom or default), display indicator
|
|
56
|
+
this.displayStatus();
|
|
57
57
|
// get the max width of a title (with consideration for the status/percentage)
|
|
58
58
|
var maxWidth = this.getMaxTitleWidth();
|
|
59
59
|
var titleElement = DOMUtils.appendOrSelect(svg, 'text.meter-title');
|
|
@@ -124,7 +124,7 @@ var MeterTitle = /** @class */ (function (_super) {
|
|
|
124
124
|
var totalString = totalFormatter !== null
|
|
125
125
|
? totalFormatter(totalValue)
|
|
126
126
|
: total + " " + unit + " total";
|
|
127
|
-
var containerBounds = DOMUtils.
|
|
127
|
+
var containerBounds = DOMUtils.getHTMLElementSize(this.services.domUtils.getMainContainer());
|
|
128
128
|
// need to check if the width is 0, and try to use the parent attribute
|
|
129
129
|
// this can happen if the chart is toggled on/off and the height is 0 for the parent, it wont validateDimensions
|
|
130
130
|
var containerWidth = containerBounds.width
|
|
@@ -138,7 +138,10 @@ var MeterTitle = /** @class */ (function (_super) {
|
|
|
138
138
|
.append('text')
|
|
139
139
|
.classed('proportional-meter-total', true)
|
|
140
140
|
.merge(title)
|
|
141
|
-
|
|
141
|
+
// Position the total text -24 pixels to add spacing between text and status icon (if status exists)
|
|
142
|
+
.attr('x', this.model.getStatus()
|
|
143
|
+
? containerWidth - Configuration.meter.total.paddingRight
|
|
144
|
+
: containerWidth)
|
|
142
145
|
.attr('y', '1em')
|
|
143
146
|
.attr('text-anchor', 'end')
|
|
144
147
|
.text(function (d) { return d; });
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"title-meter.js","sourceRoot":"","sources":["title-meter.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,mBAAmB;AACnB,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AACpC,OAAO,EAAE,WAAW,EAAE,QAAQ,E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N,IAAM,UAAU,GAAG,QAAQ,CAAC,cAAc,CACzC,IAAI,CAAC,MAAM,EACX,oBAAoB,CACpB,CAAC;YACF,sGAAsG;YACtG,IAAM,MAAM,GAAG,aAAa,CAAC,KAAK,CAAC,SAAS,CAAC,YAAY,CAAC;YAC1D,IAAM,eAAe,GAAG,UAAU,CAAC,IAAI,EAAE,CAAC,qBAAqB,EAAE,CAAC;YAElE,IAAM,WAAW,GAAG,QAAQ,CAAC,cAAc,CAC1C,IAAI,CAAC,MAAM,EACX,oBAAoB,CACpB,CAAC,IAAI,EAAE,CAAC;YACT,IAAM,WAAW,GAChB,QAAQ,CAAC,iBAAiB,CAAC,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;iBACxD,KAAK,GAAG,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,WAAW,CAAC;YAElD,OAAO,cAAc,GAAG,eAAe,GAAG,MAAM,GAAG,WAAW,CAAC;SAC/D;IACF,CAAC;IAED;;;OAGG;IACO,4CAAuB,GAAjC,UAAkC,MAAM;QACvC,QAAQ,MAAM,EAAE;YACf,KAAK,QAAQ,CAAC,OAAO;gBACpB,OAAO,mFAAmF,CAAC;YAC5F,KAAK,QAAQ,CAAC,MAAM;gBACnB,OAAO,wCAAwC,CAAC;YACjD,KAAK,QAAQ,CAAC,OAAO;gBACpB,OAAO,0PAA0P,CAAC;SACnQ;IACF,CAAC;IACF,iBAAC;AAAD,CAAC,AA7XD,CAAgC,KAAK,GA6XpC","sourcesContent":["// Internal Imports\nimport { Title } from './title';\nimport { DOMUtils } from '../../services';\nimport { Tools } from '../../tools';\nimport { RenderTypes, Statuses } from './../../interfaces/enums';\nimport * as Configuration from '../../configuration';\n\nexport class MeterTitle extends Title {\n\ttype = 'meter-title';\n\trenderType = RenderTypes.SVG;\n\n\trender() {\n\t\tconst dataset = Tools.getProperty(this.model.getDisplayData(), 0);\n\t\tconst options = this.getOptions();\n\t\tconst svg = this.getComponentContainer();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst proportional = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'meter',\n\t\t\t'proportional'\n\t\t);\n\n\t\tif (proportional) {\n\t\t\tthis.displayTotal();\n\t\t\tthis.displayBreakdownTitle();\n\t\t} else {\n\t\t\t// the title for a meter, is the label for that dataset\n\t\t\tconst title = svg\n\t\t\t\t.selectAll('text.meter-title')\n\t\t\t\t.data([dataset[groupMapsTo]]);\n\n\t\t\ttitle\n\t\t\t\t.enter()\n\t\t\t\t.append('text')\n\t\t\t\t.classed('meter-title', true)\n\t\t\t\t.merge(title)\n\t\t\t\t.attr('x', 0)\n\t\t\t\t.attr('y', '1em')\n\t\t\t\t.text((d) => d);\n\n\t\t\ttitle.exit().remove();\n\n\t\t\t// appends the associated percentage after title\n\t\t\tthis.appendPercentage();\n\n\t\t\t// if status ranges are provided (custom or default), display indicator\n\t\t\tthis.displayStatus();\n\t\t}\n\t\t// get the max width of a title (with consideration for the status/percentage)\n\t\tconst maxWidth = this.getMaxTitleWidth();\n\t\tconst titleElement = DOMUtils.appendOrSelect(svg, 'text.meter-title');\n\n\t\tif (\n\t\t\tmaxWidth > 0 &&\n\t\t\ttitleElement.node().getComputedTextLength() > maxWidth\n\t\t) {\n\t\t\tthis.truncateTitle(titleElement, maxWidth);\n\t\t}\n\t}\n\n\tdisplayBreakdownTitle() {\n\t\tconst self = this;\n\t\tconst svg = this.getComponentContainer();\n\t\tconst options = this.getOptions();\n\t\tconst datasetsTotal = this.model.getMaximumDomain(\n\t\t\tthis.model.getDisplayData()\n\t\t);\n\t\tconst total = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'meter',\n\t\t\t'proportional',\n\t\t\t'total'\n\t\t);\n\t\tconst unit = Tools.getProperty(options, 'meter', 'proportional', 'unit')\n\t\t\t? Tools.getProperty(options, 'meter', 'proportional', 'unit')\n\t\t\t: '';\n\n\t\tlet data;\n\t\tif (datasetsTotal === total) {\n\t\t\tdata = null;\n\t\t} else {\n\t\t\tconst difference =\n\t\t\t\ttotal !== null ? total - datasetsTotal : datasetsTotal;\n\t\t\t//breakdownFormatter\n\t\t\tconst breakdownFormatter = Tools.getProperty(\n\t\t\t\toptions,\n\t\t\t\t'meter',\n\t\t\t\t'proportional',\n\t\t\t\t'breakdownFormatter'\n\t\t\t);\n\t\t\tdata =\n\t\t\t\tbreakdownFormatter !== null\n\t\t\t\t\t? breakdownFormatter({\n\t\t\t\t\t\t\tdatasetsTotal: datasetsTotal,\n\t\t\t\t\t\t\ttotal: total,\n\t\t\t\t\t })\n\t\t\t\t\t: `${datasetsTotal} ${unit} used (${difference} ${unit} available)`;\n\t\t}\n\n\t\t// the breakdown part to whole of the datasets to the overall total\n\t\tconst title = svg\n\t\t\t.selectAll('text.proportional-meter-title')\n\t\t\t.data([data]);\n\n\t\ttitle\n\t\t\t.enter()\n\t\t\t.append('text')\n\t\t\t.classed('proportional-meter-title', true)\n\t\t\t.merge(title)\n\t\t\t.attr('x', 0)\n\t\t\t.attr('y', '1em')\n\t\t\t.text((d) => d);\n\n\t\ttitle.exit().remove();\n\n\t\tconst maxWidth = this.getMaxTitleWidth();\n\t\tconst titleElement = DOMUtils.appendOrSelect(\n\t\t\tsvg,\n\t\t\t'text.proportional-meter-title'\n\t\t);\n\n\t\tif (\n\t\t\tmaxWidth > 0 &&\n\t\t\ttitleElement.node().getComputedTextLength() > maxWidth\n\t\t) {\n\t\t\tthis.truncateTitle(titleElement, maxWidth);\n\t\t}\n\t}\n\n\t// show the total for prop meter\n\tdisplayTotal() {\n\t\tconst self = this;\n\t\tconst svg = this.getComponentContainer();\n\t\tconst options = this.getOptions();\n\n\t\tconst total = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'meter',\n\t\t\t'proportional',\n\t\t\t'total'\n\t\t);\n\n\t\tconst totalValue = total\n\t\t\t? Tools.getProperty(options, 'meter', 'proportional', 'total')\n\t\t\t: this.model.getMaximumDomain(this.model.getDisplayData());\n\n\t\tconst unit = Tools.getProperty(options, 'meter', 'proportional', 'unit')\n\t\t\t? Tools.getProperty(options, 'meter', 'proportional', 'unit')\n\t\t\t: '';\n\n\t\t// totalFormatter function\n\t\tconst totalFormatter = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'meter',\n\t\t\t'proportional',\n\t\t\t'totalFormatter'\n\t\t);\n\n\t\tconst totalString =\n\t\t\ttotalFormatter !== null\n\t\t\t\t? totalFormatter(totalValue)\n\t\t\t\t: `${total} ${unit} total`;\n\n\t\tconst containerBounds = DOMUtils.getSVGElementSize(\n\t\t\tthis.services.domUtils.getMainContainer(),\n\t\t\t{ useAttrs: true }\n\t\t);\n\n\t\t// need to check if the width is 0, and try to use the parent attribute\n\t\t// this can happen if the chart is toggled on/off and the height is 0 for the parent, it wont validateDimensions\n\t\tconst containerWidth = containerBounds.width\n\t\t\t? containerBounds.width\n\t\t\t: this.parent.node().getAttribute('width');\n\n\t\tconst title = svg\n\t\t\t.selectAll('text.proportional-meter-total')\n\t\t\t.data([totalString]);\n\n\t\ttitle\n\t\t\t.enter()\n\t\t\t.append('text')\n\t\t\t.classed('proportional-meter-total', true)\n\t\t\t.merge(title)\n\t\t\t.attr('x', containerWidth)\n\t\t\t.attr('y', '1em')\n\t\t\t.attr('text-anchor', 'end')\n\t\t\t.text((d) => d);\n\n\t\ttitle.exit().remove();\n\t}\n\n\t/**\n\t * Appends the corresponding status based on the value and the peak.\n\t */\n\tdisplayStatus() {\n\t\tconst self = this;\n\t\tconst svg = this.getComponentContainer();\n\n\t\tconst containerBounds = DOMUtils.getHTMLElementSize(\n\t\t\tthis.services.domUtils.getMainContainer()\n\t\t);\n\n\t\t// need to check if the width is 0, and try to use the parent attribute\n\t\t// this can happen if the chart is toggled on/off and the height is 0 for the parent, it wont validateDimensions\n\t\tconst containerWidth = containerBounds.width\n\t\t\t? containerBounds.width\n\t\t\t: 0;\n\n\t\t// get the status from the model\n\t\tconst status = this.model.getStatus();\n\t\tconst radius = Configuration.meter.status.indicatorSize / 2;\n\n\t\t// create a group for the icon/inner path\n\t\tconst statusGroup = DOMUtils.appendOrSelect(svg, `g.status-indicator`)\n\t\t\t.attr(\n\t\t\t\t'class',\n\t\t\t\tstatus !== null ? `status-indicator status--${status}` : ''\n\t\t\t)\n\t\t\t.attr('transform', `translate(${containerWidth - radius}, 0)`);\n\n\t\tconst data = status ? [status] : [];\n\t\tconst icon = statusGroup.selectAll('circle.status').data(data);\n\n\t\ticon.enter()\n\t\t\t.append('circle')\n\t\t\t.merge(icon)\n\t\t\t.attr('class', 'status')\n\t\t\t.attr('r', radius)\n\t\t\t.attr('cx', 0)\n\t\t\t.attr('cy', `calc(1em / 2)`);\n\n\t\tconst innerIcon = statusGroup.selectAll('path.innerFill').data(data);\n\n\t\tinnerIcon\n\t\t\t.enter()\n\t\t\t.append('path')\n\t\t\t.merge(innerIcon)\n\t\t\t.attr('d', self.getStatusIconPathString(status))\n\t\t\t.attr('transform', `translate(-${radius}, 0)`)\n\t\t\t.attr('class', 'innerFill');\n\n\t\tinnerIcon.exit().remove();\n\t\ticon.exit().remove();\n\t}\n\n\t/**\n\t * Appends the associated percentage to the end of the title\n\t */\n\tappendPercentage() {\n\t\tconst dataValue = Tools.getProperty(\n\t\t\tthis.model.getDisplayData(),\n\t\t\t0,\n\t\t\t'value'\n\t\t);\n\n\t\t// use the title's position to append the percentage to the end\n\t\tconst svg = this.getComponentContainer();\n\t\tconst title = DOMUtils.appendOrSelect(svg, 'text.meter-title');\n\n\t\t// check if it is enabled\n\t\tconst data =\n\t\t\tTools.getProperty(\n\t\t\t\tthis.getOptions(),\n\t\t\t\t'meter',\n\t\t\t\t'statusBar',\n\t\t\t\t'percentageIndicator',\n\t\t\t\t'enabled'\n\t\t\t) === true\n\t\t\t\t? [dataValue]\n\t\t\t\t: [];\n\n\t\t// append a percentage if it is enabled, update it\n\t\tconst percentage = svg.selectAll('text.percent-value').data(data);\n\n\t\t// the horizontal offset of the percentage value from the title\n\t\tconst offset = Configuration.meter.statusBar.paddingRight;\n\n\t\tpercentage\n\t\t\t.enter()\n\t\t\t.append('text')\n\t\t\t.classed('percent-value', true)\n\t\t\t.merge(percentage)\n\t\t\t.text((d) => `${d}%`)\n\t\t\t.attr(\n\t\t\t\t'x',\n\t\t\t\t+title.attr('x') + title.node().getComputedTextLength() + offset\n\t\t\t) // set the position to after the title\n\t\t\t.attr('y', title.attr('y'));\n\n\t\tpercentage.exit().remove();\n\t}\n\n\t/**\n\t * Uses the parent class truncate logic\n\t * @param title d3 selection of title element that will be truncated\n\t * @param titlestring the original string that needs truncation\n\t * @param maxWidth the max width the title can take\n\t */\n\ttruncateTitle(title, maxWidth) {\n\t\tsuper.truncateTitle(title, maxWidth);\n\n\t\t// update the position on the percentage to be inline with the title\n\t\tconst tspan = DOMUtils.appendOrSelect(this.parent, 'tspan');\n\t\tconst offset = Configuration.meter.statusBar.paddingRight;\n\t\tconst tspanLength = Math.ceil(tspan.node().getComputedTextLength());\n\n\t\tconst percentage = DOMUtils.appendOrSelect(\n\t\t\tthis.parent,\n\t\t\t'text.percent-value'\n\t\t);\n\t\tpercentage.attr(\n\t\t\t'x',\n\t\t\t+title.attr('x') +\n\t\t\t\ttitle.node().getComputedTextLength() +\n\t\t\t\ttspanLength +\n\t\t\t\toffset\n\t\t);\n\t}\n\n\t// computes the maximum space a title can take\n\tprotected getMaxTitleWidth() {\n\t\t// get a reference to the title elements to calculate the size the title can be\n\t\tconst containerBounds = DOMUtils.getHTMLElementSize(\n\t\t\tthis.services.domUtils.getMainContainer()\n\t\t);\n\n\t\tconst proportional = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'meter',\n\t\t\t'proportional'\n\t\t);\n\n\t\t// need to check if the width is 0, and try to use the parent attribute\n\t\tconst containerWidth = containerBounds.width\n\t\t\t? containerBounds.width\n\t\t\t: this.parent.node().getAttribute('width');\n\n\t\tif (proportional !== null) {\n\t\t\tconst total = DOMUtils.appendOrSelect(\n\t\t\t\tthis.parent,\n\t\t\t\t'text.proportional-meter-total'\n\t\t\t).node();\n\n\t\t\tconst totalWidth = DOMUtils.getSVGElementSize(total, {\n\t\t\t\tuseBBox: true,\n\t\t\t}).width;\n\n\t\t\treturn (\n\t\t\t\tcontainerWidth -\n\t\t\t\ttotalWidth -\n\t\t\t\tConfiguration.meter.total.paddingLeft\n\t\t\t);\n\t\t} else {\n\t\t\tconst percentage = DOMUtils.appendOrSelect(\n\t\t\t\tthis.parent,\n\t\t\t\t'text.percent-value'\n\t\t\t);\n\t\t\t// the title needs to fit the width of the container without crowding the status, and percentage value\n\t\t\tconst offset = Configuration.meter.statusBar.paddingRight;\n\t\t\tconst percentageWidth = percentage.node().getComputedTextLength();\n\n\t\t\tconst statusGroup = DOMUtils.appendOrSelect(\n\t\t\t\tthis.parent,\n\t\t\t\t'g.status-indicator'\n\t\t\t).node();\n\t\t\tconst statusWidth =\n\t\t\t\tDOMUtils.getSVGElementSize(statusGroup, { useBBox: true })\n\t\t\t\t\t.width + Configuration.meter.status.paddingLeft;\n\n\t\t\treturn containerWidth - percentageWidth - offset - statusWidth;\n\t\t}\n\t}\n\n\t/**\n\t * Get the associated status icon for the data\n\t * @param status the active status for the meter chart\n\t */\n\tprotected getStatusIconPathString(status) {\n\t\tswitch (status) {\n\t\t\tcase Statuses.SUCCESS:\n\t\t\t\treturn 'M6.875 11.3125 3.75 8.1875 4.74375 7.25 6.875 9.34375 11.50625 4.75 12.5 5.7375 Z';\n\t\t\tcase Statuses.DANGER:\n\t\t\t\treturn 'M10.7 11.5 4.5 5.3 5.3 4.5 11.5 10.7 Z';\n\t\t\tcase Statuses.WARNING:\n\t\t\t\treturn 'M7.9375,11.125 C7.41973305,11.125 7,11.544733 7,12.0625 C7,12.580267 7.41973305,13 7.9375,13 C8.45526695,13 8.875,12.580267 8.875,12.0625 C8.875,11.544733 8.45526695,11.125 7.9375,11.125 M7.3125, 3 8.5625, 3 8.5625, 9.875 7.3125, 9.875, 7.3125, 3 Z';\n\t\t}\n\t}\n}\n"]}
|
|
1
|
+
{"version":3,"file":"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CAAC;IACF,iBAAC;AAAD,CAAC,AAnYD,CAAgC,KAAK,GAmYpC","sourcesContent":["// Internal Imports\nimport { Title } from './title';\nimport { DOMUtils } from '../../services';\nimport { Tools } from '../../tools';\nimport { RenderTypes, Statuses } from './../../interfaces/enums';\nimport * as Configuration from '../../configuration';\n\nexport class MeterTitle extends Title {\n\ttype = 'meter-title';\n\trenderType = RenderTypes.SVG;\n\n\trender() {\n\t\tconst dataset = Tools.getProperty(this.model.getDisplayData(), 0);\n\t\tconst options = this.getOptions();\n\t\tconst svg = this.getComponentContainer();\n\t\tconst { groupMapsTo } = options.data;\n\n\t\tconst proportional = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'meter',\n\t\t\t'proportional'\n\t\t);\n\n\t\tif (proportional) {\n\t\t\tthis.displayTotal();\n\t\t\tthis.displayBreakdownTitle();\n\t\t} else {\n\t\t\t// the title for a meter, is the label for that dataset\n\t\t\tconst title = svg\n\t\t\t\t.selectAll('text.meter-title')\n\t\t\t\t.data([dataset[groupMapsTo]]);\n\n\t\t\ttitle\n\t\t\t\t.enter()\n\t\t\t\t.append('text')\n\t\t\t\t.classed('meter-title', true)\n\t\t\t\t.merge(title)\n\t\t\t\t.attr('x', 0)\n\t\t\t\t.attr('y', '1em')\n\t\t\t\t.text((d) => d);\n\n\t\t\ttitle.exit().remove();\n\n\t\t\t// appends the associated percentage after title\n\t\t\tthis.appendPercentage();\n\t\t}\n\n\t\t// if status ranges are provided (custom or default), display indicator\n\t\tthis.displayStatus();\n\n\t\t// get the max width of a title (with consideration for the status/percentage)\n\t\tconst maxWidth = this.getMaxTitleWidth();\n\t\tconst titleElement = DOMUtils.appendOrSelect(svg, 'text.meter-title');\n\n\t\tif (\n\t\t\tmaxWidth > 0 &&\n\t\t\ttitleElement.node().getComputedTextLength() > maxWidth\n\t\t) {\n\t\t\tthis.truncateTitle(titleElement, maxWidth);\n\t\t}\n\t}\n\n\tdisplayBreakdownTitle() {\n\t\tconst self = this;\n\t\tconst svg = this.getComponentContainer();\n\t\tconst options = this.getOptions();\n\t\tconst datasetsTotal = this.model.getMaximumDomain(\n\t\t\tthis.model.getDisplayData()\n\t\t);\n\t\tconst total = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'meter',\n\t\t\t'proportional',\n\t\t\t'total'\n\t\t);\n\t\tconst unit = Tools.getProperty(options, 'meter', 'proportional', 'unit')\n\t\t\t? Tools.getProperty(options, 'meter', 'proportional', 'unit')\n\t\t\t: '';\n\n\t\tlet data;\n\t\tif (datasetsTotal === total) {\n\t\t\tdata = null;\n\t\t} else {\n\t\t\tconst difference =\n\t\t\t\ttotal !== null ? total - datasetsTotal : datasetsTotal;\n\t\t\t//breakdownFormatter\n\t\t\tconst breakdownFormatter = Tools.getProperty(\n\t\t\t\toptions,\n\t\t\t\t'meter',\n\t\t\t\t'proportional',\n\t\t\t\t'breakdownFormatter'\n\t\t\t);\n\t\t\tdata =\n\t\t\t\tbreakdownFormatter !== null\n\t\t\t\t\t? breakdownFormatter({\n\t\t\t\t\t\t\tdatasetsTotal: datasetsTotal,\n\t\t\t\t\t\t\ttotal: total,\n\t\t\t\t\t })\n\t\t\t\t\t: `${datasetsTotal} ${unit} used (${difference} ${unit} available)`;\n\t\t}\n\n\t\t// the breakdown part to whole of the datasets to the overall total\n\t\tconst title = svg\n\t\t\t.selectAll('text.proportional-meter-title')\n\t\t\t.data([data]);\n\n\t\ttitle\n\t\t\t.enter()\n\t\t\t.append('text')\n\t\t\t.classed('proportional-meter-title', true)\n\t\t\t.merge(title)\n\t\t\t.attr('x', 0)\n\t\t\t.attr('y', '1em')\n\t\t\t.text((d) => d);\n\n\t\ttitle.exit().remove();\n\n\t\tconst maxWidth = this.getMaxTitleWidth();\n\t\tconst titleElement = DOMUtils.appendOrSelect(\n\t\t\tsvg,\n\t\t\t'text.proportional-meter-title'\n\t\t);\n\n\t\tif (\n\t\t\tmaxWidth > 0 &&\n\t\t\ttitleElement.node().getComputedTextLength() > maxWidth\n\t\t) {\n\t\t\tthis.truncateTitle(titleElement, maxWidth);\n\t\t}\n\t}\n\n\t// show the total for prop meter\n\tdisplayTotal() {\n\t\tconst self = this;\n\t\tconst svg = this.getComponentContainer();\n\t\tconst options = this.getOptions();\n\n\t\tconst total = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'meter',\n\t\t\t'proportional',\n\t\t\t'total'\n\t\t);\n\n\t\tconst totalValue = total\n\t\t\t? Tools.getProperty(options, 'meter', 'proportional', 'total')\n\t\t\t: this.model.getMaximumDomain(this.model.getDisplayData());\n\n\t\tconst unit = Tools.getProperty(options, 'meter', 'proportional', 'unit')\n\t\t\t? Tools.getProperty(options, 'meter', 'proportional', 'unit')\n\t\t\t: '';\n\n\t\t// totalFormatter function\n\t\tconst totalFormatter = Tools.getProperty(\n\t\t\toptions,\n\t\t\t'meter',\n\t\t\t'proportional',\n\t\t\t'totalFormatter'\n\t\t);\n\n\t\tconst totalString =\n\t\t\ttotalFormatter !== null\n\t\t\t\t? totalFormatter(totalValue)\n\t\t\t\t: `${total} ${unit} total`;\n\n\t\tconst containerBounds = DOMUtils.getHTMLElementSize(\n\t\t\tthis.services.domUtils.getMainContainer()\n\t\t);\n\n\t\t// need to check if the width is 0, and try to use the parent attribute\n\t\t// this can happen if the chart is toggled on/off and the height is 0 for the parent, it wont validateDimensions\n\t\tconst containerWidth = containerBounds.width\n\t\t\t? containerBounds.width\n\t\t\t: this.parent.node().getAttribute('width');\n\n\t\tconst title = svg\n\t\t\t.selectAll('text.proportional-meter-total')\n\t\t\t.data([totalString]);\n\n\t\ttitle\n\t\t\t.enter()\n\t\t\t.append('text')\n\t\t\t.classed('proportional-meter-total', true)\n\t\t\t.merge(title)\n\t\t\t// Position the total text -24 pixels to add spacing between text and status icon (if status exists)\n\t\t\t.attr(\n\t\t\t\t'x',\n\t\t\t\tthis.model.getStatus()\n\t\t\t\t\t? containerWidth - Configuration.meter.total.paddingRight\n\t\t\t\t\t: containerWidth\n\t\t\t)\n\t\t\t.attr('y', '1em')\n\t\t\t.attr('text-anchor', 'end')\n\t\t\t.text((d) => d);\n\n\t\ttitle.exit().remove();\n\t}\n\n\t/**\n\t * Appends the corresponding status based on the value and the peak.\n\t */\n\tdisplayStatus() {\n\t\tconst self = this;\n\t\tconst svg = this.getComponentContainer();\n\n\t\tconst containerBounds = DOMUtils.getHTMLElementSize(\n\t\t\tthis.services.domUtils.getMainContainer()\n\t\t);\n\n\t\t// need to check if the width is 0, and try to use the parent attribute\n\t\t// this can happen if the chart is toggled on/off and the height is 0 for the parent, it wont validateDimensions\n\t\tconst containerWidth = containerBounds.width\n\t\t\t? containerBounds.width\n\t\t\t: 0;\n\n\t\t// get the status from the model\n\t\tconst status = this.model.getStatus();\n\t\tconst radius = Configuration.meter.status.indicatorSize / 2;\n\n\t\t// create a group for the icon/inner path\n\t\tconst statusGroup = DOMUtils.appendOrSelect(svg, `g.status-indicator`)\n\t\t\t.attr(\n\t\t\t\t'class',\n\t\t\t\tstatus !== null ? `status-indicator status--${status}` : ''\n\t\t\t)\n\t\t\t.attr('transform', `translate(${containerWidth - radius}, 0)`);\n\n\t\tconst data = status ? [status] : [];\n\t\tconst icon = statusGroup.selectAll('circle.status').data(data);\n\n\t\ticon.enter()\n\t\t\t.append('circle')\n\t\t\t.merge(icon)\n\t\t\t.attr('class', 'status')\n\t\t\t.attr('r', radius)\n\t\t\t.attr('cx', 0)\n\t\t\t.attr('cy', `calc(1em / 2)`);\n\n\t\tconst innerIcon = statusGroup.selectAll('path.innerFill').data(data);\n\n\t\tinnerIcon\n\t\t\t.enter()\n\t\t\t.append('path')\n\t\t\t.merge(innerIcon)\n\t\t\t.attr('d', self.getStatusIconPathString(status))\n\t\t\t.attr('transform', `translate(-${radius}, 0)`)\n\t\t\t.attr('class', 'innerFill');\n\n\t\tinnerIcon.exit().remove();\n\t\ticon.exit().remove();\n\t}\n\n\t/**\n\t * Appends the associated percentage to the end of the title\n\t */\n\tappendPercentage() {\n\t\tconst dataValue = Tools.getProperty(\n\t\t\tthis.model.getDisplayData(),\n\t\t\t0,\n\t\t\t'value'\n\t\t);\n\n\t\t// use the title's position to append the percentage to the end\n\t\tconst svg = this.getComponentContainer();\n\t\tconst title = DOMUtils.appendOrSelect(svg, 'text.meter-title');\n\n\t\t// check if it is enabled\n\t\tconst data =\n\t\t\tTools.getProperty(\n\t\t\t\tthis.getOptions(),\n\t\t\t\t'meter',\n\t\t\t\t'statusBar',\n\t\t\t\t'percentageIndicator',\n\t\t\t\t'enabled'\n\t\t\t) === true\n\t\t\t\t? [dataValue]\n\t\t\t\t: [];\n\n\t\t// append a percentage if it is enabled, update it\n\t\tconst percentage = svg.selectAll('text.percent-value').data(data);\n\n\t\t// the horizontal offset of the percentage value from the title\n\t\tconst offset = Configuration.meter.statusBar.paddingRight;\n\n\t\tpercentage\n\t\t\t.enter()\n\t\t\t.append('text')\n\t\t\t.classed('percent-value', true)\n\t\t\t.merge(percentage)\n\t\t\t.text((d) => `${d}%`)\n\t\t\t.attr(\n\t\t\t\t'x',\n\t\t\t\t+title.attr('x') + title.node().getComputedTextLength() + offset\n\t\t\t) // set the position to after the title\n\t\t\t.attr('y', title.attr('y'));\n\n\t\tpercentage.exit().remove();\n\t}\n\n\t/**\n\t * Uses the parent class truncate logic\n\t * @param title d3 selection of title element that will be truncated\n\t * @param titlestring the original string that needs truncation\n\t * @param maxWidth the max width the title can take\n\t */\n\ttruncateTitle(title, maxWidth) {\n\t\tsuper.truncateTitle(title, maxWidth);\n\n\t\t// update the position on the percentage to be inline with the title\n\t\tconst tspan = DOMUtils.appendOrSelect(this.parent, 'tspan');\n\t\tconst offset = Configuration.meter.statusBar.paddingRight;\n\t\tconst tspanLength = Math.ceil(tspan.node().getComputedTextLength());\n\n\t\tconst percentage = DOMUtils.appendOrSelect(\n\t\t\tthis.parent,\n\t\t\t'text.percent-value'\n\t\t);\n\t\tpercentage.attr(\n\t\t\t'x',\n\t\t\t+title.attr('x') +\n\t\t\t\ttitle.node().getComputedTextLength() +\n\t\t\t\ttspanLength +\n\t\t\t\toffset\n\t\t);\n\t}\n\n\t// computes the maximum space a title can take\n\tprotected getMaxTitleWidth() {\n\t\t// get a reference to the title elements to calculate the size the title can be\n\t\tconst containerBounds = DOMUtils.getHTMLElementSize(\n\t\t\tthis.services.domUtils.getMainContainer()\n\t\t);\n\n\t\tconst proportional = Tools.getProperty(\n\t\t\tthis.getOptions(),\n\t\t\t'meter',\n\t\t\t'proportional'\n\t\t);\n\n\t\t// need to check if the width is 0, and try to use the parent attribute\n\t\tconst containerWidth = containerBounds.width\n\t\t\t? containerBounds.width\n\t\t\t: this.parent.node().getAttribute('width');\n\n\t\tif (proportional !== null) {\n\t\t\tconst total = DOMUtils.appendOrSelect(\n\t\t\t\tthis.parent,\n\t\t\t\t'text.proportional-meter-total'\n\t\t\t).node();\n\n\t\t\tconst totalWidth = DOMUtils.getSVGElementSize(total, {\n\t\t\t\tuseBBox: true,\n\t\t\t}).width;\n\n\t\t\treturn (\n\t\t\t\tcontainerWidth -\n\t\t\t\ttotalWidth -\n\t\t\t\tConfiguration.meter.total.paddingLeft\n\t\t\t);\n\t\t} else {\n\t\t\tconst percentage = DOMUtils.appendOrSelect(\n\t\t\t\tthis.parent,\n\t\t\t\t'text.percent-value'\n\t\t\t);\n\t\t\t// the title needs to fit the width of the container without crowding the status, and percentage value\n\t\t\tconst offset = Configuration.meter.statusBar.paddingRight;\n\t\t\tconst percentageWidth = percentage.node().getComputedTextLength();\n\n\t\t\tconst statusGroup = DOMUtils.appendOrSelect(\n\t\t\t\tthis.parent,\n\t\t\t\t'g.status-indicator'\n\t\t\t).node();\n\t\t\tconst statusWidth =\n\t\t\t\tDOMUtils.getSVGElementSize(statusGroup, { useBBox: true })\n\t\t\t\t\t.width + Configuration.meter.status.paddingLeft;\n\n\t\t\treturn containerWidth - percentageWidth - offset - statusWidth;\n\t\t}\n\t}\n\n\t/**\n\t * Get the associated status icon for the data\n\t * @param status the active status for the meter chart\n\t */\n\tprotected getStatusIconPathString(status) {\n\t\tswitch (status) {\n\t\t\tcase Statuses.SUCCESS:\n\t\t\t\treturn 'M6.875 11.3125 3.75 8.1875 4.74375 7.25 6.875 9.34375 11.50625 4.75 12.5 5.7375 Z';\n\t\t\tcase Statuses.DANGER:\n\t\t\t\treturn 'M10.7 11.5 4.5 5.3 5.3 4.5 11.5 10.7 Z';\n\t\t\tcase Statuses.WARNING:\n\t\t\t\treturn 'M7.9375,11.125 C7.41973305,11.125 7,11.544733 7,12.0625 C7,12.580267 7.41973305,13 7.9375,13 C8.45526695,13 8.875,12.580267 8.875,12.0625 C8.875,11.544733 8.45526695,11.125 7.9375,11.125 M7.3125, 3 8.5625, 3 8.5625, 9.875 7.3125, 9.875, 7.3125, 3 Z';\n\t\t}\n\t}\n}\n"]}
|
|
@@ -26,6 +26,7 @@ var Alluvial = /** @class */ (function (_super) {
|
|
|
26
26
|
var _this = _super !== null && _super.apply(this, arguments) || this;
|
|
27
27
|
_this.type = 'alluvial';
|
|
28
28
|
_this.renderType = RenderTypes.SVG;
|
|
29
|
+
_this.gradient_id = 'gradient-id-' + Math.floor(Math.random() * 99999999999);
|
|
29
30
|
return _this;
|
|
30
31
|
}
|
|
31
32
|
Alluvial.prototype.render = function (animate) {
|
|
@@ -45,6 +46,8 @@ var Alluvial = /** @class */ (function (_super) {
|
|
|
45
46
|
}
|
|
46
47
|
var options = this.model.getOptions();
|
|
47
48
|
var data = this.model.getDisplayData();
|
|
49
|
+
// Is gradient enabled or not
|
|
50
|
+
var isGradientAllowed = Tools.getProperty(this.getOptions(), 'color', 'gradient', 'enabled');
|
|
48
51
|
// Set the custom node padding if provided
|
|
49
52
|
var nodePadding = Configuration.alluvial.minNodePadding;
|
|
50
53
|
if (options.alluvial.nodePadding > Configuration.alluvial.minNodePadding) {
|
|
@@ -115,11 +118,45 @@ var Alluvial = /** @class */ (function (_super) {
|
|
|
115
118
|
return x;
|
|
116
119
|
});
|
|
117
120
|
// Draws the links (Waves)
|
|
118
|
-
svg
|
|
121
|
+
var links = svg
|
|
122
|
+
.append('g')
|
|
119
123
|
.attr('fill', 'none')
|
|
120
124
|
.selectAll('g')
|
|
121
|
-
.data(this.graph.links)
|
|
122
|
-
|
|
125
|
+
.data(this.graph.links);
|
|
126
|
+
// Exit so we can have multiple appends in group
|
|
127
|
+
links.exit().remove();
|
|
128
|
+
// Add gradient if requsted
|
|
129
|
+
if (isGradientAllowed) {
|
|
130
|
+
var scale_1 = Tools.getProperty(this.getOptions(), 'color', 'scale');
|
|
131
|
+
if (scale_1) {
|
|
132
|
+
links
|
|
133
|
+
.enter()
|
|
134
|
+
.append('linearGradient')
|
|
135
|
+
.attr('id', function (d) { return _this.gradient_id + "-link-" + d.index; })
|
|
136
|
+
.attr('gradientUnits', 'userSpaceOnUse')
|
|
137
|
+
.call(function (gradient) {
|
|
138
|
+
return gradient
|
|
139
|
+
.append('stop')
|
|
140
|
+
.attr('offset', '0%')
|
|
141
|
+
.attr('stop-color', function (d) {
|
|
142
|
+
return scale_1[d.source.name];
|
|
143
|
+
});
|
|
144
|
+
})
|
|
145
|
+
.call(function (gradient) {
|
|
146
|
+
return gradient
|
|
147
|
+
.append('stop')
|
|
148
|
+
.attr('offset', '100%')
|
|
149
|
+
.attr('stop-color', function (d) {
|
|
150
|
+
return scale_1[d.target.name];
|
|
151
|
+
});
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
// Exit so path can be appended to the group
|
|
155
|
+
links.exit().remove();
|
|
156
|
+
}
|
|
157
|
+
links
|
|
158
|
+
.enter()
|
|
159
|
+
.append('path')
|
|
123
160
|
.classed('link', true)
|
|
124
161
|
.attr('d', sankeyLinkHorizontal())
|
|
125
162
|
.attr('id', function (d) {
|
|
@@ -140,7 +177,12 @@ var Alluvial = /** @class */ (function (_super) {
|
|
|
140
177
|
originalClassName: 'link',
|
|
141
178
|
});
|
|
142
179
|
})
|
|
143
|
-
.style('stroke', function (d) {
|
|
180
|
+
.style('stroke', function (d) {
|
|
181
|
+
if (isGradientAllowed) {
|
|
182
|
+
return "url(#" + _this.gradient_id + "-link-" + d.index + ")";
|
|
183
|
+
}
|
|
184
|
+
return _this.model.getFillColor(d.source.name);
|
|
185
|
+
})
|
|
144
186
|
.attr('stroke-width', function (d) { return Math.max(1, d.width); })
|
|
145
187
|
.style('stroke-opacity', Configuration.alluvial.opacity.default)
|
|
146
188
|
.attr('aria-label', function (d) {
|