WIP make resizing work
parent
bca650ec21
commit
7161f4dc0c
|
@ -9,39 +9,48 @@ import _ from 'lodash';
|
||||||
const RefreshingLineGraph = AutoRefresh(LineGraph);
|
const RefreshingLineGraph = AutoRefresh(LineGraph);
|
||||||
const RefreshingSingleStat = AutoRefresh(SingleStat);
|
const RefreshingSingleStat = AutoRefresh(SingleStat);
|
||||||
|
|
||||||
|
const {
|
||||||
|
children,
|
||||||
|
arrayOf,
|
||||||
|
node,
|
||||||
|
number,
|
||||||
|
shape,
|
||||||
|
string,
|
||||||
|
} = PropTypes;
|
||||||
|
|
||||||
export const LayoutRenderer = React.createClass({
|
export const LayoutRenderer = React.createClass({
|
||||||
propTypes: {
|
propTypes: {
|
||||||
timeRange: PropTypes.shape({
|
timeRange: shape({
|
||||||
defaultGroupBy: PropTypes.string.isRequired,
|
defaultGroupBy: string.isRequired,
|
||||||
queryValue: PropTypes.string.isRequired,
|
queryValue: string.isRequired,
|
||||||
}).isRequired,
|
}).isRequired,
|
||||||
cells: PropTypes.arrayOf(
|
cells: arrayOf(
|
||||||
PropTypes.shape({
|
shape({
|
||||||
queries: PropTypes.arrayOf(
|
queries: arrayOf(
|
||||||
PropTypes.shape({
|
shape({
|
||||||
label: PropTypes.string,
|
label: string,
|
||||||
range: PropTypes.shape({
|
range: shape({
|
||||||
upper: PropTypes.number,
|
upper: number,
|
||||||
lower: PropTypes.number,
|
lower: number,
|
||||||
}),
|
}),
|
||||||
rp: PropTypes.string,
|
rp: string,
|
||||||
text: PropTypes.string.isRequired,
|
text: string.isRequired,
|
||||||
database: PropTypes.string.isRequired,
|
database: string.isRequired,
|
||||||
groupbys: PropTypes.arrayOf(PropTypes.string),
|
groupbys: arrayOf(string),
|
||||||
wheres: PropTypes.arrayOf(PropTypes.string),
|
wheres: arrayOf(string),
|
||||||
}).isRequired
|
}).isRequired
|
||||||
).isRequired,
|
).isRequired,
|
||||||
x: PropTypes.number.isRequired,
|
x: number.isRequired,
|
||||||
y: PropTypes.number.isRequired,
|
y: number.isRequired,
|
||||||
w: PropTypes.number.isRequired,
|
w: number.isRequired,
|
||||||
h: PropTypes.number.isRequired,
|
h: number.isRequired,
|
||||||
i: PropTypes.string.isRequired,
|
i: string.isRequired,
|
||||||
name: PropTypes.string.isRequired,
|
name: string.isRequired,
|
||||||
}).isRequired
|
}).isRequired
|
||||||
),
|
),
|
||||||
autoRefreshMs: PropTypes.number.isRequired,
|
autoRefreshMs: number.isRequired,
|
||||||
host: PropTypes.string,
|
host: string,
|
||||||
source: PropTypes.string,
|
source: string,
|
||||||
},
|
},
|
||||||
|
|
||||||
getInitialState() {
|
getInitialState() {
|
||||||
|
@ -105,12 +114,9 @@ export const LayoutRenderer = React.createClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div key={cell.i}>
|
<Wrapper key={cell.i}>
|
||||||
<h2 className="hosts-graph-heading">{cell.name}</h2>
|
<RefreshingLineGraph queries={qs} autoRefresh={autoRefreshMs} showSingleStat={cell.type === "line-plus-single-stat"} />
|
||||||
<div className="hosts-graph graph-container ">
|
</Wrapper>
|
||||||
<RefreshingLineGraph queries={qs} autoRefresh={autoRefreshMs} showSingleStat={cell.type === "line-plus-single-stat"} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
@ -141,4 +147,24 @@ export const LayoutRenderer = React.createClass({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const Wrapper = React.createClass({
|
||||||
|
propTypes: {
|
||||||
|
children: node.isRequired,
|
||||||
|
},
|
||||||
|
render() {
|
||||||
|
const that = this;
|
||||||
|
const newChildren = React.Children.map(this.props.children, (child) => {
|
||||||
|
return React.cloneElement(child, {
|
||||||
|
height: that.props.style.height,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div {...this.props}>
|
||||||
|
{newChildren}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
export default LayoutRenderer;
|
export default LayoutRenderer;
|
||||||
|
|
|
@ -25,6 +25,7 @@ export default React.createClass({
|
||||||
y: arrayOf(number),
|
y: arrayOf(number),
|
||||||
y2: arrayOf(number),
|
y2: arrayOf(number),
|
||||||
}),
|
}),
|
||||||
|
height: string,
|
||||||
title: string,
|
title: string,
|
||||||
isFetchingInitially: bool,
|
isFetchingInitially: bool,
|
||||||
isRefreshing: bool,
|
isRefreshing: bool,
|
||||||
|
@ -100,20 +101,22 @@ export default React.createClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={classNames({"graph--hasYLabel": !!(options.ylabel || options.y2label)})}>
|
<div>
|
||||||
{isRefreshing ? this.renderSpinner() : null}
|
<div className={classNames({"graph--hasYLabel": !!(options.ylabel || options.y2label)})}>
|
||||||
<Dygraph
|
{isRefreshing ? this.renderSpinner() : null}
|
||||||
containerStyle={{width: '100%', height: '300px'}}
|
<Dygraph
|
||||||
overrideLineColors={overrideLineColors}
|
containerStyle={{width: '95%', height: this.props.height && parseInt(this.props.height, 10) - 20 + 'px' || '100%'}}
|
||||||
isGraphFilled={isGraphFilled}
|
overrideLineColors={overrideLineColors}
|
||||||
timeSeries={timeSeries}
|
isGraphFilled={isGraphFilled}
|
||||||
labels={labels}
|
timeSeries={timeSeries}
|
||||||
options={options}
|
labels={labels}
|
||||||
dygraphSeries={dygraphSeries}
|
options={options}
|
||||||
ranges={ranges || this.getRanges()}
|
dygraphSeries={dygraphSeries}
|
||||||
ruleValues={ruleValues}
|
ranges={ranges || this.getRanges()}
|
||||||
/>
|
ruleValues={ruleValues}
|
||||||
{showSingleStat ? <div className="graph-single-stat single-stat">{roundedValue}</div> : null}
|
/>
|
||||||
|
{showSingleStat ? <div className="graph-single-stat single-stat">{roundedValue}</div> : null}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue