From 47c86bb22cc12812ee6c6c3383d77fc2e32ed731 Mon Sep 17 00:00:00 2001 From: Andrew Watkins Date: Fri, 29 Sep 2017 13:40:13 -0700 Subject: [PATCH] Pull constants into graph helpers dir --- ui/src/shared/components/LineGraph.js | 20 ++++++-------------- ui/src/shared/graphs/helpers.js | 14 ++++++++++++++ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/ui/src/shared/components/LineGraph.js b/ui/src/shared/components/LineGraph.js index 2c9b45e14d..437f40e3ee 100644 --- a/ui/src/shared/components/LineGraph.js +++ b/ui/src/shared/components/LineGraph.js @@ -6,9 +6,12 @@ import shallowCompare from 'react-addons-shallow-compare' import timeSeriesToDygraph from 'utils/timeSeriesToDygraph' import lastValues from 'shared/parsing/lastValues' -const {array, arrayOf, bool, func, number, shape, string} = PropTypes +import { + SINGLE_STAT_LINE_COLORS, + SMALL_CELL_HEIGHT, +} from 'src/shared/graphs/helpers' -const SMALL_CELL_HEIGHT = 1 +const {array, arrayOf, bool, func, number, shape, string} = PropTypes class LineGraph extends Component { constructor(props) { @@ -97,17 +100,6 @@ class LineGraph extends Component { strokeWidth: 1.5, }, } - const singleStatLineColors = [ - '#7A65F2', - '#FFD255', - '#7CE490', - '#F95F53', - '#4591ED', - '#B1B6FF', - '#FFF6B8', - '#C6FFD0', - '#6BDFFF', - ] let roundedValue if (showSingleStat) { @@ -118,7 +110,7 @@ class LineGraph extends Component { } const lineColors = showSingleStat - ? singleStatLineColors + ? SINGLE_STAT_LINE_COLORS : overrideLineColors return ( diff --git a/ui/src/shared/graphs/helpers.js b/ui/src/shared/graphs/helpers.js index cef1945b81..e210d36f58 100644 --- a/ui/src/shared/graphs/helpers.js +++ b/ui/src/shared/graphs/helpers.js @@ -17,6 +17,20 @@ export const LINE_COLORS = [ '#a0725b', ] +export const SMALL_CELL_HEIGHT = 1 + +export const SINGLE_STAT_LINE_COLORS = [ + '#7A65F2', + '#FFD255', + '#7CE490', + '#F95F53', + '#4591ED', + '#B1B6FF', + '#FFF6B8', + '#C6FFD0', + '#6BDFFF', +] + export const darkenColor = colorStr => { // Defined in dygraph-utils.js const color = Dygraphs.toRGB_(colorStr)