Show and hide filtered series on graph
parent
d381312b9c
commit
5bd50fd587
|
@ -26,8 +26,8 @@ export default class Dygraph extends Component {
|
||||||
isSnipped: false,
|
isSnipped: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
this.getTimeSeries = ::this.getTimeSeries
|
|
||||||
this.sync = ::this.sync
|
this.sync = ::this.sync
|
||||||
|
this.getTimeSeries = ::this.getTimeSeries
|
||||||
this.handleSortLegend = ::this.handleSortLegend
|
this.handleSortLegend = ::this.handleSortLegend
|
||||||
this.handleLegendInputChange = ::this.handleLegendInputChange
|
this.handleLegendInputChange = ::this.handleLegendInputChange
|
||||||
this.handleSnipLabel = ::this.handleSnipLabel
|
this.handleSnipLabel = ::this.handleSnipLabel
|
||||||
|
@ -68,8 +68,6 @@ export default class Dygraph extends Component {
|
||||||
finalLineColors = LINE_COLORS
|
finalLineColors = LINE_COLORS
|
||||||
}
|
}
|
||||||
|
|
||||||
const dygraphComponent = this // eslint-disable-line consistent-this
|
|
||||||
|
|
||||||
const defaultOptions = {
|
const defaultOptions = {
|
||||||
plugins: [
|
plugins: [
|
||||||
new Dygraphs.Plugins.Crosshair({
|
new Dygraphs.Plugins.Crosshair({
|
||||||
|
@ -221,6 +219,8 @@ export default class Dygraph extends Component {
|
||||||
ruleValues,
|
ruleValues,
|
||||||
isBarGraph,
|
isBarGraph,
|
||||||
} = this.props
|
} = this.props
|
||||||
|
const {filterText, legend} = this.state
|
||||||
|
|
||||||
const dygraph = this.dygraph
|
const dygraph = this.dygraph
|
||||||
if (!dygraph) {
|
if (!dygraph) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
|
@ -229,8 +229,15 @@ export default class Dygraph extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
const timeSeries = this.getTimeSeries()
|
const timeSeries = this.getTimeSeries()
|
||||||
|
const visibility = timeSeries.map(() => true).map((b, i) => {
|
||||||
|
if (!legend.series[i]) {
|
||||||
|
return b
|
||||||
|
}
|
||||||
|
|
||||||
dygraph.updateOptions({
|
return !!legend.series[i].label.match(filterText)
|
||||||
|
})
|
||||||
|
|
||||||
|
const updateOptions = {
|
||||||
labels,
|
labels,
|
||||||
file: timeSeries,
|
file: timeSeries,
|
||||||
axes: {
|
axes: {
|
||||||
|
@ -246,12 +253,10 @@ export default class Dygraph extends Component {
|
||||||
underlayCallback: options.underlayCallback,
|
underlayCallback: options.underlayCallback,
|
||||||
series: dygraphSeries,
|
series: dygraphSeries,
|
||||||
plotter: isBarGraph ? multiColumnBarPlotter : null,
|
plotter: isBarGraph ? multiColumnBarPlotter : null,
|
||||||
})
|
visibility,
|
||||||
|
}
|
||||||
|
|
||||||
// part of optional workaround for preventing updateOptions from breaking legend
|
dygraph.updateOptions(updateOptions)
|
||||||
// if (this.lastMouseMoveEvent) {
|
|
||||||
// dygraph.mouseMove_(this.lastMouseMoveEvent)
|
|
||||||
// }
|
|
||||||
dygraph.resize()
|
dygraph.resize()
|
||||||
const {w} = this.dygraph.getArea()
|
const {w} = this.dygraph.getArea()
|
||||||
this.props.setResolution(w)
|
this.props.setResolution(w)
|
||||||
|
|
Loading…
Reference in New Issue