Skip to content

Commit

Permalink
fix: Float were not displayed in non-timeline charts
Browse files Browse the repository at this point in the history
  • Loading branch information
RomRider committed Feb 3, 2021
1 parent de13a8b commit e67d2d7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
13 changes: 5 additions & 8 deletions src/apexcharts-card.ts
Original file line number Diff line number Diff line change
Expand Up @@ -494,10 +494,13 @@ class ChartsCard extends LitElement {
graphData = {
series: this._graphs.flatMap((graph, index) => {
if (!graph) return [];
let data = 0;
if (graph.history.length === 0) {
this._lastState[index] = null;
data = 0;
} else {
const lastState = graph.history[graph.history.length - 1][1];
data = lastState === null ? 0 : lastState;
this._lastState[index] = this._computeLastState(lastState, index);
}
if (!this._config?.series[index].show.in_chart) {
Expand All @@ -508,15 +511,9 @@ class ChartsCard extends LitElement {
} else {
if (this._config?.chart_type === 'radialBar') {
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
return [
getPercentFromValue(
this._lastState[index] as number,
this._config.series[index].min,
this._config.series[index].max,
),
];
return [getPercentFromValue(data, this._config.series[index].min, this._config.series[index].max)];
} else {
return [this._lastState[index]];
return [data];
}
}
}),
Expand Down
2 changes: 1 addition & 1 deletion src/graphEntry.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HomeAssistant } from 'custom-card-helpers';
import { ChartCardSeriesConfig, EntityCachePoints, EntityEntryCache, HassHistory, HistoryBuckets } from './types';
import { compress, decompress, log } from './utils';
import localForage, { config } from 'localforage';
import localForage from 'localforage';
import { HassEntity } from 'home-assistant-js-websocket';
import { DateRange } from 'moment-range';
import { HOUR_24, moment } from './const';
Expand Down

0 comments on commit e67d2d7

Please sign in to comment.