Skip to content

Commit

Permalink
fix(enabled): rename visible to enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
scottdickerson committed Dec 12, 2019
1 parent 53216f5 commit ac4862f
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 26 deletions.
30 changes: 17 additions & 13 deletions packages/core/src/axis-chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -86,7 +90,7 @@ export class AxisChart extends Chart {
this.model,
this.services,
[
...((this.model.getOptions().legend.visible !== false) ? [ legendComponent ] : [ ]),
...(isEnabled ? [ legendComponent ] : [ ]),
graphFrameComponent
],
{
Expand Down
29 changes: 16 additions & 13 deletions packages/core/src/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -171,7 +174,7 @@ export class Chart {
this.model,
this.services,
[
...((this.model.getOptions().legend.visible !== false) ? [ legendComponent ] : [ ]),
...(isEnabled ? [ legendComponent ] : [ ]),
graphFrameComponent
],
{
Expand Down
1 change: 1 addition & 0 deletions packages/core/src/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
export const legend: LegendOptions = {
position: LegendPositions.BOTTOM,
clickable: true,
enabled: true,
items: {
status: {
ACTIVE: 1,
Expand Down
4 changes: 4 additions & 0 deletions packages/core/src/interfaces/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit ac4862f

Please sign in to comment.