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

refactor: use redux in favour of mobx #281

Merged
merged 71 commits into from
Nov 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
b8953c9
refactor: move to redux and add selectors
markov00 Jul 29, 2019
a98b518
fix(test): annotations
markov00 Sep 18, 2019
952c61d
fix(tests): crosshair_utils
markov00 Sep 18, 2019
0ec70d4
fix(tests): domains
markov00 Sep 18, 2019
16467ed
fix(tests): legend
markov00 Sep 18, 2019
e487cc8
fix(tests): rendering
markov00 Sep 18, 2019
d5ce8b9
fix(test): xy_chart utils
markov00 Sep 18, 2019
8dae3bf
fix(tests): tooltip
markov00 Sep 19, 2019
11c3f06
fix: grid
markov00 Sep 19, 2019
07ccac2
fix(tests): rendering props
markov00 Sep 19, 2019
21e748b
fix(testing) store utils
markov00 Sep 20, 2019
31ae166
fix(tests) chart_state.timestamps
markov00 Sep 20, 2019
9d9893e
refactor: add element over/out listeners
markov00 Sep 30, 2019
af4043a
refactor: reenabled tests for settings and parser
markov00 Sep 30, 2019
7de17fd
refactor(listeners): refactor on element listener callers
markov00 Oct 2, 2019
0e47af0
refactor(reactive-chart): enable multilayer rendering
markov00 Oct 2, 2019
7f62c5f
fix(annotations): fix error on rendering mixed annotations
markov00 Oct 3, 2019
b010b03
refactor(annotations): split utilities into multiple files
markov00 Oct 4, 2019
9128dcd
refactor(state): split states between chart types
markov00 Oct 4, 2019
322a1e1
refactor: rename store to state
markov00 Oct 4, 2019
605abd1
refactor: handle specs update
markov00 Oct 11, 2019
2d0dc84
fix: tooltip position
markov00 Oct 11, 2019
721cb08
fix: histogram mode
markov00 Oct 11, 2019
35623e6
refactor: render chart after legend
markov00 Oct 15, 2019
fffc388
fix: duplicate axis
markov00 Oct 15, 2019
0976a6d
refactor: fix debug and top/bottom legend
markov00 Oct 15, 2019
5fbcea2
refactor: clean ups
markov00 Oct 15, 2019
68fa3b6
refactor: restore previous configurations
markov00 Oct 15, 2019
81713cb
refactor: restore previous configurations
markov00 Oct 15, 2019
6b19f9c
refactor: removed initial piechart implementation
markov00 Oct 15, 2019
e80fd19
fix: legend rendered action correctly
markov00 Nov 12, 2019
cb8a45a
Merge branch 'master' into nct_api
markov00 Nov 13, 2019
641b6f7
feat: enable cursor pointer
markov00 Nov 13, 2019
f30a5a4
fix: improved legend performance
markov00 Nov 14, 2019
9e0b04e
fix: brush and click
markov00 Nov 15, 2019
0018c5a
fix: reenable external pointer events
markov00 Nov 18, 2019
da8f644
test: unskip parser and interaction tests
markov00 Nov 18, 2019
93ce677
Merge branch 'master' into nct_api
markov00 Nov 19, 2019
59d1f7c
chore: check and clean annotations
markov00 Nov 19, 2019
7272466
chore: check and clean domains
markov00 Nov 19, 2019
5e92b52
chore: check and clean specs
markov00 Nov 19, 2019
ccfcebf
chore: check and clean tooltips
markov00 Nov 19, 2019
e52f14f
Merge branch 'master' into nct_api
markov00 Nov 19, 2019
cf1a93b
build: update yarn.lock
markov00 Nov 20, 2019
50c6997
fix(legend): reenable legend listeners and add tests
markov00 Nov 21, 2019
c18ba7e
fix: enable brushend events and fix brush extens on bars
markov00 Nov 21, 2019
fa90c37
build: remove mobx and mobx-react
markov00 Nov 21, 2019
0d93c57
fix: reenable onRenderChange
markov00 Nov 21, 2019
e585909
chore: clean up unused functions and exports
markov00 Nov 21, 2019
5ef2d5a
fix: removed unused interface
markov00 Nov 21, 2019
e9e7c39
fix: legend size computed also without last value
markov00 Nov 21, 2019
f6e3767
test: update VRT snapshots
markov00 Nov 22, 2019
59b6b1e
Merge branch 'master' into nct_api
markov00 Nov 22, 2019
ae398b5
refactor: remove useless mapStateToProps and mapDispatchToProps
markov00 Nov 22, 2019
e1a615c
test: update baseline for png export
markov00 Nov 25, 2019
159f10c
fix: decuple specs types from redux
markov00 Nov 25, 2019
5fc93cf
fix: add chartTypes type
markov00 Nov 26, 2019
a254056
refactor: removed unused file and commented code
markov00 Nov 26, 2019
a697b92
refactor: remove key and rename map index variable name on annotations
markov00 Nov 26, 2019
95276b6
refactor: add Geometries type
markov00 Nov 26, 2019
555db69
refactor: remove eslint disable
markov00 Nov 26, 2019
5699278
refactor: add enums to specTypes and seriesType
markov00 Nov 26, 2019
018883b
test: prefer skip over comment out
markov00 Nov 26, 2019
76e7d34
refactor: removed commented console.logs
markov00 Nov 26, 2019
4c9c7a0
refactor: move duplicated code into utility function
markov00 Nov 26, 2019
7d74a5a
refactor: removed unused file
markov00 Nov 26, 2019
14d7a94
refactor: remove fp-ts lib
markov00 Nov 26, 2019
9b0bb9f
refactor: line and rect annotation cleanup
markov00 Nov 26, 2019
428151a
refactor: better deconstruct
markov00 Nov 26, 2019
143276c
fix(annotationTooltip): use pointer pos and hide tooltip on annotation
markov00 Nov 26, 2019
874ebd7
Merge branch 'master' into nct_api
markov00 Nov 26, 2019
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
15 changes: 4 additions & 11 deletions .playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -19,22 +19,15 @@
position: absolute;
top: 0px;
left: 0px;
width: 100%;
}
.chart {
background: white;
display: inline-block;
position: relative;
width: 900px;
height: 600px;
margin: 10px;
/* overflow: hidden; */
}
button {
padding: 10px !important;
background: black !important;
border: 1px solid white !important;
color: white !important;
margin: 4px !important;
width: 1000px;
height: 350px;
margin: 0px;
}
</style>
</head>
Expand Down
32 changes: 28 additions & 4 deletions .playground/playgroud.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,13 @@ import {
getSpecId,
Position,
ScaleType,
HistogramBarSeries,
Settings,
LIGHT_THEME,
niceTimeFormatter,
LineAnnotation,
AnnotationDomainTypes,
BarSeries,
RectAnnotation,
} from '../src';
import { KIBANA_METRICS } from '../src/utils/data_samples/test_dataset_kibana';
export class Playground extends React.Component {
Expand Down Expand Up @@ -39,7 +42,7 @@ export class Playground extends React.Component {
}
};
render() {
const data = KIBANA_METRICS.metrics.kibana_os_load[0].data.slice(0, 100);
const data = KIBANA_METRICS.metrics.kibana_os_load[0].data.slice(0, 7);

return (
<>
Expand All @@ -53,8 +56,29 @@ export class Playground extends React.Component {
tickFormat={niceTimeFormatter([data[0][0], data[data.length - 1][0]])}
/>
<Axis id={getAxisId('count')} position={Position.Left} />

<HistogramBarSeries
<LineAnnotation
id="line annotation"
dataValues={[
{
dataValue: data[5][0],
details: 'hello tooltip',
},
]}
domainType={AnnotationDomainTypes.XDomain}
marker={<div style={{ width: 10, height: 10, background: 'red' }} />}
/>
<RectAnnotation
id="rect annotation"
dataValues={[
{
coordinates: {
x1: data[3][0],
},
details: 'hello',
},
]}
/>
<BarSeries
id={getSpecId('series bars chart')}
xScaleType={ScaleType.Linear}
yScaleType={ScaleType.Linear}
Expand Down
1 change: 1 addition & 0 deletions .playground/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ module.exports = {
exclude: /node_modules/,
options: {
configFile: 'tsconfig.json',
transpileOnly: true,
markov00 marked this conversation as resolved.
Show resolved Hide resolved
},
},
{
Expand Down
21 changes: 10 additions & 11 deletions integration/page_objects/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ class CommonPage {

return `${baseUrl}?${query}${query ? '&' : ''}knob-debug=false`;
}
async getBoundingClientRect(selector = '.echChart[data-ech-render-complete=true]') {
async getBoundingClientRect(selector = '.echChart') {
nickofthyme marked this conversation as resolved.
Show resolved Hide resolved
return await page.evaluate((selector) => {
const element = document.querySelector(selector);

Expand All @@ -37,10 +37,7 @@ class CommonPage {
/**
* Capture screenshot or chart element only
*/
async screenshotDOMElement(
selector = '.echChart[data-ech-render-complete=true]',
opts?: ScreenshotDOMElementOptions,
) {
async screenshotDOMElement(selector = '.echChart', opts?: ScreenshotDOMElementOptions) {
const padding: number = opts && opts.padding ? opts.padding : 0;
const path: string | undefined = opts && opts.path ? opts.path : undefined;
const rect = await this.getBoundingClientRect(selector);
Expand All @@ -56,10 +53,7 @@ class CommonPage {
});
}

async moveMouseRelativeToDOMElement(
mousePosition: { x: number; y: number },
selector = '.echChart[data-ech-render-complete=true]',
) {
async moveMouseRelativeToDOMElement(mousePosition: { x: number; y: number }, selector = '.echChart') {
const chartContainer = await this.getBoundingClientRect(selector);
await page.mouse.move(chartContainer.left + mousePosition.x, chartContainer.top + mousePosition.y);
}
Expand Down Expand Up @@ -113,9 +107,14 @@ class CommonPage {
async loadChartFromURL(url: string) {
const cleanUrl = CommonPage.parseUrl(url);
await page.goto(cleanUrl);
this.waitForElement();
}

async waitForElement(selector = '.echChart[data-ech-render-complete=true]', timeout = 10000) {
/**
* Wait for an element to be on the DOM
* @param {string} [selector] the DOM selector to wait for, default to '.echChartStatus[data-ech-render-complete=true]'
* @param {number} [timeout] - the timeout for the operation, default to 10000ms
*/
async waitForElement(selector = '.echChartStatus[data-ech-render-complete=true]', timeout = 10000) {
await page.waitForSelector(selector, { timeout });
}
}
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.
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.
11 changes: 7 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,11 @@
"@types/puppeteer": "^1.19.1",
"@types/react": "^16.8.5",
"@types/react-dom": "^16.8.2",
"@types/react-redux": "^7.1.1",
markov00 marked this conversation as resolved.
Show resolved Hide resolved
"@types/seedrandom": "^2.4.28",
"@types/storybook__addon-actions": "^3.4.3",
"@types/storybook__addon-info": "^4.1.2",
"@types/storybook__addon-knobs": "^5.0.3",
"@types/storybook__addon-knobs": "5.0.4",
"@types/storybook__react": "^4.0.2",
"@types/url-parse": "^1.4.3",
"@types/uuid": "^3.4.4",
Expand Down Expand Up @@ -126,6 +127,7 @@
"puppeteer": "^1.20.0",
"react-docgen-typescript-loader": "^3.0.1",
"react-docgen-typescript-webpack-plugin": "^1.1.0",
"redux-devtools-extension": "^2.13.8",
"sass-graph": "^3.0.4",
"sass-loader": "^7.1.0",
"seedrandom": "^3.0.5",
Expand All @@ -147,16 +149,17 @@
"d3-collection": "^1.0.7",
"d3-scale": "^1.0.7",
"d3-shape": "^1.3.4",
"fp-ts": "^1.14.2",
"konva": "^2.6.0",
"mobx": "^4.9.2",
"mobx-react": "^5.4.3",
"newtype-ts": "^0.2.4",
"prop-types": "^15.7.2",
"re-reselect": "^3.4.0",
monfera marked this conversation as resolved.
Show resolved Hide resolved
monfera marked this conversation as resolved.
Show resolved Hide resolved
"react": "^16.8.3",
"react-dom": "^16.8.3",
"react-konva": "16.8.3",
"react-redux": "^7.1.0",
"react-spring": "^8.0.8",
"redux": "^4.0.4",
"reselect": "^4.0.0",
"resize-observer-polyfill": "^1.5.1",
"ts-debounce": "^1.0.0",
"uuid": "^3.3.2"
Expand Down
3 changes: 2 additions & 1 deletion scripts/custom_matchers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ type MatcherParameters<T extends (this: any, received: any, ...args: any[]) => a
: never;

declare global {
namespace jest { // eslint-disable-line
// eslint-disable-next-line
namespace jest {
interface Matchers<R> {
/**
* Expect array to be filled with value, and optionally length
Expand Down
9 changes: 9 additions & 0 deletions src/chart_types/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { $Values } from 'utility-types';

export const ChartTypes = Object.freeze({
Global: 'global' as 'global',
Pie: 'pie' as 'pie',
XYAxis: 'xy_axis' as 'xy_axis',
});
nickofthyme marked this conversation as resolved.
Show resolved Hide resolved

export type ChartTypes = $Values<typeof ChartTypes>;
9 changes: 9 additions & 0 deletions src/chart_types/specs.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
export {
AreaSeries,
BarSeries,
LineSeries,
Axis,
LineAnnotation,
RectAnnotation,
HistogramBarSeries,
} from './xy_chart/specs';
58 changes: 18 additions & 40 deletions src/chart_types/xy_chart/annotations/annotation_marker.test.tsx
Original file line number Diff line number Diff line change
@@ -1,20 +1,16 @@
import * as React from 'react';

import { AnnotationDomainTypes, AnnotationSpec, Position, Rotation } from '../utils/specs';
import { AnnotationDomainTypes, AnnotationSpec, Position, Rotation, SpecTypes, AnnotationTypes } from '../utils/specs';
import { DEFAULT_ANNOTATION_LINE_STYLE } from '../../../utils/themes/theme';
import { Dimensions } from '../../../utils/dimensions';
import { getAnnotationId, getGroupId, GroupId } from '../../../utils/ids';
import { GroupId } from '../../../utils/ids';
import { ScaleContinuous } from '../../../utils/scales/scale_continuous';
import { Scale, ScaleType } from '../../../utils/scales/scales';
import {
computeLineAnnotationDimensions,
isWithinLineMarkerBounds,
AnnotationMarker,
AnnotationLineProps,
} from './annotation_utils';
import { computeLineAnnotationDimensions, AnnotationLineProps } from './line_annotation_tooltip';
import { ChartTypes } from '../..';

describe('annotation marker', () => {
const groupId = getGroupId('foo-group');
const groupId = 'foo-group';

const minRange = 0;
const maxRange = 100;
Expand All @@ -41,10 +37,12 @@ describe('annotation marker', () => {
test('should compute line annotation dimensions with marker if defined (y domain)', () => {
const chartRotation: Rotation = 0;

const annotationId = getAnnotationId('foo-line');
const id = 'foo-line';
const lineAnnotation: AnnotationSpec = {
annotationType: 'line',
annotationId,
chartType: ChartTypes.XYAxis,
specType: SpecTypes.Annotation,
annotationType: AnnotationTypes.Line,
id,
domainType: AnnotationDomainTypes.YDomain,
dataValues: [{ dataValue: 2, details: 'foo' }],
groupId,
Expand Down Expand Up @@ -95,10 +93,11 @@ describe('annotation marker', () => {
test('should compute line annotation dimensions with marker if defined (y domain: 180 deg rotation)', () => {
const chartRotation: Rotation = 180;

const annotationId = getAnnotationId('foo-line');
const lineAnnotation: AnnotationSpec = {
annotationType: 'line',
annotationId,
chartType: ChartTypes.XYAxis,
specType: SpecTypes.Annotation,
annotationType: AnnotationTypes.Line,
id: 'foo-line',
domainType: AnnotationDomainTypes.YDomain,
dataValues: [{ dataValue: 2, details: 'foo' }],
groupId,
Expand Down Expand Up @@ -148,10 +147,11 @@ describe('annotation marker', () => {
test('should compute line annotation dimensions with marker if defined (x domain)', () => {
const chartRotation: Rotation = 0;

const annotationId = getAnnotationId('foo-line');
const lineAnnotation: AnnotationSpec = {
annotationType: 'line',
annotationId,
chartType: ChartTypes.XYAxis,
specType: SpecTypes.Annotation,
annotationType: AnnotationTypes.Line,
id: 'foo-line',
domainType: AnnotationDomainTypes.XDomain,
dataValues: [{ dataValue: 2, details: 'foo' }],
groupId,
Expand Down Expand Up @@ -197,26 +197,4 @@ describe('annotation marker', () => {
];
expect(dimensions).toEqual(expectedDimensions);
});

test('should compute if a point is within an annotation line marker bounds', () => {
const marker: AnnotationMarker = {
icon: <div />,
color: 'custom-color',
position: { top: 0, left: 0 },
dimension: { width: 10, height: 10 },
};
expect(isWithinLineMarkerBounds({ x: -1, y: 0 }, marker)).toBe(false);

expect(isWithinLineMarkerBounds({ x: 0, y: -1 }, marker)).toBe(false);

expect(isWithinLineMarkerBounds({ x: 0, y: 0 }, marker)).toBe(true);

expect(isWithinLineMarkerBounds({ x: 10, y: 10 }, marker)).toBe(true);

expect(isWithinLineMarkerBounds({ x: 11, y: 10 }, marker)).toBe(false);

expect(isWithinLineMarkerBounds({ x: 11, y: 10 }, { ...marker, position: { top: 0, left: 1 } })).toBe(true);

expect(isWithinLineMarkerBounds({ x: 15, y: 15 }, { ...marker, position: { top: 10, left: 10 } })).toBe(true);
});
});
Loading