Commit cd458950 authored by Mike Greiling's avatar Mike Greiling

correctly set the domain of a result set when it is different on other tracks

parent 0816b280
...@@ -79,7 +79,7 @@ ...@@ -79,7 +79,7 @@
}, },
formatMetricUsage(series) { formatMetricUsage(series) {
const value = series.values[this.currentDataIndex].value; const value = series.values[this.currentDataIndex] && series.values[this.currentDataIndex].value;
if (isNaN(value)) { if (isNaN(value)) {
return '-'; return '-';
} }
......
...@@ -13,7 +13,7 @@ const defaultColorOrder = ['blue', 'orange', 'red', 'green', 'purple']; ...@@ -13,7 +13,7 @@ const defaultColorOrder = ['blue', 'orange', 'red', 'green', 'purple'];
const defaultStyleOrder = ['solid', 'dashed', 'dotted']; const defaultStyleOrder = ['solid', 'dashed', 'dotted'];
function queryTimeSeries(query, graphWidth, graphHeight, graphHeightOffset, maxValue, lineStyle) { function queryTimeSeries(query, graphWidth, graphHeight, graphHeightOffset, xDom, yDom, lineStyle) {
let usedColors = []; let usedColors = [];
function pickColor(name) { function pickColor(name) {
...@@ -44,9 +44,9 @@ function queryTimeSeries(query, graphWidth, graphHeight, graphHeightOffset, maxV ...@@ -44,9 +44,9 @@ function queryTimeSeries(query, graphWidth, graphHeight, graphHeightOffset, maxV
const timeSeriesScaleY = d3.scale.linear() const timeSeriesScaleY = d3.scale.linear()
.range([graphHeight - graphHeightOffset, 0]); .range([graphHeight - graphHeightOffset, 0]);
timeSeriesScaleX.domain(d3.extent(timeSeries.values, d => d.time)); timeSeriesScaleX.domain(xDom);
timeSeriesScaleX.ticks(d3.time.minute, 60); timeSeriesScaleX.ticks(d3.time.minute, 60);
timeSeriesScaleY.domain([0, maxValue]); timeSeriesScaleY.domain(yDom);
const defined = d => !isNaN(d.value) && d.value != null; const defined = d => !isNaN(d.value) && d.value != null;
...@@ -93,17 +93,17 @@ function queryTimeSeries(query, graphWidth, graphHeight, graphHeightOffset, maxV ...@@ -93,17 +93,17 @@ function queryTimeSeries(query, graphWidth, graphHeight, graphHeightOffset, maxV
} }
export default function createTimeSeries(queries, graphWidth, graphHeight, graphHeightOffset) { export default function createTimeSeries(queries, graphWidth, graphHeight, graphHeightOffset) {
const maxValue = const allValues = queries.reduce((allQueryResults, query) => allQueryResults.concat(
d3.max(queries.map(query => ( query.result.reduce((allResults, result) => allResults.concat(result.values), []),
d3.max(query.result.map(resultSet => ( ), []);
d3.max(resultSet.values.map(d => d.value))
))) const xDom = d3.extent(allValues, d => d.time);
))); const yDom = [0, d3.max(allValues.map(d => d.value))];
return queries.reduce((series, query, index) => { return queries.reduce((series, query, index) => {
const lineStyle = defaultStyleOrder[index % defaultStyleOrder.length]; const lineStyle = defaultStyleOrder[index % defaultStyleOrder.length];
return series.concat( return series.concat(
queryTimeSeries(query, graphWidth, graphHeight, graphHeightOffset, maxValue, lineStyle), queryTimeSeries(query, graphWidth, graphHeight, graphHeightOffset, xDom, yDom, lineStyle),
); );
}, []); }, []);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment