Skip to content

Commit

Permalink
fix(annotations): fix alignment at the edges (#641)
Browse files Browse the repository at this point in the history
This commit fixed the alignment of rect and line annotations near the edge of a data domain. It aligns the x/y position specified by the `dataValues` of the annotation to the domain of the chart.

BREAKING CHANGE: In the rectangular annotation, the y0 parameter of the coordinates now refers to the minimum value and the y1 value refers to the maximum value of the y domain.

fix #586
  • Loading branch information
markov00 authored Apr 28, 2020
1 parent f411771 commit 43c5a59
Show file tree
Hide file tree
Showing 60 changed files with 1,894 additions and 1,161 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ test/failure-screenshots/**/*.png

reports/
tmp/
.temp/
dist/
coverage/
.out/
Expand Down
34 changes: 6 additions & 28 deletions .playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,22 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Charts Playground</title>
<title>Elastic-Charts Playground</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta http-equiv="X-UA-Compatible" content="ie=edge" />
<title>Document</title>
<style>
html,
body {
background: blanchedalmond !important;
/*margin-left: 8px !important;*/
/*padding: 8px !important;*/
/*height: 100%;*/
/*width: 2000px;
}
#root {
position: absolute;
/*
top: 0;
left: 0;
*/
/* width: 100%;
height: 100%;*/
/* overflow-x: hidden; */
}
.chart {
background: white;
/*display: inline-block;
position: relative;
*/
width: 100%;
height: 500px;
overflow: auto;
width: 800px;
height: 300px;
margin: 20px;
}

.testing {
background: aquamarine;
position: relative;
width: 100vw;
overflow: auto;
label {
display: block;
}
</style>
</head>
Expand Down
5 changes: 0 additions & 5 deletions .playground/playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,9 @@
* under the License. */

import React from 'react';
import { XYChartElementEvent, PartitionElementEvent } from '../src';
import { example } from '../stories/treemap/6_custom_style';

export class Playground extends React.Component {
onElementClick = (elements: (XYChartElementEvent | PartitionElementEvent)[]) => {
// eslint-disable-next-line no-console
console.log(elements);
};
render() {
return (
<div className="testing">
Expand Down
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.
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@ import { DEFAULT_ANNOTATION_LINE_STYLE } from '../../../utils/themes/theme';
import { Dimensions } from '../../../utils/dimensions';
import { GroupId } from '../../../utils/ids';
import { Scale, ScaleType, ScaleContinuous } from '../../../scales';
import { computeLineAnnotationDimensions, AnnotationLineProps } from './line_annotation_tooltip';
import { ChartTypes } from '../..';
import { SpecTypes } from '../../../specs/settings';
import { computeLineAnnotationDimensions } from './line/dimensions';
import { AnnotationLineProps } from './line/types';
import { ChartTypes } from '../..';

describe('annotation marker', () => {
const groupId = 'foo-group';
Expand Down Expand Up @@ -75,7 +76,6 @@ describe('annotation marker', () => {
yScales,
xScale,
Position.Left,
0,
false,
);
const expectedDimensions: AnnotationLineProps[] = [
Expand Down Expand Up @@ -130,7 +130,6 @@ describe('annotation marker', () => {
yScales,
xScale,
Position.Left,
0,
false,
);
const expectedDimensions: AnnotationLineProps[] = [
Expand Down Expand Up @@ -184,7 +183,6 @@ describe('annotation marker', () => {
yScales,
xScale,
Position.Bottom,
0,
false,
);
const expectedDimensions: AnnotationLineProps[] = [
Expand Down
61 changes: 0 additions & 61 deletions src/chart_types/xy_chart/annotations/annotation_tooltip.ts

This file was deleted.

Loading

0 comments on commit 43c5a59

Please sign in to comment.