Skip to content

Commit

Permalink
feat(annotation): enable marker positioning on LineAnnotation (opense…
Browse files Browse the repository at this point in the history
…arch-project#737)

This commit allows changing the marker position on a line annotation. The position is absolute on
the screen space and doesn't depend on the chart rotation

fix opensearch-project#701
  • Loading branch information
markov00 authored Jul 6, 2020
1 parent 9c49c90 commit 2fa5a0b
Show file tree
Hide file tree
Showing 18 changed files with 465 additions and 751 deletions.
1 change: 1 addition & 0 deletions packages/osd-charts/api/charts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -785,6 +785,7 @@ export type LineAnnotationSpec = BaseAnnotationSpec<typeof AnnotationTypes.Line,
width: number;
height: number;
};
markerPosition?: Position;
hideLines?: boolean;
hideLinesTooltips?: boolean;
zIndex?: number;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
import { MockSeriesSpec, MockAnnotationSpec, MockGlobalSpec } from '../../../../mocks/specs';
import { MockStore } from '../../../../mocks/store';
import { ScaleType } from '../../../../scales/constants';
import { Position } from '../../../../utils/commons';
import { computeAnnotationDimensionsSelector } from '../../state/selectors/compute_annotations';
import { AnnotationDomainTypes } from '../../utils/specs';

Expand Down Expand Up @@ -51,11 +50,10 @@ function expectAnnotationAtPosition(
const annotations = computeAnnotationDimensionsSelector(store.getState());
expect(annotations.get(annotation.id)).toEqual([
{
anchor: { left: expectedLinePosition, position: 'bottom', top: 100 },
details: { detailsText: undefined, headerText: `${indexPosition}` },
linePathPoints: {
start: { x1: expectedLinePosition, y1: 100 },
end: { x2: expectedLinePosition, y2: 0 },
start: { x1: expectedLinePosition, y1: 0 },
end: { x2: expectedLinePosition, y2: 100 },
},
marker: undefined,
},
Expand Down Expand Up @@ -145,14 +143,9 @@ describe('Render vertical line annotation within', () => {
const annotations = computeAnnotationDimensionsSelector(store.getState());
expect(annotations.get(annotation.id)).toEqual([
{
anchor: {
top: 100,
left: 95,
position: Position.Bottom,
},
linePathPoints: {
start: { x1: 95, y1: 100 },
end: { x2: 95, y2: 0 },
start: { x1: 95, y1: 0 },
end: { x2: 95, y2: 100 },
},
details: { detailsText: 'foo', headerText: '9.5' },
marker: undefined,
Expand Down
Loading

0 comments on commit 2fa5a0b

Please sign in to comment.