this.container = el} className="rhythm_chart__timeseries-container">
{ tooltip }
{ annotations }
diff --git a/src/core_plugins/metrics/public/visualizations/components/top_n.js b/src/core_plugins/metrics/public/visualizations/components/top_n.js
index e50ea366b2355..464cddd7dffbe 100644
--- a/src/core_plugins/metrics/public/visualizations/components/top_n.js
+++ b/src/core_plugins/metrics/public/visualizations/components/top_n.js
@@ -1,6 +1,7 @@
import React, { Component, PropTypes } from 'react';
import _ from 'lodash';
import getLastValue from '../lib/get_last_value';
+import reactcss from 'reactcss';
class TopN extends Component {
@@ -20,18 +21,27 @@ class TopN extends Component {
const value = formatter(lastValue);
const width = `${100 * (lastValue / maxValue)}%`;
const backgroundColor = item.color;
- const style = {};
- if (this.props.onClick) {
- style.cursor = 'pointer';
- }
+ const styles = reactcss({
+ default: {
+ innerBar: {
+ width,
+ backgroundColor
+ }
+ },
+ onClick: {
+ row: {
+ cursor: 'pointer'
+ }
+ }
+ }, this.props);
return (
+ style={styles.row}>
{ item.label } |
+ style={styles.innerBar}/>
|
{ value } |
@@ -40,7 +50,7 @@ class TopN extends Component {
}
render() {
- if (!this.props.series) return (
);
+ if (!this.props.series) return null;
const maxValue = this.props.series.reduce((max, series) => {
const lastValue = getLastValue(series.data, series.data.length);
return lastValue > max ? lastValue : max;
diff --git a/src/core_plugins/metrics/public/visualizations/components/vertical_legend.js b/src/core_plugins/metrics/public/visualizations/components/vertical_legend.js
index 32f83c0c42a0d..4a789ace72204 100644
--- a/src/core_plugins/metrics/public/visualizations/components/vertical_legend.js
+++ b/src/core_plugins/metrics/public/visualizations/components/vertical_legend.js
@@ -1,32 +1,36 @@
import React, { PropTypes } from 'react';
import createLegendSeries from '../lib/create_legend_series';
+import reactcss from 'reactcss';
function VerticalLegend(props) {
const rows = props.series.map(createLegendSeries(props));
- const seriesStyle = {};
- const legendStyle = {};
- const controlStyle = {};
- let openClass = 'fa-chevron-left';
- let closeClass = 'fa-chevron-right';
- if (props.legendPosition === 'left') {
- openClass = 'fa-chevron-right';
- closeClass = 'fa-chevron-left';
- legendStyle.order = '-1';
- controlStyle.order = '2';
- }
- let legendControlClass = `fa ${closeClass}`;
- legendStyle.width = 200;
- if (!props.showLegend) {
- legendStyle.width = 12;
- seriesStyle.display = 'none';
- legendControlClass = `fa ${openClass}`;
- }
+ const hideLegend = !props.showLegend;
+ const leftLegend = props.legendPosition === 'left';
+
+ const styles = reactcss({
+ default: {
+ legend: { width: 200 }
+ },
+ leftLegend: {
+ legend: { order: '-1' },
+ control: { order: '2' }
+ },
+ hideLegend: {
+ legend: { width: 12 },
+ series: { display: 'none' },
+ }
+ }, { hideLegend, leftLegend });
+
+ const openClass = leftLegend ? 'fa-chevron-right' : 'fa-chevron-left';
+ const closeClass = leftLegend ? 'fa-chevron-left' : 'fa-chevron-right';
+ const legendControlClass = hideLegend ? `fa ${openClass}` : `fa ${closeClass}`;
+
return (
-
-
+
+
-
diff --git a/src/core_plugins/metrics/public/visualizations/less/includes/chart.less b/src/core_plugins/metrics/public/visualizations/less/includes/chart.less
index c80436d9c6048..ea8ae6036aad5 100644
--- a/src/core_plugins/metrics/public/visualizations/less/includes/chart.less
+++ b/src/core_plugins/metrics/public/visualizations/less/includes/chart.less
@@ -115,6 +115,13 @@
}
}
+.rhythm_chart__timeseries-container {
+ position: relative;
+ display: flex;
+ row-direction: column;
+ flex: 1 0 auto;
+}
+
.annotation {
position: absolute;
display: flex;
@@ -124,6 +131,7 @@
}
.annotation__line {
flex: 1 0 auto;
+ width: 2px;
}
.annotation__icon {
position: relative;