Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(domain): custom domain should not filter data #1181

Merged
merged 5 commits into from
Jun 3, 2021
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
13 changes: 10 additions & 3 deletions src/chart_types/xy_chart/renderer/canvas/lines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,16 @@ export function renderLines(ctx: CanvasRenderingContext2D, props: LineGeometries
const { seriesLineStyle, seriesPointStyle, points } = line;

if (seriesLineStyle.visible) {
withPanelTransform(ctx, panel, rotation, renderingArea, (ctx) => {
renderLine(ctx, line, sharedStyle, clippings, highlightedLegendItem);
});
withPanelTransform(
ctx,
panel,
rotation,
renderingArea,
(ctx) => {
renderLine(ctx, line, sharedStyle, clippings, highlightedLegendItem);
},
{ area: clippings, shouldClip: true },
);
Comment on lines +52 to +61
Copy link
Collaborator

Choose a reason for hiding this comment

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

So currently the lines never needed to be clipped because of filtering the points before creating the path?

Copy link
Collaborator

@nickofthyme nickofthyme Jun 3, 2021

Choose a reason for hiding this comment

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

Ya looks like that's the case, I think we should have always clipped the line. See the story below when you have really sharp splines.

Screen.Recording.2021-06-03.at.10.02.54.AM.mp4

Copy link
Member Author

Choose a reason for hiding this comment

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

Exactly, I haven't added the clipping for lines because of this case, but we are still clipping the areas for example, so this will also align the current rendering between these two chart types

}

const visiblePoints = seriesPointStyle.visible ? points : points.filter(({ orphan }) => orphan);
Expand Down
6 changes: 3 additions & 3 deletions src/chart_types/xy_chart/rendering/rendering.bubble.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -748,14 +748,14 @@ describe('Rendering points - bubble', () => {
geometries: { bubbles },
geometriesIndex,
} = computeSeriesGeometriesSelector(store.getState());
test('Can render two points', () => {
test('Should render 3 points', () => {
const [
{
value: { points },
},
] = bubbles;
// will not render the 3rd point that is out of y domain
expect(points.length).toBe(2);
// will not render the 4th point that is out of x domain
expect(points.length).toBe(3);
// will keep the 3rd point as an indexedGeometry
expect(geometriesIndex.size).toEqual(3);
expect(points[0]).toEqual(
Expand Down
12 changes: 6 additions & 6 deletions src/chart_types/xy_chart/rendering/rendering.lines.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -680,15 +680,15 @@ describe('Rendering points - line', () => {
geometriesIndex,
} = computeSeriesGeometriesSelector(store.getState());

test('Can render a split line', () => {
test('should render a split line', () => {
const [{ value: renderedLine }] = lines;
expect(renderedLine.line.split('M').length - 1).toBe(3);
expect(renderedLine.color).toBe('red');
expect(renderedLine.seriesIdentifier.seriesKeys).toEqual([1]);
expect(renderedLine.seriesIdentifier.specId).toEqual(SPEC_ID);
expect(renderedLine.transform).toEqual({ x: 0, y: 0 });
});
test('Can render points', () => {
test('should render points', () => {
const [
{
value: { points },
Expand All @@ -709,7 +709,7 @@ describe('Rendering points - line', () => {
expect((zeroValueIndexdGeometry[0] as PointGeometry).radius).toBe(LIGHT_THEME.lineSeriesStyle.point.radius);
});
});
describe('Remove points datum is not in domain', () => {
describe('Removing out-of-domain points', () => {
const pointSeriesSpec = MockSeriesSpec.line({
id: SPEC_ID,
// groupId: GROUP_ID,
Expand All @@ -736,14 +736,14 @@ describe('Rendering points - line', () => {
geometries: { lines },
geometriesIndex,
} = computeSeriesGeometriesSelector(store.getState());
test('Can render two points', () => {
test('should render 3 points', () => {
const [
{
value: { points },
},
] = lines;
// will not render the 3rd point that is out of y domain
expect(points.length).toBe(2);
// will not render the 4th point is out of the x domain
expect(points.length).toBe(3);
// will keep the 3rd point as an indexedGeometry
expect(geometriesIndex.size).toEqual(3);
expect(points[0]).toEqual(
Expand Down
3 changes: 1 addition & 2 deletions src/chart_types/xy_chart/rendering/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ export function isYValueDefinedFn(yScale: Scale, xScale: Scale): YDefinedFn {
return (
yValue !== null &&
!((isLogScale && domainPolarity >= 0 && yValue <= 0) || (domainPolarity < 0 && yValue >= 0)) &&
xScale.isValueInDomain(datum.x) &&
yScale.isValueInDomain(yValue)
xScale.isValueInDomain(datum.x)
markov00 marked this conversation as resolved.
Show resolved Hide resolved
);
};
}
Expand Down
2 changes: 1 addition & 1 deletion stories/axes/8_custom_domain.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export const Example = () => {

const lineDomain = {
min: number('Line min', 0, options, 'Line'),
max: number('Line max', 10, options, 'Line'),
max: number('Line max', 8, options, 'Line'),
};

const ticksOptions = {
Expand Down