Merge pull request #1957 from influxdata/bugfix/stacked

BUGFIX: Stacked graph bug
pull/1945/head^2
Andrew Watkins 2017-09-01 13:14:53 -07:00 committed by GitHub
commit 04818f1a61
3 changed files with 15 additions and 4 deletions

View File

@ -5,6 +5,7 @@
1. [#1951](https://github.com/influxdata/chronograf/pull/1951): Fix crosshair not being removed when user leaves graph
1. [#1943](https://github.com/influxdata/chronograf/pull/1943): Fix inability to add kapacitor from source page on fresh install
1. [#1947](https://github.com/influxdata/chronograf/pull/1947): Fix DataExplorer crash if field property not present on queryConfig
1. [#1957](https://github.com/influxdata/chronograf/pull/1957): Fix stacked graphs not being fully displayed
### Features
1. [#1928](https://github.com/influxdata/chronograf/pull/1928): Add prefix, suffix, scale, and other y-axis formatting

View File

@ -6,7 +6,7 @@ import _ from 'lodash'
import moment from 'moment'
import Dygraphs from 'src/external/dygraph'
import getRange from 'shared/parsing/getRangeForDygraph'
import getRange, {getStackedRange} from 'shared/parsing/getRangeForDygraph'
import DygraphLegend from 'src/shared/components/DygraphLegend'
import {DISPLAY_OPTIONS} from 'src/dashboards/constants'
import {buildDefaultYLabel} from 'shared/presenters'
@ -63,7 +63,9 @@ export default class Dygraph extends Component {
plugins: [new Dygraphs.Plugins.Crosshair({direction: 'vertical'})],
axes: {
y: {
valueRange: getRange(timeSeries, y.bounds, ruleValues),
valueRange: options.stackedGraph
? getStackedRange(y.bounds)
: getRange(timeSeries, y.bounds, ruleValues),
axisLabelFormatter: (yval, __, opts) =>
numberValueFormatter(yval, opts, y.prefix, y.suffix),
axisLabelWidth: this.getLabelWidth(),
@ -142,12 +144,14 @@ export default class Dygraph extends Component {
const updateOptions = {
...options,
labels,
ylabel: this.getLabel('y'),
file: timeSeries,
logscale: y.scale === LOG,
ylabel: this.getLabel('y'),
axes: {
y: {
valueRange: getRange(timeSeries, y.bounds, ruleValues),
valueRange: options.stackedGraph
? getStackedRange(y.bounds)
: getRange(timeSeries, y.bounds, ruleValues),
axisLabelFormatter: (yval, __, opts) =>
numberValueFormatter(yval, opts, y.prefix, y.suffix),
axisLabelWidth: this.getLabelWidth(),

View File

@ -79,4 +79,10 @@ const getRange = (
return [min, max]
}
const coerceToNum = str => (str ? +str : null)
export const getStackedRange = (bounds = [null, null]) => [
coerceToNum(bounds[0]),
coerceToNum(bounds[1]),
]
export default getRange