Implement PR review suggestions.
parent
7f2342dc37
commit
b4ecdf3c5e
|
@ -14,7 +14,7 @@ import * as queryModifiers from 'src/utils/queryTransitions'
|
||||||
import defaultQueryConfig from 'src/utils/defaultQueryConfig'
|
import defaultQueryConfig from 'src/utils/defaultQueryConfig'
|
||||||
import {buildQuery} from 'utils/influxql'
|
import {buildQuery} from 'utils/influxql'
|
||||||
import {getQueryConfig} from 'shared/apis'
|
import {getQueryConfig} from 'shared/apis'
|
||||||
import {GET_STATIC_LEGEND} from 'src/shared/constants'
|
import {IS_STATIC_LEGEND} from 'src/shared/constants'
|
||||||
|
|
||||||
import {
|
import {
|
||||||
removeUnselectedTemplateValues,
|
removeUnselectedTemplateValues,
|
||||||
|
@ -46,7 +46,7 @@ class CellEditorOverlay extends Component {
|
||||||
queriesWorkingDraft,
|
queriesWorkingDraft,
|
||||||
activeQueryIndex: 0,
|
activeQueryIndex: 0,
|
||||||
isDisplayOptionsTabActive: false,
|
isDisplayOptionsTabActive: false,
|
||||||
staticLegend: GET_STATIC_LEGEND(legend),
|
staticLegend: IS_STATIC_LEGEND(legend),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -339,14 +339,13 @@ class Dygraph extends Component {
|
||||||
className="dygraph-child-container"
|
className="dygraph-child-container"
|
||||||
style={dygraphStyle}
|
style={dygraphStyle}
|
||||||
/>
|
/>
|
||||||
{staticLegend
|
{staticLegend &&
|
||||||
? <StaticLegend
|
<StaticLegend
|
||||||
dygraph={this.dygraph}
|
dygraph={this.dygraph}
|
||||||
handleReceiveStaticLegendHeight={
|
handleReceiveStaticLegendHeight={
|
||||||
this.handleReceiveStaticLegendHeight
|
this.handleReceiveStaticLegendHeight
|
||||||
}
|
}
|
||||||
/>
|
/>}
|
||||||
: null}
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,12 +3,7 @@ import _ from 'lodash'
|
||||||
import classnames from 'classnames'
|
import classnames from 'classnames'
|
||||||
import uuid from 'node-uuid'
|
import uuid from 'node-uuid'
|
||||||
|
|
||||||
import {makeLegendStyles} from 'shared/graphs/helpers'
|
import {makeLegendStyles, removeMeasurement} from 'shared/graphs/helpers'
|
||||||
|
|
||||||
const removeMeasurement = (label = '') => {
|
|
||||||
const [measurement] = label.match(/^(.*)[.]/g) || ['']
|
|
||||||
return label.replace(measurement, '')
|
|
||||||
}
|
|
||||||
|
|
||||||
class DygraphLegend extends Component {
|
class DygraphLegend extends Component {
|
||||||
state = {
|
state = {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import WidgetCell from 'shared/components/WidgetCell'
|
||||||
import LayoutCell from 'shared/components/LayoutCell'
|
import LayoutCell from 'shared/components/LayoutCell'
|
||||||
import RefreshingGraph from 'shared/components/RefreshingGraph'
|
import RefreshingGraph from 'shared/components/RefreshingGraph'
|
||||||
import {buildQueriesForLayouts} from 'utils/buildQueriesForLayouts'
|
import {buildQueriesForLayouts} from 'utils/buildQueriesForLayouts'
|
||||||
import {GET_STATIC_LEGEND} from 'src/shared/constants'
|
import {IS_STATIC_LEGEND} from 'src/shared/constants'
|
||||||
|
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ const Layout = (
|
||||||
: <RefreshingGraph
|
: <RefreshingGraph
|
||||||
axes={axes}
|
axes={axes}
|
||||||
type={type}
|
type={type}
|
||||||
staticLegend={GET_STATIC_LEGEND(legend)}
|
staticLegend={IS_STATIC_LEGEND(legend)}
|
||||||
cellHeight={h}
|
cellHeight={h}
|
||||||
colors={colors}
|
colors={colors}
|
||||||
onZoom={onZoom}
|
onZoom={onZoom}
|
||||||
|
|
|
@ -1,19 +1,7 @@
|
||||||
import React, {PropTypes, Component} from 'react'
|
import React, {PropTypes, Component} from 'react'
|
||||||
import _ from 'lodash'
|
import _ from 'lodash'
|
||||||
import uuid from 'node-uuid'
|
import uuid from 'node-uuid'
|
||||||
|
import {removeMeasurement} from 'shared/graphs/helpers'
|
||||||
const style = {
|
|
||||||
position: 'absolute',
|
|
||||||
width: 'calc(100% - 32px)',
|
|
||||||
bottom: '8px',
|
|
||||||
left: '16px',
|
|
||||||
paddingTop: '8px',
|
|
||||||
}
|
|
||||||
|
|
||||||
const removeMeasurement = (label = '') => {
|
|
||||||
const [measurement] = label.match(/^(.*)[.]/g) || ['']
|
|
||||||
return label.replace(measurement, '')
|
|
||||||
}
|
|
||||||
|
|
||||||
const staticLegendItemClassname = (visibilities, i, hoverEnabled) => {
|
const staticLegendItemClassname = (visibilities, i, hoverEnabled) => {
|
||||||
if (visibilities.length) {
|
if (visibilities.length) {
|
||||||
|
@ -29,10 +17,11 @@ const staticLegendItemClassname = (visibilities, i, hoverEnabled) => {
|
||||||
class StaticLegend extends Component {
|
class StaticLegend extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props)
|
super(props)
|
||||||
|
}
|
||||||
|
|
||||||
this.state = {
|
state = {
|
||||||
visibilities: [],
|
visibilities: [],
|
||||||
}
|
clickStatus: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
componentDidMount = () => {
|
componentDidMount = () => {
|
||||||
|
@ -51,6 +40,7 @@ class StaticLegend extends Component {
|
||||||
|
|
||||||
handleClick = i => e => {
|
handleClick = i => e => {
|
||||||
const visibilities = this.props.dygraph.visibility()
|
const visibilities = this.props.dygraph.visibility()
|
||||||
|
const clickStatus = this.state.clickStatus
|
||||||
|
|
||||||
if (e.shiftKey || e.metaKey) {
|
if (e.shiftKey || e.metaKey) {
|
||||||
visibilities[i] = !visibilities[i]
|
visibilities[i] = !visibilities[i]
|
||||||
|
@ -59,13 +49,19 @@ class StaticLegend extends Component {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
const newVisibilities = visibilities[i]
|
const prevClickStatus = clickStatus && visibilities[i]
|
||||||
? _.map(visibilities, v => !v)
|
|
||||||
|
const newVisibilities = prevClickStatus
|
||||||
|
? _.map(visibilities, () => true)
|
||||||
: _.map(visibilities, () => false)
|
: _.map(visibilities, () => false)
|
||||||
|
|
||||||
newVisibilities[i] = true
|
newVisibilities[i] = true
|
||||||
|
|
||||||
this.props.dygraph.setVisibility(newVisibilities)
|
this.props.dygraph.setVisibility(newVisibilities)
|
||||||
this.setState({visibilities: newVisibilities})
|
this.setState({
|
||||||
|
visibilities: newVisibilities,
|
||||||
|
clickStatus: !prevClickStatus,
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
@ -74,9 +70,7 @@ class StaticLegend extends Component {
|
||||||
|
|
||||||
const labels = dygraph ? _.drop(dygraph.getLabels()) : []
|
const labels = dygraph ? _.drop(dygraph.getLabels()) : []
|
||||||
const colors = dygraph
|
const colors = dygraph
|
||||||
? _.map(labels, l => {
|
? _.map(labels, l => dygraph.attributes_.series_[l].options.color)
|
||||||
return dygraph.attributes_.series_[l].options.color
|
|
||||||
})
|
|
||||||
: []
|
: []
|
||||||
|
|
||||||
const hoverEnabled = labels.length > 1
|
const hoverEnabled = labels.length > 1
|
||||||
|
|
|
@ -426,7 +426,7 @@ export const DEFAULT_SOURCE = {
|
||||||
metaUrl: '',
|
metaUrl: '',
|
||||||
}
|
}
|
||||||
|
|
||||||
export const GET_STATIC_LEGEND = legend =>
|
export const IS_STATIC_LEGEND = legend =>
|
||||||
_.get(legend, 'type', false) === 'static'
|
_.get(legend, 'type', false) === 'static'
|
||||||
|
|
||||||
export const linksLink = '/chronograf/v1'
|
export const linksLink = '/chronograf/v1'
|
||||||
|
|
|
@ -173,6 +173,12 @@ export const makeLegendStyles = (graph, legend, pageX) => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// globally matches anything that ends in a '.'
|
||||||
|
export const removeMeasurement = (label = '') => {
|
||||||
|
const [measurement] = label.match(/^(.*)[.]/g) || ['']
|
||||||
|
return label.replace(measurement, '')
|
||||||
|
}
|
||||||
|
|
||||||
export const OPTIONS = {
|
export const OPTIONS = {
|
||||||
rightGap: 0,
|
rightGap: 0,
|
||||||
axisLineWidth: 2,
|
axisLineWidth: 2,
|
||||||
|
|
|
@ -6,7 +6,12 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
.static-legend {
|
.static-legend {
|
||||||
|
position: absolute;
|
||||||
|
width: calc(100% - 32px);
|
||||||
|
bottom: 8px;
|
||||||
|
left: 16px;
|
||||||
display: flex;
|
display: flex;
|
||||||
|
padding-top: 8px;
|
||||||
align-items: flex-end;
|
align-items: flex-end;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
max-height: 50%;
|
max-height: 50%;
|
||||||
|
|
Loading…
Reference in New Issue