From ac4862f28df2c91718ac7eb93228e8434292c8f2 Mon Sep 17 00:00:00 2001 From: Scott Dickerson Date: Thu, 12 Dec 2019 13:05:39 -0600 Subject: [PATCH] fix(enabled): rename visible to enabled --- packages/core/src/axis-chart.ts | 30 ++++++++++++---------- packages/core/src/chart.ts | 29 +++++++++++---------- packages/core/src/configuration.ts | 1 + packages/core/src/interfaces/components.ts | 4 +++ 4 files changed, 38 insertions(+), 26 deletions(-) diff --git a/packages/core/src/axis-chart.ts b/packages/core/src/axis-chart.ts index 0192549696..adc296c7b0 100644 --- a/packages/core/src/axis-chart.ts +++ b/packages/core/src/axis-chart.ts @@ -60,23 +60,27 @@ export class AxisChart extends Chart { } }; + const isEnabled = this.model.getOptions().legend.enabled !== false; + // Decide the position of the legend in reference to the chart let fullFrameComponentDirection = LayoutDirection.COLUMN; - const legendPosition = Tools.getProperty(this.model.getOptions(), "legend", "position"); - if (legendPosition === LegendPositions.LEFT) { - fullFrameComponentDirection = LayoutDirection.ROW; + if (isEnabled) { + const legendPosition = Tools.getProperty(this.model.getOptions(), "legend", "position"); + if (legendPosition === LegendPositions.LEFT) { + fullFrameComponentDirection = LayoutDirection.ROW; - if (!this.model.getOptions().legend.orientation) { - this.model.getOptions().legend.orientation = LegendOrientations.VERTICAL; - } - } else if (legendPosition === LegendPositions.RIGHT) { - fullFrameComponentDirection = LayoutDirection.ROW_REVERSE; + if (!this.model.getOptions().legend.orientation) { + this.model.getOptions().legend.orientation = LegendOrientations.VERTICAL; + } + } else if (legendPosition === LegendPositions.RIGHT) { + fullFrameComponentDirection = LayoutDirection.ROW_REVERSE; - if (!this.model.getOptions().legend.orientation) { - this.model.getOptions().legend.orientation = LegendOrientations.VERTICAL; + if (!this.model.getOptions().legend.orientation) { + this.model.getOptions().legend.orientation = LegendOrientations.VERTICAL; + } + } else if (legendPosition === LegendPositions.BOTTOM) { + fullFrameComponentDirection = LayoutDirection.COLUMN_REVERSE; } - } else if (legendPosition === LegendPositions.BOTTOM) { - fullFrameComponentDirection = LayoutDirection.COLUMN_REVERSE; } const fullFrameComponent = { @@ -86,7 +90,7 @@ export class AxisChart extends Chart { this.model, this.services, [ - ...((this.model.getOptions().legend.visible !== false) ? [ legendComponent ] : [ ]), + ...(isEnabled ? [ legendComponent ] : [ ]), graphFrameComponent ], { diff --git a/packages/core/src/chart.ts b/packages/core/src/chart.ts index 939f12dd67..2ef2209093 100644 --- a/packages/core/src/chart.ts +++ b/packages/core/src/chart.ts @@ -144,24 +144,27 @@ export class Chart { } }; + const isEnabled = this.model.getOptions().legend.enabled !== false; // TODORF - REUSE BETWEEN AXISCHART & CHART // Decide the position of the legend in reference to the chart let fullFrameComponentDirection = LayoutDirection.COLUMN; - const legendPosition = Tools.getProperty(this.model.getOptions(), "legend", "position"); - if (legendPosition === "left") { - fullFrameComponentDirection = LayoutDirection.ROW; + if (isEnabled) { + const legendPosition = Tools.getProperty(this.model.getOptions(), "legend", "position"); + if (legendPosition === "left") { + fullFrameComponentDirection = LayoutDirection.ROW; - if (!this.model.getOptions().legend.orientation) { - this.model.getOptions().legend.orientation = LegendOrientations.VERTICAL; - } - } else if (legendPosition === "right") { - fullFrameComponentDirection = LayoutDirection.ROW_REVERSE; + if (!this.model.getOptions().legend.orientation) { + this.model.getOptions().legend.orientation = LegendOrientations.VERTICAL; + } + } else if (legendPosition === "right") { + fullFrameComponentDirection = LayoutDirection.ROW_REVERSE; - if (!this.model.getOptions().legend.orientation) { - this.model.getOptions().legend.orientation = LegendOrientations.VERTICAL; + if (!this.model.getOptions().legend.orientation) { + this.model.getOptions().legend.orientation = LegendOrientations.VERTICAL; + } + } else if (legendPosition === "bottom") { + fullFrameComponentDirection = LayoutDirection.COLUMN_REVERSE; } - } else if (legendPosition === "bottom") { - fullFrameComponentDirection = LayoutDirection.COLUMN_REVERSE; } const fullFrameComponent = { @@ -171,7 +174,7 @@ export class Chart { this.model, this.services, [ - ...((this.model.getOptions().legend.visible !== false) ? [ legendComponent ] : [ ]), + ...(isEnabled ? [ legendComponent ] : [ ]), graphFrameComponent ], { diff --git a/packages/core/src/configuration.ts b/packages/core/src/configuration.ts index 63ab041620..6383084095 100644 --- a/packages/core/src/configuration.ts +++ b/packages/core/src/configuration.ts @@ -33,6 +33,7 @@ import { export const legend: LegendOptions = { position: LegendPositions.BOTTOM, clickable: true, + enabled: true, items: { status: { ACTIVE: 1, diff --git a/packages/core/src/interfaces/components.ts b/packages/core/src/interfaces/components.ts index 231e0da700..e7f2a21096 100644 --- a/packages/core/src/interfaces/components.ts +++ b/packages/core/src/interfaces/components.ts @@ -33,6 +33,10 @@ export interface LegendOptions { * the clickability of legend items */ clickable?: boolean; + /** + * is the legend visible or not + */ + enabled?: boolean; items?: { status?: { ACTIVE?: Number;