@forter/chart
Advanced tools
Comparing version 5.31.4 to 5.31.5
@@ -6,2 +6,13 @@ # Change Log | ||
## [5.31.5](https://github.com/forter/web-components/compare/@forter/chart@5.31.4...@forter/chart@5.31.5) (2023-02-15) | ||
### Bug Fixes | ||
* **chart:** disable area color in PoP if positiveChange field isnt set ([#1215](https://github.com/forter/web-components/issues/1215)) ([e7466f0](https://github.com/forter/web-components/commit/e7466f0)) | ||
## [5.31.4](https://github.com/forter/web-components/compare/@forter/chart@5.31.3...@forter/chart@5.31.4) (2023-02-08) | ||
@@ -8,0 +19,0 @@ |
import { translateColor } from './dataset-color-config-builder.js'; | ||
import moment from 'moment'; | ||
import { isPeriodOverPeriodChart, NEGATIVE_COLOR, POSITIVE_COLOR } from './period-over-period.helpers.js'; | ||
import moment from 'moment'; | ||
/* eslint-disable max-len */ | ||
var periodOverPeriodBuilder = ((config, chartJSConfig, context) => { | ||
@@ -109,3 +108,4 @@ if (isPeriodOverPeriodChart(config)) { | ||
series.map((series, index) => { | ||
let dataset; | ||
var _baseDataset$periodOv; | ||
const { | ||
@@ -115,7 +115,8 @@ period, | ||
} = series.periodOverPeriod; | ||
const baseDataset = datasets[index]; | ||
const hasPositiveChangeField = ((_baseDataset$periodOv = baseDataset.periodOverPeriod) === null || _baseDataset$periodOv === void 0 ? void 0 : _baseDataset$periodOv.positiveChangeIsGood) !== null; | ||
let dataset; | ||
if (period === POP_SCALES.PREVIOUS) { | ||
var _dataset, _dataset$periodOverPe; | ||
dataset = { ...datasets[index], | ||
dataset = { ...baseDataset, | ||
label: label || tickConfig.PREVIOUS, | ||
@@ -132,9 +133,10 @@ data: [], | ||
}; | ||
const color = ((_dataset = dataset) === null || _dataset === void 0 ? void 0 : (_dataset$periodOverPe = _dataset.periodOverPeriod) === null || _dataset$periodOverPe === void 0 ? void 0 : _dataset$periodOverPe.positiveChangeIsGood) === true ? NEGATIVE_COLOR : POSITIVE_COLOR; | ||
const translatedColor = translateColor(color, context); | ||
dataset.fill.above = `${translatedColor}40`; | ||
if (hasPositiveChangeField) { | ||
const color = dataset.periodOverPeriod.positiveChangeIsGood ? NEGATIVE_COLOR : POSITIVE_COLOR; | ||
const translatedColor = translateColor(color, context); | ||
dataset.fill.above = `${translatedColor}40`; | ||
} | ||
} else if (period === POP_SCALES.CURRENT) { | ||
var _dataset2, _dataset2$periodOverP; | ||
dataset = { ...datasets[index], | ||
dataset = { ...baseDataset, | ||
label: label || tickConfig.CURRENT, | ||
@@ -149,5 +151,10 @@ data: [], | ||
}; | ||
const color = ((_dataset2 = dataset) === null || _dataset2 === void 0 ? void 0 : (_dataset2$periodOverP = _dataset2.periodOverPeriod) === null || _dataset2$periodOverP === void 0 ? void 0 : _dataset2$periodOverP.positiveChangeIsGood) === true ? POSITIVE_COLOR : NEGATIVE_COLOR; | ||
const translatedColor = translateColor(color, context); | ||
dataset.fill.above = `${translatedColor}40`; | ||
if (hasPositiveChangeField) { | ||
var _dataset$periodOverPe; | ||
const color = ((_dataset$periodOverPe = dataset.periodOverPeriod) === null || _dataset$periodOverPe === void 0 ? void 0 : _dataset$periodOverPe.positiveChangeIsGood) ? POSITIVE_COLOR : NEGATIVE_COLOR; | ||
const translatedColor = translateColor(color, context); | ||
dataset.fill.above = `${translatedColor}40`; | ||
} | ||
} | ||
@@ -154,0 +161,0 @@ |
{ | ||
"name": "@forter/chart", | ||
"version": "5.31.4", | ||
"version": "5.31.5", | ||
"description": "chart from Forter Components", | ||
@@ -61,3 +61,3 @@ "author": "Forter Developers", | ||
}, | ||
"gitHead": "816d3952865606a12a160e1673ecbc1f37fb24f0" | ||
"gitHead": "b9662dac495316f3eb3d7d1ea24a99f63ed3aa50" | ||
} |
@@ -1,8 +0,7 @@ | ||
/* eslint-disable max-len */ | ||
import moment from 'moment'; | ||
import { | ||
isPeriodOverPeriodChart, NEGATIVE_COLOR, POSITIVE_COLOR } | ||
from './period-over-period.helpers'; | ||
import moment from 'moment'; | ||
isPeriodOverPeriodChart, | ||
NEGATIVE_COLOR, | ||
POSITIVE_COLOR, | ||
} from './period-over-period.helpers'; | ||
import { translateColor } from './dataset-color-config-builder'; | ||
@@ -111,7 +110,10 @@ | ||
series.map((series, index) => { | ||
const { period, label } = series.periodOverPeriod; | ||
const baseDataset = datasets[index]; | ||
const hasPositiveChangeField = baseDataset.periodOverPeriod?.positiveChangeIsGood !== null; | ||
let dataset; | ||
const { period, label } = series.periodOverPeriod; | ||
if (period === POP_SCALES.PREVIOUS) { | ||
dataset = { | ||
...datasets[index], | ||
...baseDataset, | ||
label: label || tickConfig.PREVIOUS, | ||
@@ -129,8 +131,11 @@ data: [], | ||
const color = dataset?.periodOverPeriod?.positiveChangeIsGood === true ? NEGATIVE_COLOR : POSITIVE_COLOR; | ||
const translatedColor = translateColor(color, context); | ||
dataset.fill.above = `${translatedColor}40`; | ||
if (hasPositiveChangeField) { | ||
const color = dataset.periodOverPeriod.positiveChangeIsGood | ||
? NEGATIVE_COLOR : POSITIVE_COLOR; | ||
const translatedColor = translateColor(color, context); | ||
dataset.fill.above = `${translatedColor}40`; | ||
} | ||
} else if (period === POP_SCALES.CURRENT) { | ||
dataset = { | ||
...datasets[index], | ||
...baseDataset, | ||
label: label || tickConfig.CURRENT, | ||
@@ -146,5 +151,8 @@ data: [], | ||
const color = dataset?.periodOverPeriod?.positiveChangeIsGood === true ? POSITIVE_COLOR : NEGATIVE_COLOR; | ||
const translatedColor = translateColor(color, context); | ||
dataset.fill.above = `${translatedColor}40`; | ||
if (hasPositiveChangeField) { | ||
const color = dataset.periodOverPeriod?.positiveChangeIsGood | ||
? POSITIVE_COLOR : NEGATIVE_COLOR; | ||
const translatedColor = translateColor(color, context); | ||
dataset.fill.above = `${translatedColor}40`; | ||
} | ||
} | ||
@@ -151,0 +159,0 @@ |
Sorry, the diff of this file is not supported yet
336516
5403