Pass default Y label into DisplayOptions
Refactor DisplayOptions into ES6 component Rename buildYLabel to buildDefaultYLabelpull/1928/head
parent
abf3da2a78
commit
0cb5523f5b
|
@ -43,16 +43,16 @@ class DisplayOptions extends Component {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="display-options">
|
<div className="display-options">
|
||||||
<GraphTypeSelector
|
|
||||||
selectedGraphType={selectedGraphType}
|
|
||||||
onSelectGraphType={onSelectGraphType}
|
|
||||||
/>
|
|
||||||
<AxesOptions
|
<AxesOptions
|
||||||
onSetLabel={onSetLabel}
|
onSetLabel={onSetLabel}
|
||||||
onSetYAxisBoundMin={onSetYAxisBoundMin}
|
onSetYAxisBoundMin={onSetYAxisBoundMin}
|
||||||
onSetYAxisBoundMax={onSetYAxisBoundMax}
|
onSetYAxisBoundMax={onSetYAxisBoundMax}
|
||||||
axes={axes}
|
axes={axes}
|
||||||
/>
|
/>
|
||||||
|
<GraphTypeSelector
|
||||||
|
selectedGraphType={selectedGraphType}
|
||||||
|
onSelectGraphType={onSelectGraphType}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -42,6 +42,25 @@ export default class Dygraph extends Component {
|
||||||
dygraphRef: () => {},
|
dygraphRef: () => {},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getTimeSeries() {
|
||||||
|
const {timeSeries} = this.props
|
||||||
|
// Avoid 'Can't plot empty data set' errors by falling back to a
|
||||||
|
// default dataset that's valid for Dygraph.
|
||||||
|
return timeSeries.length ? timeSeries : [[0]]
|
||||||
|
}
|
||||||
|
|
||||||
|
getLabel(axis) {
|
||||||
|
const {axes, queries} = this.props
|
||||||
|
const label = _.get(axes, [axis, 'label'], '')
|
||||||
|
const queryConfig = _.get(queries, ['0', 'queryConfig'], false)
|
||||||
|
|
||||||
|
if (label || !queryConfig) {
|
||||||
|
return label
|
||||||
|
}
|
||||||
|
|
||||||
|
return buildDefaultYLabel(queryConfig)
|
||||||
|
}
|
||||||
|
|
||||||
componentDidMount() {
|
componentDidMount() {
|
||||||
const timeSeries = this.getTimeSeries()
|
const timeSeries = this.getTimeSeries()
|
||||||
// dygraphSeries is a legend label and its corresponding y-axis e.g. {legendLabel1: 'y', legendLabel2: 'y2'};
|
// dygraphSeries is a legend label and its corresponding y-axis e.g. {legendLabel1: 'y', legendLabel2: 'y2'};
|
||||||
|
|
Loading…
Reference in New Issue