mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
removing extra cruft
This commit is contained in:
parent
1cb28600fb
commit
4efe0ecd92
6 changed files with 0 additions and 199 deletions
|
@ -1,18 +0,0 @@
|
|||
import React, { Component, PropTypes } from 'react';
|
||||
export default (props) => {
|
||||
const bars = props.values.map(val => {
|
||||
const width = (val.value < 1) ? (val.value * 100) : 100;
|
||||
const style = {
|
||||
backgroundColor: val.color,
|
||||
width: `${width}%`
|
||||
};
|
||||
return (
|
||||
<div key={ val.color } className="bar" style={ style }></div>
|
||||
);
|
||||
});
|
||||
return (
|
||||
<div className="bar-vis">
|
||||
{bars}
|
||||
</div>
|
||||
);
|
||||
};
|
|
@ -1,38 +0,0 @@
|
|||
import moment from 'moment';
|
||||
|
||||
/* calling .subtract or .add on a moment object mutates the object
|
||||
* so this function shortcuts creating a fresh object */
|
||||
function getTime(bucket) {
|
||||
return moment.utc(bucket[0]);
|
||||
}
|
||||
|
||||
/* find the milliseconds of difference between 2 moment objects */
|
||||
function getDelta(t1, t2) {
|
||||
return moment.duration(t1 - t2).asMilliseconds();
|
||||
}
|
||||
|
||||
export default function filterPartialBuckets(min, max, bucketSize, options = {}) {
|
||||
return (bucket) => {
|
||||
const bucketTime = getTime(bucket);
|
||||
|
||||
// timestamp is too late to be complete
|
||||
if (getDelta(max, bucketTime.add(bucketSize, 'seconds')) < (bucketSize * 1000)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/* Table listing metrics don't need to filter the beginning of data for
|
||||
* partial buckets. They just boil down the data into max/min/last/slope
|
||||
* numbers instead of graphing it. So table listing data buckets pass
|
||||
* ignoreEarly */
|
||||
if (options.ignoreEarly !== true) {
|
||||
// timestamp is too early to be complete
|
||||
if (getDelta(bucketTime.subtract(bucketSize, 'seconds'), min) < 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
import getLastValue from './get_last_value';
|
||||
import flot from './flot';
|
||||
import events from './events';
|
||||
import filterPartialBuckets from './filter_partial_buckets';
|
||||
import calculateAuto from './calculate_auto';
|
||||
|
||||
import Timeseries from './timeseries';
|
||||
|
@ -23,6 +22,5 @@ export default {
|
|||
getLastValue,
|
||||
flot,
|
||||
events,
|
||||
filterPartialBuckets,
|
||||
calculateAuto,
|
||||
};
|
||||
|
|
|
@ -1,17 +0,0 @@
|
|||
import _ from 'lodash';
|
||||
import numeral from 'numeral';
|
||||
import React, { Component } from 'react';
|
||||
import $ from './flot';
|
||||
import getLastValue from './get_last_value';
|
||||
import Sparkline from './sparkline';
|
||||
class LoadSparkline extends Sparkline {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
this.opts.yaxis.max = _(props.metrics).map(row => row[1]).max() + 1;
|
||||
this.opts.yaxis.min = 0;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default LoadSparkline;
|
|
@ -1,31 +0,0 @@
|
|||
import _ from 'lodash';
|
||||
import numeral from 'numeral';
|
||||
import React, { Component } from 'react';
|
||||
import $ from './flot';
|
||||
import getLastValue from './get_last_value';
|
||||
import Sparkline from './sparkline';
|
||||
class SeriesSparkline extends Sparkline {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
}
|
||||
|
||||
calculateData(data) {
|
||||
return _(data)
|
||||
.map((set) => {
|
||||
if (_.isPlainObject(set)) {
|
||||
return set;
|
||||
}
|
||||
return {
|
||||
color: '#990000',
|
||||
data: set
|
||||
};
|
||||
})
|
||||
.reverse()
|
||||
.value();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default SeriesSparkline;
|
||||
|
|
@ -1,93 +0,0 @@
|
|||
import _ from 'lodash';
|
||||
import numeral from 'numeral';
|
||||
import React, { Component } from 'react';
|
||||
import $ from './flot';
|
||||
import getLastValue from './get_last_value';
|
||||
|
||||
class Sparkline extends Component {
|
||||
|
||||
constructor(props) {
|
||||
super(props);
|
||||
const max = props.max;
|
||||
const min = props.min;
|
||||
this.height = props.height || 75;
|
||||
this.width = props.width || 150;
|
||||
this.opts = {
|
||||
legend: { show: false },
|
||||
xaxis: {
|
||||
timezone: 'browser',
|
||||
mode: 'time',
|
||||
show: false
|
||||
},
|
||||
yaxis: { show: false },
|
||||
series: {
|
||||
shadowSize: 0,
|
||||
lines: {
|
||||
lineWidth: props.line ? 1 : 0, fill: props.line ? 0.0 : 1.0,
|
||||
show: true
|
||||
}
|
||||
},
|
||||
grid: {
|
||||
backgroundColor: '#EEEEEE',
|
||||
borderWidth: 0
|
||||
}
|
||||
};
|
||||
|
||||
if (props.max) _.set(this.opts, 'yaxis.max', props.max);
|
||||
if (props.min) _.set(this.opts, 'yaxis.min', props.min);
|
||||
}
|
||||
|
||||
componentWillUnmount() {
|
||||
this.plot.shutdown();
|
||||
}
|
||||
|
||||
shouldComponentUpdate() {
|
||||
if (!this.plot) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
componentWillReceiveProps(newProps) {
|
||||
if (this.plot) {
|
||||
const { metrics } = newProps;
|
||||
this.plot.setData(this.calculateData(metrics));
|
||||
this.plot.setupGrid();
|
||||
this.plot.draw();
|
||||
}
|
||||
}
|
||||
|
||||
componentDidMount() {
|
||||
this.renderChart();
|
||||
}
|
||||
|
||||
calculateData(data) {
|
||||
const last = getLastValue(data);
|
||||
const dataPoint = {
|
||||
color: this.props.color || '#6eadc1',
|
||||
data,
|
||||
lines: {}
|
||||
};
|
||||
if (this.props.thresholds) {
|
||||
dataPoint.color = '#d76051';
|
||||
dataPoint.threshold = [
|
||||
{ below: 0.60, color: '#8ac336'},
|
||||
{ below: 0.80, color: '#fbce47' }
|
||||
];
|
||||
}
|
||||
return [dataPoint];
|
||||
}
|
||||
|
||||
renderChart() {
|
||||
const { target} = this.refs;
|
||||
const { metrics} = this.props;
|
||||
const data = this.calculateData(metrics);
|
||||
$(target).width(this.width).height(this.height);
|
||||
this.plot = $.plot(target, data, this.opts);
|
||||
}
|
||||
|
||||
render() {
|
||||
return (<div className="sparkline" ref="target"/>);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export default Sparkline;
|
Loading…
Add table
Add a link
Reference in a new issue