Skip to content

Commit

Permalink
Fix error when rendering time-series charts too soon
Browse files Browse the repository at this point in the history
Rendering a time-series chart before the data has arrived -- as may be
the case if there are multiple pending requests, and the first one
received does not contain data for the chart -- will use default values
of 0.0.
  • Loading branch information
antw committed Oct 29, 2018
1 parent f130758 commit e5f1dda
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/assets/javascripts/lib/views/d3_yearly_chart_view.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -128,12 +128,16 @@ class @D3YearlyChartView extends D3ChartView
max

getSerie: (serie) =>
# Creates a default array of values (8760 x 0.0) if the query does not have
# a value. This may be the case if the user quickly loads one slide, then a
# slide containing this chart: the chart will be rendered before the second
# request containing data is received.
color: serie.get('color'),
label: serie.get('label'),
key: serie.get('gquery').get('key'),
skip: serie.get('skip'),
is_target: serie.get('is_target_line')
values: serie.future_value()
values: serie.future_value() || Array.apply(null, Array(8760)).map(-> 0)

createLinearScale: ->
d3.scale.linear().domain([0, @maxYvalue()]).range([@height, 0]).nice()
Expand Down

0 comments on commit e5f1dda

Please sign in to comment.