Skip to content

Commit f3eaf08

Browse files
committed
Do not render null points on rangeArea charts
ref apexcharts/apexcharts.js#3821
1 parent 727e544 commit f3eaf08

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

src/SuplaDeveloperBundle/DataFixtures/ORM/LogItemsFixture.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -282,8 +282,8 @@ private function createGeneralPurposeMeasurementLogItems() {
282282
EntityUtils::setField($logItem, 'open_value', $openValue);
283283
EntityUtils::setField($logItem, 'close_value', $temperature);
284284
EntityUtils::setField($logItem, 'avg_value', $avgValue);
285-
EntityUtils::setField($logItem, 'max_value', $maxValue);
286-
EntityUtils::setField($logItem, 'min_value', $minValue);
285+
EntityUtils::setField($logItem, 'max_value', max($maxValue, $minValue));
286+
EntityUtils::setField($logItem, 'min_value', min($maxValue, $minValue));
287287
if ($this->faker->boolean(95)) {
288288
$this->entityManager->persist($logItem);
289289
}

src/frontend/src/channels/history/channel-measurements-history-chart-strategies.js

+5-1
Original file line numberDiff line numberDiff line change
@@ -692,7 +692,11 @@ export const CHART_TYPES = {
692692
if (this.channel?.config?.chartType === 'LINEAR') {
693693
const rangeSeries = allLogs
694694
.filter((item) => item.min !== null)
695-
.map((item) => ({x: item.date_timestamp * 1000, y: [item.min_value, item.max_value]}));
695+
.map((item) => ({x: item.date_timestamp * 1000, y: [item.min_value, item.max_value]}))
696+
// TODO remove filter after fix https://github.com/apexcharts/apexcharts.js/issues/3821
697+
// it should correctly display ranges on null logs
698+
.filter(item => item.y[0] !== null);
699+
console.log(rangeSeries[5]?.y);
696700
series.push({
697701
name: `${this.$t('Value')} - ${this.$t('range')}`,
698702
type: 'rangeArea',

src/frontend/src/channels/params/channel-params-general-purpose-measurement.vue

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
<dd>{{ $t('Chart type') }}</dd>
2929
<dt>
3030
<ChannelParamsButtonSelector
31+
use-dropdown
3132
v-model="props.channel.config.chartType"
3233
@input="$emit('change')"
3334
:values="[{id: 'LINEAR', label: $t('Linear')}, {id: 'BAR', label: $t('Bar')}, {id: 'CANDLE', label: $t('Candle')}]"/>

src/frontend/tests/unit/channels/channel-measurements-history-chart-strategies.spec.js

+18
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,24 @@ describe('Channel measurement history data strategies', () => {
381381
});
382382
});
383383

384+
describe('GENERAL_PURPOSE_MEASUREMENT', function () {
385+
const strategy = CHART_TYPES.GENERAL_PURPOSE_MEASUREMENT;
386+
387+
it('aggregates simple logs', () => {
388+
const logs = [
389+
{date_timestamp: 1, avg_value: 5, min_value: 2, max_value: 8, open_value: 4, close_value: 6},
390+
{date_timestamp: 2, avg_value: 6, min_value: 1, max_value: 9, open_value: 6, close_value: 7},
391+
{date_timestamp: 3, avg_value: 7, min_value: 2, max_value: 8, open_value: 7, close_value: 5},
392+
];
393+
const aggregatedLog = strategy.aggregateLogs(logs);
394+
expect(aggregatedLog.avg_value).toEqual(6);
395+
expect(aggregatedLog.min_value).toEqual(1);
396+
expect(aggregatedLog.max_value).toEqual(9);
397+
expect(aggregatedLog.open_value).toEqual(4);
398+
expect(aggregatedLog.close_value).toEqual(5);
399+
});
400+
});
401+
384402
describe('GENERAL_PURPOSE_METER', function () {
385403
const strategy = CHART_TYPES.GENERAL_PURPOSE_METER;
386404

0 commit comments

Comments
 (0)