Skip to content

Commit

Permalink
Gauges didn't update on initial load when store does not yet contain …
Browse files Browse the repository at this point in the history
…values (NaN).

Signed-off-by: Boris Krivonog <[email protected]>
  • Loading branch information
crnjan committed Jan 21, 2021
1 parent f8241dc commit b3aee86
Showing 1 changed file with 10 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,28 @@ export default {
get (component, points, startTime, endTime, chart) {
let series = {}

if (!component.dataSeriesId) {
component.dataSeriesId = Framework7.utils.id() + '.'
}

if (component.config) {
if (typeof component.config !== 'object') return {}

const id = Framework7.utils.id() + '.'

for (const key in component.config) {
chart.$set(series, key, chart.evaluateExpression(id + key, component.config[key]))
chart.$set(series, key, chart.evaluateExpression(component.dataSeriesId + key, component.config[key]))
}

if (component.config.data && Array.isArray(component.config.data)) {
series.data = component.config.data.map((v, index) => chart.evaluateExpression(id + 'data.' + index, v))
series.data = component.config.data.map((v, index) => {
const item = chart.evaluateExpression(component.dataSeriesId + 'data.' + index, v)
return Number.isNaN(item.value) ? {} : item
})
}

if (component.config.axisLine && component.config.axisLine.lineStyle && component.config.axisLine.lineStyle.color && Array.isArray(component.config.axisLine.lineStyle.color)) {
series.axisLine.lineStyle.color = component.config.axisLine.lineStyle.color.map((v, index) => {
if (!Array.isArray(v)) return v
return v.map((s, subindex) => chart.evaluateExpression(id + 'axisLine.lineStyle.color.' + index + '.' + subindex, s))
return v.map((s, subindex) => chart.evaluateExpression(component.dataSeriesId + 'axisLine.lineStyle.color.' + index + '.' + subindex, s))
})
}
}
Expand Down

0 comments on commit b3aee86

Please sign in to comment.