Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import {
YAxis,
HorizontalGridLines,
LineSeries,
AreaSeries
AreaSeries,
VerticalRectSeries
} from 'react-vis';
import PropTypes from 'prop-types';
import React, { PureComponent } from 'react';
Expand Down Expand Up @@ -56,13 +57,14 @@ class StaticPlot extends PureComponent {
case 'areaMaxHeight':
const yMax = last(plotValues.yTickValues);
const data = serie.data.map(p => ({
x0: p.x0,
x: p.x,
y0: 0,
y: p.y ? yMax : null
y: yMax
}));

return (
<AreaSeries
<VerticalRectSeries
Copy link
Copy Markdown
Contributor Author

@sorenlouv sorenlouv Nov 24, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line might be the biggest change in this PR: going from AreaSeries to RectSeries.
An AreaSeries take points like { x, y0, y } - so no horisontal width. To set the horisontal width I used to add a starting point, an ending point, and then padded with a null point to avoid connecting the area with the following area (if there are no null values between them two points will be connected with a line). Pretty hacky:

acc.push({ x: p.x, y: 1 });
if (nextPoint.x == null || nextPoint.x > endX) {
acc.push(
{
x: endX,
y: 1
},
{
x: getX(p.x, 2)
}
);
}
return acc;
}, []);

RectSeries take points like { x0, x, y0, y }. So the hacky stuff can go away.

getNull={d => d.y !== null}
key={serie.title}
xType="time"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ import {
getEmptySerie
} from '../../../../../store/selectors/chartSelectors';

function getXValueByIndex(index) {
return responseWithData.responseTimes.avg[index].x;
}

describe('when response has data', () => {
let wrapper;
let onHover;
Expand All @@ -26,7 +30,6 @@ describe('when response has data', () => {

beforeEach(() => {
const series = getResponseTimeSeries(responseWithData);

onHover = jest.fn();
onMouseLeave = jest.fn();
onSelectionEnd = jest.fn();
Expand Down Expand Up @@ -166,7 +169,7 @@ describe('when response has data', () => {
});

it('should call onHover', () => {
expect(onHover).toHaveBeenCalledWith(responseWithData.dates[index]);
expect(onHover).toHaveBeenCalledWith(getXValueByIndex(index));
});
});

Expand All @@ -178,9 +181,9 @@ describe('when response has data', () => {
});

// Simulate hovering over multiple buckets
wrapper.setProps({ hoverX: responseWithData.dates[13] });
wrapper.setProps({ hoverX: responseWithData.dates[14] });
wrapper.setProps({ hoverX: responseWithData.dates[15] });
wrapper.setProps({ hoverX: getXValueByIndex(13) });
wrapper.setProps({ hoverX: getXValueByIndex(14) });
wrapper.setProps({ hoverX: getXValueByIndex(15) });
});

it('should display tooltip', () => {
Expand Down
Loading