From 328480f6d8f76049965454717798ac196423899e Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Fri, 1 Jun 2018 12:08:33 +0200
Subject: [PATCH 01/68] First version of barchart/histogram with examples
---
.../src/views/xy_chart_series/bar_series.js | 12 -
.../xy_chart_series/horizontal_bar_series.js | 23 +
.../xy_chart_series/horizontal_rect_series.js | 22 +
.../views/xy_chart_series/series_example.js | 163 +-
.../stacked_horizontal_bar_series.js | 78 +
.../stacked_vertical_bar_series.js | 78 +
.../xy_chart_series/vertical_bar_series.js | 24 +
.../xy_chart_series/vertical_rect_series.js | 23 +
src/components/index.js | 7 +-
.../xy_chart/__snapshots__/area.test.js.snap | 62 -
.../xy_chart/__snapshots__/bar.test.js.snap | 6772 -----------------
.../xy_chart/__snapshots__/chart.test.js.snap | 1 -
.../xy_chart/__snapshots__/line.test.js.snap | 54 -
src/components/xy_chart/chart.js | 15 +-
.../xy_chart/horizontal_bar_series.js | 44 +
.../xy_chart/horizontal_rect_series.js | 44 +
src/components/xy_chart/index.js | 14 +-
.../xy_chart/vertical_bar_series.js | 42 +
...ar.test.js => vertical_bar_series.test.js} | 12 +-
.../{bar.js => vertical_rect_series.js} | 12 +-
20 files changed, 569 insertions(+), 6933 deletions(-)
delete mode 100644 src-docs/src/views/xy_chart_series/bar_series.js
create mode 100644 src-docs/src/views/xy_chart_series/horizontal_bar_series.js
create mode 100644 src-docs/src/views/xy_chart_series/horizontal_rect_series.js
create mode 100644 src-docs/src/views/xy_chart_series/stacked_horizontal_bar_series.js
create mode 100644 src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js
create mode 100644 src-docs/src/views/xy_chart_series/vertical_bar_series.js
create mode 100644 src-docs/src/views/xy_chart_series/vertical_rect_series.js
delete mode 100644 src/components/xy_chart/__snapshots__/bar.test.js.snap
create mode 100644 src/components/xy_chart/horizontal_bar_series.js
create mode 100644 src/components/xy_chart/horizontal_rect_series.js
create mode 100644 src/components/xy_chart/vertical_bar_series.js
rename src/components/xy_chart/{bar.test.js => vertical_bar_series.test.js} (89%)
rename src/components/xy_chart/{bar.js => vertical_rect_series.js} (78%)
diff --git a/src-docs/src/views/xy_chart_series/bar_series.js b/src-docs/src/views/xy_chart_series/bar_series.js
deleted file mode 100644
index d2b31cd1d096..000000000000
--- a/src-docs/src/views/xy_chart_series/bar_series.js
+++ /dev/null
@@ -1,12 +0,0 @@
-import React from 'react';
-
-import { EuiXYChart, EuiBar } from '../../../../src/components';
-
-export default () => (
-
-
-
-);
\ No newline at end of file
diff --git a/src-docs/src/views/xy_chart_series/horizontal_bar_series.js b/src-docs/src/views/xy_chart_series/horizontal_bar_series.js
new file mode 100644
index 000000000000..8be242d688f5
--- /dev/null
+++ b/src-docs/src/views/xy_chart_series/horizontal_bar_series.js
@@ -0,0 +1,23 @@
+import React from 'react';
+
+import { EuiXYChart, EuiHorizontalBarSeries } from '../../../../src/components';
+
+const data = [
+ { x: 3, y: 'A' },
+ { x: 1, y: 'B' },
+ { x: 5, y: 'C' },
+ { x: 2, y: 'D' },
+ { x: 1, y: 'E' }
+]
+export default () => (
+
+
+
+);
diff --git a/src-docs/src/views/xy_chart_series/horizontal_rect_series.js b/src-docs/src/views/xy_chart_series/horizontal_rect_series.js
new file mode 100644
index 000000000000..0c5284747c72
--- /dev/null
+++ b/src-docs/src/views/xy_chart_series/horizontal_rect_series.js
@@ -0,0 +1,22 @@
+import React from 'react';
+
+import { EuiXYChart, EuiHorizontalRectSeries } from '../../../../src/components';
+
+const data = [
+ { x: 3, y: 0, y0: 1 },
+ { x: 1, y: 1, y0: 2 },
+ { x: 5, y: 2, y0: 3 },
+ { x: 2, y: 3, y0: 4 },
+ { x: 1, y: 4, y0: 5 },
+]
+export default () => (
+
+
+
+);
diff --git a/src-docs/src/views/xy_chart_series/series_example.js b/src-docs/src/views/xy_chart_series/series_example.js
index ac26a419e457..6a3ce1a71118 100644
--- a/src-docs/src/views/xy_chart_series/series_example.js
+++ b/src-docs/src/views/xy_chart_series/series_example.js
@@ -1,12 +1,17 @@
import React from 'react';
import { GuideSectionTypes } from '../../components';
import LineSeriesExample from './line_series';
-import BarSeriesExample from './bar_series';
+import VerticalBarSeriesExample from './vertical_bar_series';
+import HorizontalBarSeriesExample from './horizontal_bar_series';
+import StackedHorizontalBarSeriesExample from './stacked_horizontal_bar_series';
+import StackedVerticalBarSeriesExample from './stacked_vertical_bar_series';
+import VerticalRectSeriesExample from './vertical_rect_series';
+import HorizontalRectSeriesExample from './horizontal_rect_series';
import AreaSeriesExample from './area_series';
-import { EuiCode, EuiBar, EuiLine, EuiArea } from '../../../../src/components';
+import { EuiCode, EuiVerticalBarSeries, EuiHorizontalBarSeries, EuiLine, EuiArea } from '../../../../src/components';
export const XYChartSeriesExample = {
- title: 'XYChart Series',
+ title: 'XYChart Series',
sections: [
{
title: 'Line Series',
@@ -65,19 +70,21 @@ export const XYChartSeriesExample = {
)
},
{
- title: 'Bar Series',
+ title: 'Vertical Bar Chart',
text: (
- When no data is provided to EuiXYChart, an empty state is displayed
+ Use EuiXYChart with EuiVerticalBarSeries for displaying
+ vertical bar charts. Use the appropriate xType props to match your
+ x value scale. Available values are: ordinal ,linear
),
- props: { EuiBar },
+ props: { EuiVerticalBarSeries },
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./bar_series')
+ code: require('!!raw-loader!./vertical_bar_series')
},
{
type: GuideSectionTypes.HTML,
@@ -86,9 +93,147 @@ export const XYChartSeriesExample = {
],
demo: (
-
+
)
- }
+ },
+ {
+ title: 'Horizontal Bar Chart',
+ text: (
+
+
+ Use EuiXYChart with EuiHorizontalBarSeries for displaying
+ horizontal bar charts. Use the appropriate yType props to match your
+ y value scale. Available values are: ordinal ,linear
+
+
+ ),
+ props: { EuiHorizontalBarSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./horizontal_bar_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ {
+ title: 'Vertical Histogram',
+ text: (
+
+
+ Use EuiXYChart with EuiVerticalRectSeries for displaying
+ vertical histograms.
+
+
+ ),
+ props: { EuiVerticalBarSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./vertical_rect_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ {
+ title: 'Horizontal Histogram',
+ text: (
+
+
+ Use EuiXYChart with EuiVerticalRectSeries for displaying
+ an horizontal histogram.
+
+
+ ),
+ props: { EuiVerticalBarSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./vertical_rect_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ {
+ title: 'Stacked Horizontal Bar Chart',
+ text: (
+
+
+ Use EuiXYChart with EuiHorizontalBarSeries for displaying
+ horizontal bar charts. Use the appropriate yType props to match your
+ y value scale. Available values are: ordinal ,linear
+
+
+ ),
+ props: { EuiHorizontalBarSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./stacked_horizontal_bar_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ {
+ title: 'Stacked Vertical Bar Chart',
+ text: (
+
+
+ Use EuiXYChart with EuiHorizontalBarSeries for displaying
+ horizontal bar charts. Use the appropriate yType props to match your
+ y value scale. Available values are: ordinal ,linear
+
+
+ ),
+ props: { EuiHorizontalBarSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./stacked_vertical_bar_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
]
};
diff --git a/src-docs/src/views/xy_chart_series/stacked_horizontal_bar_series.js b/src-docs/src/views/xy_chart_series/stacked_horizontal_bar_series.js
new file mode 100644
index 000000000000..bb4bec36b87e
--- /dev/null
+++ b/src-docs/src/views/xy_chart_series/stacked_horizontal_bar_series.js
@@ -0,0 +1,78 @@
+import React, { Component } from 'react';
+
+import {
+ EuiButton,
+ EuiXYChart,
+ EuiHorizontalBarSeries,
+} from '../../../../src/components';
+
+const data = [
+ [
+ { x: 1, y: 'A' },
+ { x: 2, y: 'B' },
+ { x: 3, y: 'C' },
+ { x: 4, y: 'D' },
+ { x: 5, y: 'E' },
+ ],
+ [
+ { x: 3, y: 'A' },
+ { x: 2, y: 'B' },
+ { x: 1, y: 'C' },
+ { x: 2, y: 'D' },
+ { x: 3, y: 'E' },
+ ]
+];
+export default class extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ stacked: true,
+ };
+ }
+
+ onSwitchStacked = () => {
+ this.setState({
+ stacked: !this.state.stacked,
+ });
+ }
+ renderBars = () => {
+ const { stacked } = this.state
+ return data.map((d, i) => {
+ return (
+
+ )
+ })
+ }
+
+ render() {
+
+ return (
+
+
+ Toggle stacked
+
+
+ {
+ this.renderBars()
+ }
+
+
+
+ )
+ }
+}
diff --git a/src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js b/src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js
new file mode 100644
index 000000000000..5b3606ee0221
--- /dev/null
+++ b/src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js
@@ -0,0 +1,78 @@
+import React, { Component } from 'react';
+
+import {
+ EuiButton,
+ EuiXYChart,
+ EuiVerticalBarSeries,
+} from '../../../../src/components';
+
+const data = [
+ [
+ { x: 'A', y: 3 },
+ { x: 'B', y: 1 },
+ { x: 'C', y: 5 },
+ { x: 'D', y: 2 },
+ { x: 'E', y: 1 },
+ ],
+ [
+ { x: 'A', y: 1 },
+ { x: 'B', y: 2 },
+ { x: 'C', y: 3 },
+ { x: 'D', y: 4 },
+ { x: 'E', y: 5 },
+ ]
+];
+export default class extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ stacked: true,
+ };
+ }
+
+ onSwitchStacked = () => {
+ this.setState({
+ stacked: !this.state.stacked,
+ });
+ }
+ renderBars = () => {
+ const { stacked } = this.state
+ return data.map((d, i) => {
+ return (
+
+ )
+ })
+ }
+
+ render() {
+
+ return (
+
+
+ Toggle stacked
+
+
+ {
+ this.renderBars()
+ }
+
+
+
+ )
+ }
+}
diff --git a/src-docs/src/views/xy_chart_series/vertical_bar_series.js b/src-docs/src/views/xy_chart_series/vertical_bar_series.js
new file mode 100644
index 000000000000..b609ab00bab8
--- /dev/null
+++ b/src-docs/src/views/xy_chart_series/vertical_bar_series.js
@@ -0,0 +1,24 @@
+import React from 'react';
+
+import { EuiXYChart, EuiVerticalBarSeries } from '../../../../src/components';
+
+const data = [
+ { x: 'A', y: 3 },
+ { x: 'B', y: 1 },
+ { x: 'C', y: 5 },
+ { x: 'D', y: 2 },
+ { x: 'E', y: 1 },
+]
+
+export default () => (
+
+
+
+);
diff --git a/src-docs/src/views/xy_chart_series/vertical_rect_series.js b/src-docs/src/views/xy_chart_series/vertical_rect_series.js
new file mode 100644
index 000000000000..78ebb4bde151
--- /dev/null
+++ b/src-docs/src/views/xy_chart_series/vertical_rect_series.js
@@ -0,0 +1,23 @@
+import React from 'react';
+
+import { EuiXYChart, EuiVerticalRectSeries } from '../../../../src/components';
+
+const data = [
+ { x0: 0, x: 1, y: 1 },
+ { x0: 1, x: 2, y: 3 },
+ { x0: 2, x: 3, y: 2 },
+ { x0: 3, x: 4, y: 0.5 },
+ { x0: 4, x: 5, y: 5 },
+]
+
+export default () => (
+
+
+
+);
diff --git a/src/components/index.js b/src/components/index.js
index 4183ccd24d78..6382aa9e00db 100644
--- a/src/components/index.js
+++ b/src/components/index.js
@@ -306,5 +306,8 @@ export {
EuiXYChart,
EuiLine,
EuiArea,
- EuiBar
-} from './xy_chart';
\ No newline at end of file
+ EuiVerticalBarSeries,
+ EuiHorizontalBarSeries,
+ EuiVerticalRectSeries,
+ EuiHorizontalRectSeries,
+} from './xy_chart';
diff --git a/src/components/xy_chart/__snapshots__/area.test.js.snap b/src/components/xy_chart/__snapshots__/area.test.js.snap
index 99e1f750b518..20c9f8225616 100644
--- a/src/components/xy_chart/__snapshots__/area.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/area.test.js.snap
@@ -16,7 +16,6 @@ exports[`EuiArea all props are rendered 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -0.4
-
-
-
-
-
- -0.2
-
-
-
-
-
- 0.0
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.8
-
-
-
-
-
- 1.0
-
-
-
-
-
- 1.2
-
-
-
-
-
- 1.4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
-
-
- 2
-
-
-
-
-
- 4
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
- 14
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`EuiBar is rendered 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -0.4
-
-
-
-
-
- -0.2
-
-
-
-
-
- 0.0
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.8
-
-
-
-
-
- 1.0
-
-
-
-
-
- 1.2
-
-
-
-
-
- 1.4
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
-
-
- 2
-
-
-
-
-
- 4
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
- 14
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
diff --git a/src/components/xy_chart/__snapshots__/chart.test.js.snap b/src/components/xy_chart/__snapshots__/chart.test.js.snap
index 2ec3454ac13d..999858655eac 100644
--- a/src/components/xy_chart/__snapshots__/chart.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/chart.test.js.snap
@@ -84,7 +84,6 @@ exports[`EuiXYChart passes handler functions 1`] = `
{showAxis && [
@@ -212,6 +216,9 @@ export class XYChart extends PureComponent {
XYChart.propTypes = {
width: PropTypes.number.isRequired,
height: PropTypes.number.isRequired,
+ stackBy: PropTypes.string,
+ xType: PropTypes.string,
+ yType: PropTypes.string,
onHover: PropTypes.func,
onMouseLeave: PropTypes.func,
onSelectEnd: PropTypes.func,
@@ -222,18 +229,16 @@ XYChart.propTypes = {
showAxis: PropTypes.bool,
xAxisLocation: PropTypes.string,
yAxisLocation: PropTypes.string,
- mode: PropTypes.string,
showTooltips: PropTypes.bool,
errorText: PropTypes.string,
crosshairX: PropTypes.number,
- onCrosshairUpdate: PropTypes.func
+ onCrosshairUpdate: PropTypes.func,
};
XYChart.defaultProps = {
truncateLegends: false,
showAxis: true,
showTooltips: true,
- mode: 'linear',
};
export default makeWidthFlexible(XYChart);
diff --git a/src/components/xy_chart/horizontal_bar_series.js b/src/components/xy_chart/horizontal_bar_series.js
new file mode 100644
index 000000000000..e6bf44ea596d
--- /dev/null
+++ b/src/components/xy_chart/horizontal_bar_series.js
@@ -0,0 +1,44 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { HorizontalBarSeries } from 'react-vis';
+
+class EuiHorizontalBarSeries extends HorizontalBarSeries {
+ render() {
+ const { name, data, color, onClick, ...rest } = this.props;
+
+ return (
+
+
+
+ );
+ }
+}
+export default EuiHorizontalBarSeries;
+
+EuiHorizontalBarSeries.propTypes = {
+ /** The name used to define the data in tooltips and ledgends */
+ name: PropTypes.string.isRequired,
+ /** Array<{x: string|number, y: string|number}> */
+ data: PropTypes.arrayOf(PropTypes.shape({
+ x: PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.number
+ ]),
+ y: PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.number
+ ]),
+ })).isRequired,
+ /** Without a color set, a random EUI color palette color will be chosen */
+ color: PropTypes.string,
+ onClick: PropTypes.func
+};
+
+EuiHorizontalBarSeries.defaultProps = {};
diff --git a/src/components/xy_chart/horizontal_rect_series.js b/src/components/xy_chart/horizontal_rect_series.js
new file mode 100644
index 000000000000..9bc891e6d51a
--- /dev/null
+++ b/src/components/xy_chart/horizontal_rect_series.js
@@ -0,0 +1,44 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { HorizontalRectSeries } from 'react-vis';
+
+class EuiHorizontalBarSeries extends HorizontalRectSeries {
+ render() {
+ const { name, data, color, onClick, ...rest } = this.props;
+
+ return (
+
+
+
+ );
+ }
+}
+export default EuiHorizontalBarSeries;
+
+EuiHorizontalBarSeries.propTypes = {
+ /** The name used to define the data in tooltips and ledgends */
+ name: PropTypes.string.isRequired,
+ /** Array<{x: string|number, y: string|number}> */
+ data: PropTypes.arrayOf(PropTypes.shape({
+ x: PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.number
+ ]),
+ y: PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.number
+ ]),
+ })).isRequired,
+ /** Without a color set, a random EUI color palette color will be chosen */
+ color: PropTypes.string,
+ onClick: PropTypes.func
+};
+
+EuiHorizontalBarSeries.defaultProps = {};
diff --git a/src/components/xy_chart/index.js b/src/components/xy_chart/index.js
index b375c1a81f23..3dafdc19dc30 100644
--- a/src/components/xy_chart/index.js
+++ b/src/components/xy_chart/index.js
@@ -2,14 +2,20 @@ import { asSeries } from './as_series';
import EuiXYChart from './chart';
import * as utils from './utils';
import { EuiLine } from './line';
-import EuiBar from './bar';
+import EuiVerticalBarSeries from './vertical_bar_series';
+import EuiHorizontalBarSeries from './horizontal_bar_series';
+import EuiVerticalRectSeries from './vertical_rect_series';
+import EuiHorizontalRectSeries from './horizontal_rect_series';
import{ EuiArea } from './area';
-export {
+export {
EuiXYChart,
EuiLine,
EuiArea,
- EuiBar,
+ EuiVerticalBarSeries,
+ EuiHorizontalBarSeries,
+ EuiVerticalRectSeries,
+ EuiHorizontalRectSeries,
utils,
asSeries
-};
\ No newline at end of file
+};
diff --git a/src/components/xy_chart/vertical_bar_series.js b/src/components/xy_chart/vertical_bar_series.js
new file mode 100644
index 000000000000..384363bfee94
--- /dev/null
+++ b/src/components/xy_chart/vertical_bar_series.js
@@ -0,0 +1,42 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { VerticalBarSeries } from 'react-vis';
+
+class EuiVerticalBarSeries extends VerticalBarSeries {
+ render() {
+ const { name, data, color, onClick, ...rest } = this.props;
+
+ return (
+
+ );
+ }
+}
+export default EuiVerticalBarSeries;
+
+EuiVerticalBarSeries.propTypes = {
+ /** The name used to define the data in tooltips and ledgends */
+ name: PropTypes.string.isRequired,
+ /** Array<{x: string|number, y: string|number}> */
+ data: PropTypes.arrayOf(PropTypes.shape({
+ x: PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.number
+ ]),
+ y: PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.number
+ ]),
+ })).isRequired,
+ /** Without a color set, a random EUI color palette color will be chosen */
+ color: PropTypes.string,
+ onClick: PropTypes.func
+};
+
+EuiVerticalBarSeries.defaultProps = {};
diff --git a/src/components/xy_chart/bar.test.js b/src/components/xy_chart/vertical_bar_series.test.js
similarity index 89%
rename from src/components/xy_chart/bar.test.js
rename to src/components/xy_chart/vertical_bar_series.test.js
index a086d0caca8e..73e05c9356a6 100644
--- a/src/components/xy_chart/bar.test.js
+++ b/src/components/xy_chart/vertical_bar_series.test.js
@@ -4,17 +4,17 @@ import { patchRandom, unpatchRandom } from '../../test/patch_random';
import { requiredProps } from '../../test/required_props';
import EuiXYChart from './chart';
-import EuiBar from './bar';
+import EuiVerticalBarSeries from './vertical_bar_series';
import { benchmarkFunction } from '../../test/time_execution';
beforeEach(patchRandom);
afterEach(unpatchRandom);
-describe('EuiBar', () => {
+describe.skip('EuiVerticalBarSeries', () => {
test('is rendered', () => {
const component = mount(
-
@@ -27,7 +27,7 @@ describe('EuiBar', () => {
test('all props are rendered', () => {
const component = mount(
- {
function renderChart() {
render(
-
+
)
}
@@ -94,7 +94,7 @@ describe('EuiBar', () => {
render(
{linesData.map((data, index) => (
-
+
))}
)
diff --git a/src/components/xy_chart/bar.js b/src/components/xy_chart/vertical_rect_series.js
similarity index 78%
rename from src/components/xy_chart/bar.js
rename to src/components/xy_chart/vertical_rect_series.js
index 9d54695ef776..a05f09e61b06 100644
--- a/src/components/xy_chart/bar.js
+++ b/src/components/xy_chart/vertical_rect_series.js
@@ -1,14 +1,14 @@
import React from 'react';
import PropTypes from 'prop-types';
-import { VerticalBarSeries } from 'react-vis';
+import { VerticalRectSeries } from 'react-vis';
-class EUIBarSeries extends VerticalBarSeries {
+class EuiVerticalBarSeries extends VerticalRectSeries {
render() {
const { name, data, color, onClick, ...rest } = this.props;
return (
- */
@@ -41,4 +41,4 @@ EUIBarSeries.propTypes = {
onClick: PropTypes.func
};
-EUIBarSeries.defaultProps = {};
+EuiVerticalBarSeries.defaultProps = {};
From 9ceb425321749d85b12b264d105f9cafae060cf4 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Fri, 1 Jun 2018 12:30:53 +0200
Subject: [PATCH 02/68] Fix wrong component naming. Fix stacked mechanism
---
.../stacked_horizontal_bar_series.js | 57 +-
.../stacked_vertical_bar_series.js | 58 +-
.../vertical_bar_series.test.js.snap | 6724 +++++++++++++++++
.../xy_chart/horizontal_rect_series.js | 8 +-
.../xy_chart/vertical_rect_series.js | 7 +-
5 files changed, 6780 insertions(+), 74 deletions(-)
create mode 100644 src/components/xy_chart/__snapshots__/vertical_bar_series.test.js.snap
diff --git a/src-docs/src/views/xy_chart_series/stacked_horizontal_bar_series.js b/src-docs/src/views/xy_chart_series/stacked_horizontal_bar_series.js
index bb4bec36b87e..f443646cfea4 100644
--- a/src-docs/src/views/xy_chart_series/stacked_horizontal_bar_series.js
+++ b/src-docs/src/views/xy_chart_series/stacked_horizontal_bar_series.js
@@ -6,22 +6,21 @@ import {
EuiHorizontalBarSeries,
} from '../../../../src/components';
-const data = [
- [
- { x: 1, y: 'A' },
- { x: 2, y: 'B' },
- { x: 3, y: 'C' },
- { x: 4, y: 'D' },
- { x: 5, y: 'E' },
- ],
- [
- { x: 3, y: 'A' },
- { x: 2, y: 'B' },
- { x: 1, y: 'C' },
- { x: 2, y: 'D' },
- { x: 3, y: 'E' },
- ]
+const dataA = [
+ { x: 1, y: 'A' },
+ { x: 2, y: 'B' },
+ { x: 3, y: 'C' },
+ { x: 4, y: 'D' },
+ { x: 5, y: 'E' },
];
+const dataB = [
+ { x: 3, y: 'A' },
+ { x: 2, y: 'B' },
+ { x: 1, y: 'C' },
+ { x: 2, y: 'D' },
+ { x: 3, y: 'E' },
+];
+
export default class extends Component {
constructor(props) {
super(props);
@@ -36,22 +35,9 @@ export default class extends Component {
stacked: !this.state.stacked,
});
}
- renderBars = () => {
- const { stacked } = this.state
- return data.map((d, i) => {
- return (
-
- )
- })
- }
render() {
-
+ const { stacked } = this.state
return (
- {
- this.renderBars()
- }
+
+
diff --git a/src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js b/src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js
index 5b3606ee0221..94ab4a93b04a 100644
--- a/src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js
+++ b/src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js
@@ -6,22 +6,22 @@ import {
EuiVerticalBarSeries,
} from '../../../../src/components';
-const data = [
- [
- { x: 'A', y: 3 },
- { x: 'B', y: 1 },
- { x: 'C', y: 5 },
- { x: 'D', y: 2 },
- { x: 'E', y: 1 },
- ],
- [
- { x: 'A', y: 1 },
- { x: 'B', y: 2 },
- { x: 'C', y: 3 },
- { x: 'D', y: 4 },
- { x: 'E', y: 5 },
- ]
+const dataA = [
+ { x: 'A', y: 3 },
+ { x: 'B', y: 1 },
+ { x: 'C', y: 5 },
+ { x: 'D', y: 2 },
+ { x: 'E', y: 1 },
];
+
+const dataB = [
+ { x: 'A', y: 1 },
+ { x: 'B', y: 2 },
+ { x: 'C', y: 3 },
+ { x: 'D', y: 4 },
+ { x: 'E', y: 5 },
+];
+
export default class extends Component {
constructor(props) {
super(props);
@@ -36,22 +36,9 @@ export default class extends Component {
stacked: !this.state.stacked,
});
}
- renderBars = () => {
- const { stacked } = this.state
- return data.map((d, i) => {
- return (
-
- )
- })
- }
render() {
-
+ const { stacked } = this.state
return (
- {
- this.renderBars()
- }
+
+
diff --git a/src/components/xy_chart/__snapshots__/vertical_bar_series.test.js.snap b/src/components/xy_chart/__snapshots__/vertical_bar_series.test.js.snap
new file mode 100644
index 000000000000..1ecc63cf4ec7
--- /dev/null
+++ b/src/components/xy_chart/__snapshots__/vertical_bar_series.test.js.snap
@@ -0,0 +1,6724 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`EuiVerticalBarSeries all props are rendered 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -0.4
+
+
+
+
+
+ -0.2
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 1.0
+
+
+
+
+
+ 1.2
+
+
+
+
+
+ 1.4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 2
+
+
+
+
+
+ 4
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`EuiVerticalBarSeries is rendered 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -0.4
+
+
+
+
+
+ -0.2
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 1.0
+
+
+
+
+
+ 1.2
+
+
+
+
+
+ 1.4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 2
+
+
+
+
+
+ 4
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/src/components/xy_chart/horizontal_rect_series.js b/src/components/xy_chart/horizontal_rect_series.js
index 9bc891e6d51a..4cec4d2cd997 100644
--- a/src/components/xy_chart/horizontal_rect_series.js
+++ b/src/components/xy_chart/horizontal_rect_series.js
@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { HorizontalRectSeries } from 'react-vis';
-class EuiHorizontalBarSeries extends HorizontalRectSeries {
+class EuiHorizontalRectSeries extends HorizontalRectSeries {
render() {
const { name, data, color, onClick, ...rest } = this.props;
@@ -20,9 +20,9 @@ class EuiHorizontalBarSeries extends HorizontalRectSeries {
);
}
}
-export default EuiHorizontalBarSeries;
+export default EuiHorizontalRectSeries;
-EuiHorizontalBarSeries.propTypes = {
+EuiHorizontalRectSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
name: PropTypes.string.isRequired,
/** Array<{x: string|number, y: string|number}> */
@@ -41,4 +41,4 @@ EuiHorizontalBarSeries.propTypes = {
onClick: PropTypes.func
};
-EuiHorizontalBarSeries.defaultProps = {};
+EuiHorizontalRectSeries.defaultProps = {};
diff --git a/src/components/xy_chart/vertical_rect_series.js b/src/components/xy_chart/vertical_rect_series.js
index a05f09e61b06..711fd7e121fe 100644
--- a/src/components/xy_chart/vertical_rect_series.js
+++ b/src/components/xy_chart/vertical_rect_series.js
@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { VerticalRectSeries } from 'react-vis';
-class EuiVerticalBarSeries extends VerticalRectSeries {
+export default class EuiVerticalRectSeries extends VerticalRectSeries {
render() {
const { name, data, color, onClick, ...rest } = this.props;
@@ -20,9 +20,8 @@ class EuiVerticalBarSeries extends VerticalRectSeries {
);
}
}
-export default EuiVerticalBarSeries;
-EuiVerticalBarSeries.propTypes = {
+EuiVerticalRectSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
name: PropTypes.string.isRequired,
/** Array<{x: string|number, y: string|number}> */
@@ -41,4 +40,4 @@ EuiVerticalBarSeries.propTypes = {
onClick: PropTypes.func
};
-EuiVerticalBarSeries.defaultProps = {};
+EuiVerticalRectSeries.defaultProps = {};
From a1639165570c4a0a196c0053792fe7126212c8f3 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Fri, 1 Jun 2018 18:01:52 +0200
Subject: [PATCH 03/68] Update examples
---
.../views/xy_chart_series/series_example.js | 58 +
.../stacked_horizontal_rect_series.js | 41 +
.../stacked_vertical_bar_series.js | 20 +-
.../stacked_vertical_rect_series.js | 41 +
.../vertical_bar_series.test.js.snap | 7978 +++--------------
.../vertical_rect_series.test.js.snap | 1362 +++
.../xy_chart/horizontal_bar_series.js | 7 +-
.../xy_chart/horizontal_rect_series.js | 7 +-
.../xy_chart/vertical_bar_series.js | 7 +-
.../xy_chart/vertical_bar_series.test.js | 34 +-
.../xy_chart/vertical_rect_series.js | 7 +-
.../xy_chart/vertical_rect_series.test.js | 135 +
12 files changed, 2985 insertions(+), 6712 deletions(-)
create mode 100644 src-docs/src/views/xy_chart_series/stacked_horizontal_rect_series.js
create mode 100644 src-docs/src/views/xy_chart_series/stacked_vertical_rect_series.js
create mode 100644 src/components/xy_chart/__snapshots__/vertical_rect_series.test.js.snap
create mode 100644 src/components/xy_chart/vertical_rect_series.test.js
diff --git a/src-docs/src/views/xy_chart_series/series_example.js b/src-docs/src/views/xy_chart_series/series_example.js
index 6a3ce1a71118..3516e8921fb8 100644
--- a/src-docs/src/views/xy_chart_series/series_example.js
+++ b/src-docs/src/views/xy_chart_series/series_example.js
@@ -4,7 +4,9 @@ import LineSeriesExample from './line_series';
import VerticalBarSeriesExample from './vertical_bar_series';
import HorizontalBarSeriesExample from './horizontal_bar_series';
import StackedHorizontalBarSeriesExample from './stacked_horizontal_bar_series';
+import StackedHorizontalRectSeriesExample from './stacked_horizontal_rect_series';
import StackedVerticalBarSeriesExample from './stacked_vertical_bar_series';
+import StackedVerticalRectSeriesExample from './stacked_vertical_rect_series';
import VerticalRectSeriesExample from './vertical_rect_series';
import HorizontalRectSeriesExample from './horizontal_rect_series';
import AreaSeriesExample from './area_series';
@@ -235,5 +237,61 @@ export const XYChartSeriesExample = {
)
},
+ {
+ title: 'Stacked Vertical Histogram',
+ text: (
+
+
+ Use EuiXYChart with EuiHorizontalBarSeries for displaying
+ horizontal bar charts. Use the appropriate yType props to match your
+ y value scale. Available values are: ordinal ,linear
+
+
+ ),
+ props: { EuiHorizontalBarSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./stacked_vertical_rect_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ {
+ title: 'Stacked Horizontal Histogram',
+ text: (
+
+
+ Use EuiXYChart with EuiHorizontalBarSeries for displaying
+ horizontal bar charts. Use the appropriate yType props to match your
+ y value scale. Available values are: ordinal ,linear
+
+
+ ),
+ props: { EuiHorizontalBarSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./stacked_horizontal_rect_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
]
};
diff --git a/src-docs/src/views/xy_chart_series/stacked_horizontal_rect_series.js b/src-docs/src/views/xy_chart_series/stacked_horizontal_rect_series.js
new file mode 100644
index 000000000000..e1ddabd91a0e
--- /dev/null
+++ b/src-docs/src/views/xy_chart_series/stacked_horizontal_rect_series.js
@@ -0,0 +1,41 @@
+import React from 'react';
+
+import {
+ EuiXYChart,
+ EuiHorizontalRectSeries,
+} from '../../../../src/components';
+
+const dataA = [
+ { y: 0, y0: 1, x: 1 },
+ { y: 1, y0: 2, x: 2 },
+ { y: 2, y0: 3, x: 3 },
+ { y: 3, y0: 4, x: 4 },
+ { y: 4, y0: 5, x: 5 },
+];
+
+const dataB = [
+ { y: 0, y0: 1, x: 5 },
+ { y: 1, y0: 2, x: 4 },
+ { y: 2, y0: 3, x: 3 },
+ { y: 3, y0: 4, x: 2 },
+ { y: 4, y0: 5, x: 1 },
+];
+
+export default () => (
+
+
+
+
+);
diff --git a/src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js b/src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js
index 94ab4a93b04a..936c093a0e43 100644
--- a/src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js
+++ b/src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js
@@ -7,19 +7,19 @@ import {
} from '../../../../src/components';
const dataA = [
- { x: 'A', y: 3 },
- { x: 'B', y: 1 },
- { x: 'C', y: 5 },
- { x: 'D', y: 2 },
- { x: 'E', y: 1 },
+ { x: 0, y: 5 },
+ { x: 1, y: 4 },
+ { x: 2, y: 3 },
+ { x: 3, y: 2 },
+ { x: 4, y: 1 },
];
const dataB = [
- { x: 'A', y: 1 },
- { x: 'B', y: 2 },
- { x: 'C', y: 3 },
- { x: 'D', y: 4 },
- { x: 'E', y: 5 },
+ { x: 0, y: 1 },
+ { x: 1, y: 2 },
+ { x: 2, y: 3 },
+ { x: 3, y: 4 },
+ { x: 4, y: 5 },
];
export default class extends Component {
diff --git a/src-docs/src/views/xy_chart_series/stacked_vertical_rect_series.js b/src-docs/src/views/xy_chart_series/stacked_vertical_rect_series.js
new file mode 100644
index 000000000000..0b28a65858eb
--- /dev/null
+++ b/src-docs/src/views/xy_chart_series/stacked_vertical_rect_series.js
@@ -0,0 +1,41 @@
+import React from 'react';
+
+import {
+ EuiXYChart,
+ EuiVerticalRectSeries,
+} from '../../../../src/components';
+
+const dataA = [
+ { x0: 0, x: 1, y: 1 },
+ { x0: 1, x: 2, y: 2 },
+ { x0: 2, x: 3, y: 1 },
+ { x0: 3, x: 4, y: 1 },
+ { x0: 4, x: 5, y: 1 },
+];
+
+const dataB = [
+ { x0: 0, x: 1, y: 2 },
+ { x0: 1, x: 2, y: 1 },
+ { x0: 2, x: 3, y: 2 },
+ { x0: 3, x: 4, y: 2 },
+ { x0: 4, x: 5, y: 2 },
+];
+
+export default () => (
+
+
+
+
+
+
+);
diff --git a/src/components/xy_chart/__snapshots__/vertical_bar_series.test.js.snap b/src/components/xy_chart/__snapshots__/vertical_bar_series.test.js.snap
index 1ecc63cf4ec7..81b1b12c6377 100644
--- a/src/components/xy_chart/__snapshots__/vertical_bar_series.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/vertical_bar_series.test.js.snap
@@ -1,6724 +1,1314 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`EuiVerticalBarSeries all props are rendered 1`] = `
-
-
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
+
+ -0.4
+
+
+
+
+
+ -0.2
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.4
+
+
+
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
- -0.4
-
-
-
-
-
- -0.2
-
-
-
-
-
- 0.0
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.8
-
-
-
-
-
- 1.0
-
-
-
-
-
- 1.2
-
-
-
-
-
- 1.4
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
-
-
- 2
-
-
-
-
-
- 4
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
- 14
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ 1.2
+
+
+
+
+
+ 1.4
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 2
+
+
+
+
+
+ 4
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
+
+
+
+
+
+
-
+
`;
exports[`EuiVerticalBarSeries is rendered 1`] = `
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -0.4
+
+
+
+
+
+ -0.2
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 1.0
+
+
+
+
+
+ 1.2
+
+
+
+
+
+ 1.4
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 2
+
+
+
+
+
+ 4
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`EuiVerticalBarSeries renders stacked bar chart 1`] = `
+
+
+
-
-
+
+
+
+
+
+
+
+
-
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
- -0.4
-
-
-
-
-
- -0.2
-
-
-
-
-
- 0.0
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.8
-
-
-
-
-
- 1.0
-
-
-
-
-
- 1.2
-
-
-
-
-
- 1.4
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 2
+
+
+
+
+
+ 4
+
+
+
+
+
+ 6
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
-
-
- 2
-
-
-
-
-
- 4
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
- 14
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ 10
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
`;
diff --git a/src/components/xy_chart/__snapshots__/vertical_rect_series.test.js.snap b/src/components/xy_chart/__snapshots__/vertical_rect_series.test.js.snap
new file mode 100644
index 000000000000..106d36b8c408
--- /dev/null
+++ b/src/components/xy_chart/__snapshots__/vertical_rect_series.test.js.snap
@@ -0,0 +1,1362 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`EuiVerticalRectSeries all props are rendered 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 2
+
+
+
+
+
+ 4
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`EuiVerticalRectSeries is rendered 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 2
+
+
+
+
+
+ 4
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`EuiVerticalRectSeries renders stacked vertical histogram 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 1
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 2
+
+
+
+
+
+ 4
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/src/components/xy_chart/horizontal_bar_series.js b/src/components/xy_chart/horizontal_bar_series.js
index e6bf44ea596d..000043282932 100644
--- a/src/components/xy_chart/horizontal_bar_series.js
+++ b/src/components/xy_chart/horizontal_bar_series.js
@@ -12,7 +12,12 @@ class EuiHorizontalBarSeries extends HorizontalBarSeries {
key={name}
onSeriesClick={onClick}
color={color}
- style={{ rx: 2, ry: 2 }}
+ style={{
+ strokeWidth: 1,
+ stroke: 'white',
+ rx: 2,
+ ry: 2,
+ }}
data={data}
{...rest}
/>
diff --git a/src/components/xy_chart/horizontal_rect_series.js b/src/components/xy_chart/horizontal_rect_series.js
index 4cec4d2cd997..2d120d3d3add 100644
--- a/src/components/xy_chart/horizontal_rect_series.js
+++ b/src/components/xy_chart/horizontal_rect_series.js
@@ -12,7 +12,12 @@ class EuiHorizontalRectSeries extends HorizontalRectSeries {
key={name}
onSeriesClick={onClick}
color={color}
- style={{ rx: 2, ry: 2 }}
+ style={{
+ strokeWidth: 1,
+ stroke: 'white',
+ rx: 2,
+ ry: 2,
+ }}
data={data}
{...rest}
/>
diff --git a/src/components/xy_chart/vertical_bar_series.js b/src/components/xy_chart/vertical_bar_series.js
index 384363bfee94..279cc10d8468 100644
--- a/src/components/xy_chart/vertical_bar_series.js
+++ b/src/components/xy_chart/vertical_bar_series.js
@@ -11,7 +11,12 @@ class EuiVerticalBarSeries extends VerticalBarSeries {
key={name}
onSeriesClick={onClick}
color={color}
- style={{ rx: 2, ry: 2 }}
+ style={{
+ strokeWidth: 1,
+ stroke: 'white',
+ rx: 2,
+ ry: 2,
+ }}
data={data}
{...rest}
/>
diff --git a/src/components/xy_chart/vertical_bar_series.test.js b/src/components/xy_chart/vertical_bar_series.test.js
index 73e05c9356a6..8976e8988485 100644
--- a/src/components/xy_chart/vertical_bar_series.test.js
+++ b/src/components/xy_chart/vertical_bar_series.test.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { mount, render } from 'enzyme';
+import { render } from 'enzyme';
import { patchRandom, unpatchRandom } from '../../test/patch_random';
import { requiredProps } from '../../test/required_props';
@@ -10,9 +10,9 @@ import { benchmarkFunction } from '../../test/time_execution';
beforeEach(patchRandom);
afterEach(unpatchRandom);
-describe.skip('EuiVerticalBarSeries', () => {
+describe('EuiVerticalBarSeries', () => {
test('is rendered', () => {
- const component = mount(
+ const component = render(
{
});
test('all props are rendered', () => {
- const component = mount(
+ const component = render(
{
expect(component).toMatchSnapshot();
});
+ test('renders stacked bar chart', () => {
+ const component = render(
+
+ {}}
+ />
+ {}}
+ />
+
+ );
+
+ expect(component).toMatchSnapshot();
+ });
+
describe('performance', () => {
it.skip('renders 1000 items in under 0.5 seconds', () => {
const yTicks = [[0, 'zero'], [1, 'one']];
diff --git a/src/components/xy_chart/vertical_rect_series.js b/src/components/xy_chart/vertical_rect_series.js
index 711fd7e121fe..83d7a4d69e51 100644
--- a/src/components/xy_chart/vertical_rect_series.js
+++ b/src/components/xy_chart/vertical_rect_series.js
@@ -12,7 +12,12 @@ export default class EuiVerticalRectSeries extends VerticalRectSeries {
key={name}
onSeriesClick={onClick}
color={color}
- style={{ rx: 2, ry: 2 }}
+ style={{
+ strokeWidth: 1,
+ stroke: 'white',
+ rx: 2,
+ ry: 2,
+ }}
data={data}
{...rest}
/>
diff --git a/src/components/xy_chart/vertical_rect_series.test.js b/src/components/xy_chart/vertical_rect_series.test.js
new file mode 100644
index 000000000000..5576d23b17a4
--- /dev/null
+++ b/src/components/xy_chart/vertical_rect_series.test.js
@@ -0,0 +1,135 @@
+import React from 'react';
+import { render } from 'enzyme';
+import { patchRandom, unpatchRandom } from '../../test/patch_random';
+import { requiredProps } from '../../test/required_props';
+
+import EuiXYChart from './chart';
+import EuiVerticalRectSeries from './vertical_rect_series';
+import { benchmarkFunction } from '../../test/time_execution';
+
+beforeEach(patchRandom);
+afterEach(unpatchRandom);
+
+describe('EuiVerticalRectSeries', () => {
+ test('is rendered', () => {
+ const component = render(
+
+
+
+ );
+
+ expect(component).toMatchSnapshot();
+ });
+
+ test('all props are rendered', () => {
+ const component = render(
+
+ {}}
+ />
+
+ );
+
+ expect(component).toMatchSnapshot();
+ });
+
+ test('renders stacked vertical histogram', () => {
+ const component = render(
+
+ {}}
+ />
+ {}}
+ />
+
+ );
+
+ expect(component).toMatchSnapshot();
+ });
+
+ describe('performance', () => {
+ it.skip('renders 1000 items in under 0.5 seconds', () => {
+ const yTicks = [[0, 'zero'], [1, 'one']];
+ const xTicks = [
+ [0, '0'],
+ [250, '250'],
+ [500, '500'],
+ [750, '750'],
+ [1000, '1000']
+ ];
+ const data = [];
+
+ for (let i = 0; i < 1000; i++) {
+ data.push({ x: i, y: Math.random() });
+ }
+
+ function renderChart() {
+ render(
+
+
+
+ )
+ }
+
+ const runtime = benchmarkFunction(renderChart);
+ // as of 2018-05-011 / git 00cfbb94d2fcb08aeeed2bb8f4ed0b94eb08307b
+ // this is ~9ms on a MacBookPro
+ expect(runtime).toBeLessThan(500);
+ });
+
+ it.skip('renders 30 lines of 500 items in under 3 seconds', () => {
+ const yTicks = [[0, 'zero'], [1, 'one']];
+ const xTicks = [
+ [0, '0'],
+ [125, '125'],
+ [250, '240'],
+ [375, '375'],
+ [500, '500']
+ ];
+
+ const linesData = [];
+ for (let i = 0; i < 30; i++) {
+ const data = [];
+
+ for (let i = 0; i < 500; i++) {
+ data.push({ x: i, y: Math.random() });
+ }
+
+ linesData.push(data);
+ }
+
+ function renderChart() {
+ render(
+
+ {linesData.map((data, index) => (
+
+ ))}
+
+ )
+ }
+
+ const runtime = benchmarkFunction(renderChart);
+ // as of 2018-05-011 / git 00cfbb94d2fcb08aeeed2bb8f4ed0b94eb08307b
+ // this is ~1750 on a MacBookPro
+ expect(runtime).toBeLessThan(3000);
+ });
+ });
+});
From e64f5c25bed4e9be9e97322e5c8521bb5ea87a19 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Fri, 1 Jun 2018 18:51:02 +0200
Subject: [PATCH 04/68] Update example descriptions
---
.../views/xy_chart_series/series_example.js | 73 ++++++++++++++-----
.../xy_chart/horizontal_bar_series.js | 5 +-
.../xy_chart/horizontal_rect_series.js | 10 +--
.../xy_chart/vertical_bar_series.js | 5 +-
4 files changed, 60 insertions(+), 33 deletions(-)
diff --git a/src-docs/src/views/xy_chart_series/series_example.js b/src-docs/src/views/xy_chart_series/series_example.js
index 3516e8921fb8..280464f884d4 100644
--- a/src-docs/src/views/xy_chart_series/series_example.js
+++ b/src-docs/src/views/xy_chart_series/series_example.js
@@ -77,8 +77,15 @@ export const XYChartSeriesExample = {
Use EuiXYChart with EuiVerticalBarSeries for displaying
- vertical bar charts. Use the appropriate xType props to match your
- x value scale. Available values are: ordinal ,linear
+ vertical bar charts.
+
+
+ Specify EuiXYChart prop xType="ordinal"
+ because we are creating a Bar Chart.
+
+
+ The Y-Axis can be configured with linear ,log ,
+ time , time-utc
),
@@ -105,8 +112,14 @@ export const XYChartSeriesExample = {
Use EuiXYChart with EuiHorizontalBarSeries for displaying
- horizontal bar charts. Use the appropriate yType props to match your
- y value scale. Available values are: ordinal ,linear
+ horizontal bar charts.
+
+
+ Specify EuiXYChart prop yType="ordinal"
+ because we are creating a Bar Chart.
+
+
The X-Axis can be configured with linear ,log ,
+ time , time-utc .
),
@@ -134,6 +147,9 @@ export const XYChartSeriesExample = {
Use EuiXYChart with EuiVerticalRectSeries for displaying
vertical histograms.
+ The Y-Axis needs can be configured with linear ,log ,
+ time , time-utc .
+ The same for X-Axis.
),
@@ -159,8 +175,11 @@ export const XYChartSeriesExample = {
text: (
- Use EuiXYChart with EuiVerticalRectSeries for displaying
- an horizontal histogram.
+ Use EuiXYChart with EuiHorizontalRectSeries for displaying
+ horizontal histograms.
+ The Y-Axis needs can be configured as linear ,log ,
+ time , time-utc .
+ The same for X-Axis.
),
@@ -187,9 +206,18 @@ export const XYChartSeriesExample = {
Use EuiXYChart with EuiHorizontalBarSeries for displaying
- horizontal bar charts. Use the appropriate yType props to match your
- y value scale. Available values are: ordinal ,linear
+ horizontal stacked bar charts.
+ Specify EuiXYChart props like the following:
+
+
+ yType="ordinal" because we are creating a Bar Chart
+
+
+ stackBy="x" to stack bars one above the other.
+ If stackBy is not specified, bars are clustered together depending on the Y value
+
+
),
props: { EuiHorizontalBarSeries },
@@ -214,10 +242,19 @@ export const XYChartSeriesExample = {
text: (
- Use EuiXYChart with EuiHorizontalBarSeries for displaying
- horizontal bar charts. Use the appropriate yType props to match your
- y value scale. Available values are: ordinal ,linear
+ Use EuiXYChart with EuiVerticalBarSeries for displaying
+ vertical stacked bar charts.
+ Specify EuiXYChart props like the following:
+
+
+ xType="ordinal" because we are creating a Bar Chart
+
+
+ stackBy="y" to stack bars one above the other.
+ If stackBy is not specified, bars are clustered together depending on the X value
+
+
),
props: { EuiHorizontalBarSeries },
@@ -242,10 +279,11 @@ export const XYChartSeriesExample = {
text: (
- Use EuiXYChart with EuiHorizontalBarSeries for displaying
- horizontal bar charts. Use the appropriate yType props to match your
- y value scale. Available values are: ordinal ,linear
+ Use EuiXYChart with EuiVerticalRectSeries for displaying
+ stacked vedrtical histograms.
+
Specify stackBy="x" to stack bars together.
+
Note: Is not possible to "cluster" bars by the same X value.
),
props: { EuiHorizontalBarSeries },
@@ -270,10 +308,11 @@ export const XYChartSeriesExample = {
text: (
- Use EuiXYChart with EuiHorizontalBarSeries for displaying
- horizontal bar charts. Use the appropriate yType props to match your
- y value scale. Available values are: ordinal ,linear
+ Use EuiXYChart with EuiHorizontalRectSeries to display
+ stacked horizontal histograms.
+
Specify stackBy="x" to stack bars together.
+
Note: Is not possible to "cluster" bars by the same Y value.
),
props: { EuiHorizontalBarSeries },
diff --git a/src/components/xy_chart/horizontal_bar_series.js b/src/components/xy_chart/horizontal_bar_series.js
index 000043282932..db60f72f5421 100644
--- a/src/components/xy_chart/horizontal_bar_series.js
+++ b/src/components/xy_chart/horizontal_bar_series.js
@@ -32,10 +32,7 @@ EuiHorizontalBarSeries.propTypes = {
name: PropTypes.string.isRequired,
/** Array<{x: string|number, y: string|number}> */
data: PropTypes.arrayOf(PropTypes.shape({
- x: PropTypes.oneOfType([
- PropTypes.string,
- PropTypes.number
- ]),
+ x: PropTypes.number,
y: PropTypes.oneOfType([
PropTypes.string,
PropTypes.number
diff --git a/src/components/xy_chart/horizontal_rect_series.js b/src/components/xy_chart/horizontal_rect_series.js
index 2d120d3d3add..eb711d96b739 100644
--- a/src/components/xy_chart/horizontal_rect_series.js
+++ b/src/components/xy_chart/horizontal_rect_series.js
@@ -32,14 +32,8 @@ EuiHorizontalRectSeries.propTypes = {
name: PropTypes.string.isRequired,
/** Array<{x: string|number, y: string|number}> */
data: PropTypes.arrayOf(PropTypes.shape({
- x: PropTypes.oneOfType([
- PropTypes.string,
- PropTypes.number
- ]),
- y: PropTypes.oneOfType([
- PropTypes.string,
- PropTypes.number
- ]),
+ x: PropTypes.number,
+ y: PropTypes.number,
})).isRequired,
/** Without a color set, a random EUI color palette color will be chosen */
color: PropTypes.string,
diff --git a/src/components/xy_chart/vertical_bar_series.js b/src/components/xy_chart/vertical_bar_series.js
index 279cc10d8468..ab91174e0306 100644
--- a/src/components/xy_chart/vertical_bar_series.js
+++ b/src/components/xy_chart/vertical_bar_series.js
@@ -34,10 +34,7 @@ EuiVerticalBarSeries.propTypes = {
PropTypes.string,
PropTypes.number
]),
- y: PropTypes.oneOfType([
- PropTypes.string,
- PropTypes.number
- ]),
+ y: PropTypes.number,
})).isRequired,
/** Without a color set, a random EUI color palette color will be chosen */
color: PropTypes.string,
From 70a878378949caf272760c1593c6cc8e7ad1bc1e Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Fri, 1 Jun 2018 19:06:03 +0200
Subject: [PATCH 05/68] Update props types
---
.../views/xy_chart_series/series_example.js | 22 +++++++++++++------
.../xy_chart/horizontal_bar_series.js | 2 +-
.../xy_chart/horizontal_rect_series.js | 3 ++-
.../xy_chart/vertical_bar_series.js | 2 +-
.../xy_chart/vertical_rect_series.js | 13 ++++-------
5 files changed, 23 insertions(+), 19 deletions(-)
diff --git a/src-docs/src/views/xy_chart_series/series_example.js b/src-docs/src/views/xy_chart_series/series_example.js
index 280464f884d4..04a79f10178e 100644
--- a/src-docs/src/views/xy_chart_series/series_example.js
+++ b/src-docs/src/views/xy_chart_series/series_example.js
@@ -10,7 +10,15 @@ import StackedVerticalRectSeriesExample from './stacked_vertical_rect_series';
import VerticalRectSeriesExample from './vertical_rect_series';
import HorizontalRectSeriesExample from './horizontal_rect_series';
import AreaSeriesExample from './area_series';
-import { EuiCode, EuiVerticalBarSeries, EuiHorizontalBarSeries, EuiLine, EuiArea } from '../../../../src/components';
+import {
+ EuiCode,
+ EuiVerticalBarSeries,
+ EuiVerticalRectSeries,
+ EuiHorizontalBarSeries,
+ EuiHorizontalRectSeries,
+ EuiLine,
+ EuiArea,
+} from '../../../../src/components';
export const XYChartSeriesExample = {
title: 'XYChart Series',
@@ -85,7 +93,7 @@ export const XYChartSeriesExample = {
The Y-Axis can be configured with linear ,log ,
- time , time-utc
+ time , time-utc .
),
@@ -153,7 +161,7 @@ export const XYChartSeriesExample = {
),
- props: { EuiVerticalBarSeries },
+ props: { EuiVerticalRectSeries },
source: [
{
type: GuideSectionTypes.JS,
@@ -183,7 +191,7 @@ export const XYChartSeriesExample = {
),
- props: { EuiVerticalBarSeries },
+ props: { EuiHorizontalRectSeries },
source: [
{
type: GuideSectionTypes.JS,
@@ -257,7 +265,7 @@ export const XYChartSeriesExample = {
),
- props: { EuiHorizontalBarSeries },
+ props: { EuiVerticalBarSeries },
source: [
{
type: GuideSectionTypes.JS,
@@ -286,7 +294,7 @@ export const XYChartSeriesExample = {
Note: Is not possible to "cluster" bars by the same X value.
),
- props: { EuiHorizontalBarSeries },
+ props: { EuiVerticalRectSeries },
source: [
{
type: GuideSectionTypes.JS,
@@ -315,7 +323,7 @@ export const XYChartSeriesExample = {
Note: Is not possible to "cluster" bars by the same Y value.
),
- props: { EuiHorizontalBarSeries },
+ props: { EuiHorizontalRectSeries },
source: [
{
type: GuideSectionTypes.JS,
diff --git a/src/components/xy_chart/horizontal_bar_series.js b/src/components/xy_chart/horizontal_bar_series.js
index db60f72f5421..f45431f57a81 100644
--- a/src/components/xy_chart/horizontal_bar_series.js
+++ b/src/components/xy_chart/horizontal_bar_series.js
@@ -30,7 +30,7 @@ export default EuiHorizontalBarSeries;
EuiHorizontalBarSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
name: PropTypes.string.isRequired,
- /** Array<{x: string|number, y: string|number}> */
+ /** Array<{x: number, y: string|number}> */
data: PropTypes.arrayOf(PropTypes.shape({
x: PropTypes.number,
y: PropTypes.oneOfType([
diff --git a/src/components/xy_chart/horizontal_rect_series.js b/src/components/xy_chart/horizontal_rect_series.js
index eb711d96b739..9ac3b94ceb9e 100644
--- a/src/components/xy_chart/horizontal_rect_series.js
+++ b/src/components/xy_chart/horizontal_rect_series.js
@@ -30,10 +30,11 @@ export default EuiHorizontalRectSeries;
EuiHorizontalRectSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
name: PropTypes.string.isRequired,
- /** Array<{x: string|number, y: string|number}> */
+ /** Array<{x: number, y: number, y0: number}> */
data: PropTypes.arrayOf(PropTypes.shape({
x: PropTypes.number,
y: PropTypes.number,
+ y0: PropTypes.number,
})).isRequired,
/** Without a color set, a random EUI color palette color will be chosen */
color: PropTypes.string,
diff --git a/src/components/xy_chart/vertical_bar_series.js b/src/components/xy_chart/vertical_bar_series.js
index ab91174e0306..be95df1d46ed 100644
--- a/src/components/xy_chart/vertical_bar_series.js
+++ b/src/components/xy_chart/vertical_bar_series.js
@@ -28,7 +28,7 @@ export default EuiVerticalBarSeries;
EuiVerticalBarSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
name: PropTypes.string.isRequired,
- /** Array<{x: string|number, y: string|number}> */
+ /** Array<{x: string|number, y: number}> */
data: PropTypes.arrayOf(PropTypes.shape({
x: PropTypes.oneOfType([
PropTypes.string,
diff --git a/src/components/xy_chart/vertical_rect_series.js b/src/components/xy_chart/vertical_rect_series.js
index 83d7a4d69e51..40913d47f280 100644
--- a/src/components/xy_chart/vertical_rect_series.js
+++ b/src/components/xy_chart/vertical_rect_series.js
@@ -29,16 +29,11 @@ export default class EuiVerticalRectSeries extends VerticalRectSeries {
EuiVerticalRectSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
name: PropTypes.string.isRequired,
- /** Array<{x: string|number, y: string|number}> */
+ /** Array<{x0: number, x: number, y: number}> */
data: PropTypes.arrayOf(PropTypes.shape({
- x: PropTypes.oneOfType([
- PropTypes.string,
- PropTypes.number
- ]),
- y: PropTypes.oneOfType([
- PropTypes.string,
- PropTypes.number
- ]),
+ x0: PropTypes.number,
+ x: PropTypes.number,
+ y: PropTypes.number,
})).isRequired,
/** Without a color set, a random EUI color palette color will be chosen */
color: PropTypes.string,
From a75682105fed6e6285a9fb020c1b7ed1416352cf Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Tue, 12 Jun 2018 16:53:05 +0200
Subject: [PATCH 06/68] Add DefaultAxis component
---
.../src/views/xy_chart_series/area_series.js | 3 +-
.../xy_chart_series/horizontal_bar_series.js | 5 +-
.../xy_chart_series/horizontal_rect_series.js | 5 +-
.../src/views/xy_chart_series/line_series.js | 3 +-
.../stacked_horizontal_bar_series.js | 4 +
.../stacked_horizontal_rect_series.js | 4 +
.../stacked_vertical_bar_series.js | 2 +
.../stacked_vertical_rect_series.js | 4 +-
.../xy_chart_series/vertical_bar_series.js | 7 +-
.../xy_chart_series/vertical_rect_series.js | 7 +-
src/components/index.js | 1 +
.../xy_chart/__snapshots__/area.test.js.snap | 8084 ++++-------------
.../xy_chart/__snapshots__/chart.test.js.snap | 1 -
.../xy_chart/__snapshots__/line.test.js.snap | 6594 +++-----------
.../vertical_bar_series.test.js.snap | 1173 ---
.../vertical_rect_series.test.js.snap | 1213 ---
src/components/xy_chart/chart.js | 51 +-
src/components/xy_chart/default_axis.js | 96 +
src/components/xy_chart/index.js | 4 +-
19 files changed, 3196 insertions(+), 14065 deletions(-)
create mode 100644 src/components/xy_chart/default_axis.js
diff --git a/src-docs/src/views/xy_chart_series/area_series.js b/src-docs/src/views/xy_chart_series/area_series.js
index bf849ee40d00..a1625acacce9 100644
--- a/src-docs/src/views/xy_chart_series/area_series.js
+++ b/src-docs/src/views/xy_chart_series/area_series.js
@@ -1,6 +1,6 @@
import React from 'react';
-import { EuiXYChart, EuiArea } from '../../../../src/components';
+import { EuiXYChart, EuiArea, EuiDefaultAxis } from '../../../../src/components';
export default () => (
(
height={200}
>
+
);
diff --git a/src-docs/src/views/xy_chart_series/horizontal_bar_series.js b/src-docs/src/views/xy_chart_series/horizontal_bar_series.js
index 8be242d688f5..7d37dca18e7b 100644
--- a/src-docs/src/views/xy_chart_series/horizontal_bar_series.js
+++ b/src-docs/src/views/xy_chart_series/horizontal_bar_series.js
@@ -1,6 +1,6 @@
import React from 'react';
-import { EuiXYChart, EuiHorizontalBarSeries } from '../../../../src/components';
+import { EuiXYChart, EuiHorizontalBarSeries, EuiDefaultAxis } from '../../../../src/components';
const data = [
{ x: 3, y: 'A' },
@@ -19,5 +19,8 @@ export default () => (
name="Tag counts"
data={data}
/>
+
);
diff --git a/src-docs/src/views/xy_chart_series/horizontal_rect_series.js b/src-docs/src/views/xy_chart_series/horizontal_rect_series.js
index 0c5284747c72..322a4f542476 100644
--- a/src-docs/src/views/xy_chart_series/horizontal_rect_series.js
+++ b/src-docs/src/views/xy_chart_series/horizontal_rect_series.js
@@ -1,6 +1,6 @@
import React from 'react';
-import { EuiXYChart, EuiHorizontalRectSeries } from '../../../../src/components';
+import { EuiXYChart, EuiHorizontalRectSeries, EuiDefaultAxis } from '../../../../src/components';
const data = [
{ x: 3, y: 0, y0: 1 },
@@ -18,5 +18,8 @@ export default () => (
name="Bytes"
data={data}
/>
+
);
diff --git a/src-docs/src/views/xy_chart_series/line_series.js b/src-docs/src/views/xy_chart_series/line_series.js
index 1a2464b4b193..c50bb2fa8558 100644
--- a/src-docs/src/views/xy_chart_series/line_series.js
+++ b/src-docs/src/views/xy_chart_series/line_series.js
@@ -1,6 +1,6 @@
import React from 'react';
-import { EuiXYChart, EuiLine } from '../../../../src/components';
+import { EuiXYChart, EuiLine, EuiDefaultAxis } from '../../../../src/components';
export default () => (
(
height={200}
>
+
);
diff --git a/src-docs/src/views/xy_chart_series/stacked_horizontal_bar_series.js b/src-docs/src/views/xy_chart_series/stacked_horizontal_bar_series.js
index f443646cfea4..3044417f4a1a 100644
--- a/src-docs/src/views/xy_chart_series/stacked_horizontal_bar_series.js
+++ b/src-docs/src/views/xy_chart_series/stacked_horizontal_bar_series.js
@@ -4,6 +4,7 @@ import {
EuiButton,
EuiXYChart,
EuiHorizontalBarSeries,
+ EuiDefaultAxis,
} from '../../../../src/components';
const dataA = [
@@ -61,6 +62,9 @@ export default class extends Component {
name={`Tag B`}
data={dataB}
/>
+
diff --git a/src-docs/src/views/xy_chart_series/stacked_horizontal_rect_series.js b/src-docs/src/views/xy_chart_series/stacked_horizontal_rect_series.js
index e1ddabd91a0e..05d5f36972bf 100644
--- a/src-docs/src/views/xy_chart_series/stacked_horizontal_rect_series.js
+++ b/src-docs/src/views/xy_chart_series/stacked_horizontal_rect_series.js
@@ -3,6 +3,7 @@ import React from 'react';
import {
EuiXYChart,
EuiHorizontalRectSeries,
+ EuiDefaultAxis,
} from '../../../../src/components';
const dataA = [
@@ -37,5 +38,8 @@ export default () => (
data={dataB}
stack={true}
/>
+
);
diff --git a/src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js b/src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js
index 936c093a0e43..9743d82c4fa9 100644
--- a/src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js
+++ b/src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js
@@ -4,6 +4,7 @@ import {
EuiButton,
EuiXYChart,
EuiVerticalBarSeries,
+ EuiDefaultAxis,
} from '../../../../src/components';
const dataA = [
@@ -62,6 +63,7 @@ export default class extends Component {
name={`Tag B`}
data={dataB}
/>
+
diff --git a/src-docs/src/views/xy_chart_series/stacked_vertical_rect_series.js b/src-docs/src/views/xy_chart_series/stacked_vertical_rect_series.js
index 0b28a65858eb..da9cd516a0a3 100644
--- a/src-docs/src/views/xy_chart_series/stacked_vertical_rect_series.js
+++ b/src-docs/src/views/xy_chart_series/stacked_vertical_rect_series.js
@@ -3,6 +3,7 @@ import React from 'react';
import {
EuiXYChart,
EuiVerticalRectSeries,
+ EuiDefaultAxis,
} from '../../../../src/components';
const dataA = [
@@ -35,7 +36,6 @@ export default () => (
name={`Tag B`}
data={dataB}
/>
-
-
+
);
diff --git a/src-docs/src/views/xy_chart_series/vertical_bar_series.js b/src-docs/src/views/xy_chart_series/vertical_bar_series.js
index b609ab00bab8..6365ed608247 100644
--- a/src-docs/src/views/xy_chart_series/vertical_bar_series.js
+++ b/src-docs/src/views/xy_chart_series/vertical_bar_series.js
@@ -1,6 +1,10 @@
import React from 'react';
-import { EuiXYChart, EuiVerticalBarSeries } from '../../../../src/components';
+import {
+ EuiXYChart,
+ EuiVerticalBarSeries,
+ EuiDefaultAxis,
+} from '../../../../src/components';
const data = [
{ x: 'A', y: 3 },
@@ -20,5 +24,6 @@ export default () => (
name="Tags"
data={data}
/>
+
);
diff --git a/src-docs/src/views/xy_chart_series/vertical_rect_series.js b/src-docs/src/views/xy_chart_series/vertical_rect_series.js
index 78ebb4bde151..6c6772ce8fe6 100644
--- a/src-docs/src/views/xy_chart_series/vertical_rect_series.js
+++ b/src-docs/src/views/xy_chart_series/vertical_rect_series.js
@@ -1,6 +1,10 @@
import React from 'react';
-import { EuiXYChart, EuiVerticalRectSeries } from '../../../../src/components';
+import {
+ EuiXYChart,
+ EuiVerticalRectSeries,
+ EuiDefaultAxis,
+} from '../../../../src/components';
const data = [
{ x0: 0, x: 1, y: 1 },
@@ -19,5 +23,6 @@ export default () => (
name="Bytes"
data={data}
/>
+
);
diff --git a/src/components/index.js b/src/components/index.js
index 6382aa9e00db..27c70d831e0b 100644
--- a/src/components/index.js
+++ b/src/components/index.js
@@ -310,4 +310,5 @@ export {
EuiHorizontalBarSeries,
EuiVerticalRectSeries,
EuiHorizontalRectSeries,
+ EuiDefaultAxis,
} from './xy_chart';
diff --git a/src/components/xy_chart/__snapshots__/area.test.js.snap b/src/components/xy_chart/__snapshots__/area.test.js.snap
index 20c9f8225616..b62dcf527bf9 100644
--- a/src/components/xy_chart/__snapshots__/area.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/area.test.js.snap
@@ -16,7 +16,6 @@ exports[`EuiArea all props are rendered 1`] = `
-
-
-
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
+
-
-
-
-
-
-
-
-
-
- 0.0
-
-
-
-
-
- 0.1
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.3
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.5
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.7
-
-
-
-
-
- 0.8
-
-
-
-
-
- 0.9
-
-
-
-
-
- 1.0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
- 14
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`EuiArea is rendered 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
- 0.0
-
-
-
-
-
- 0.1
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.3
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.5
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.7
-
-
-
-
-
- 0.8
-
-
-
-
-
- 0.9
-
-
-
-
-
- 1.0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
-
+
+
-
-
-
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
- 14
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`EuiArea is rendered 1`] = `
+
+
+
+
+
+
+
-
-
-
+
-
-
+
-
-
-
-
-
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
- 0.0
-
-
-
-
-
- 0.1
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.3
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.5
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.7
-
-
-
-
-
- 0.8
-
-
-
-
-
- 0.9
-
-
-
-
-
- 1.0
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
- 14
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`EuiLine is rendered 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0.0
-
-
-
-
-
- 0.1
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.3
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.5
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.7
-
-
-
-
-
- 0.8
-
-
-
-
-
- 0.9
-
-
-
-
-
- 1.0
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
- 14
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`EuiLine is rendered 1`] = `
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -0.4
-
-
-
-
-
- -0.2
-
-
-
-
-
- 0.0
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.8
-
-
-
-
-
- 1.0
-
-
-
-
-
- 1.2
-
-
-
-
-
- 1.4
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
-
-
- 2
-
-
-
-
-
- 4
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
- 14
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- -0.4
-
-
-
-
-
- -0.2
-
-
-
-
-
- 0.0
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.8
-
-
-
-
-
- 1.0
-
-
-
-
-
- 1.2
-
-
-
-
-
- 1.4
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
-
-
- 2
-
-
-
-
-
- 4
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
- 14
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
-
-
- 1
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
-
-
- 2
-
-
-
-
-
- 4
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0.0
-
-
-
-
-
- 0.1
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.3
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.5
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.7
-
-
-
-
-
- 0.8
-
-
-
-
-
- 0.9
-
-
-
-
-
- 1.0
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
-
-
- 2
-
-
-
-
-
- 4
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
- 14
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0.0
-
-
-
-
-
- 0.1
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.3
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.5
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.7
-
-
-
-
-
- 0.8
-
-
-
-
-
- 0.9
-
-
-
-
-
- 1.0
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
-
-
- 2
-
-
-
-
-
- 4
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
- 14
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
-
-
- 1
-
-
-
-
-
-
-
-
-
-
- 0
-
-
-
-
-
- 2
-
-
-
-
-
- 4
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
{
- return v[1];
- });
- }
-
- _getTicks(ticks) {
- if (!ticks) return;
-
- {
- return ticks.map(v => {
- return v[0];
- });
- }
- }
-
_renderChildren = (child, i) => {
const props = {
id: `chart-${i}`,
@@ -135,11 +117,6 @@ export class XYChart extends PureComponent {
yType,
stackBy,
errorText,
- xAxisLocation,
- yAxisLocation,
- showAxis,
- yTicks,
- xTicks,
crosshairX,
showTooltips,
onSelectEnd,
@@ -173,28 +150,6 @@ export class XYChart extends PureComponent {
stackBy={stackBy}
>
- {showAxis && [
- ,
- this._getTickLabels(xTicks)[v] || v : undefined}
- />,
- this._getTickLabels(yTicks)[v] || v : undefined}
- />
- ]}
-
{React.Children.map(children, this._renderChildren)}
{showTooltips && (
@@ -226,7 +181,7 @@ XYChart.propTypes = {
xTicks: PropTypes.array,
yTicks: PropTypes.array, // [[0, "zero"], [1.2, "one mark"], [2.4, "two marks"]]
truncateLegends: PropTypes.bool,
- showAxis: PropTypes.bool,
+ // showAxis: PropTypes.bool,
xAxisLocation: PropTypes.string,
yAxisLocation: PropTypes.string,
showTooltips: PropTypes.bool,
@@ -237,7 +192,7 @@ XYChart.propTypes = {
XYChart.defaultProps = {
truncateLegends: false,
- showAxis: true,
+ // showAxis: true,
showTooltips: true,
};
diff --git a/src/components/xy_chart/default_axis.js b/src/components/xy_chart/default_axis.js
new file mode 100644
index 000000000000..b419af8198d3
--- /dev/null
+++ b/src/components/xy_chart/default_axis.js
@@ -0,0 +1,96 @@
+import React, { Fragment, PureComponent } from 'react';
+import PropTypes from 'prop-types';
+import { XAxis, YAxis, HorizontalGridLines, VerticalGridLines } from 'react-vis';
+
+export default class DefaultAxis extends PureComponent {
+
+ _getTickLabels(ticks) {
+ if (!ticks) return;
+
+ return ticks.map(v => {
+ return v[1];
+ });
+ }
+
+ _getTicks(ticks) {
+ if (!ticks) return;
+
+ {
+ return ticks.map(v => {
+ return v[0];
+ });
+ }
+ }
+
+ render() {
+ const {
+ yTicks,
+ xTicks,
+ xAxisLocation,
+ yAxisLocation,
+ showGridLines,
+ isHorizontal,
+ ...rest } = this.props;
+ return (
+
+ {
+ showGridLines && !isHorizontal &&
+
+ }
+ {
+ showGridLines && isHorizontal &&
+
+ }
+
+ this._getTickLabels(xTicks)[v] || v : undefined}
+ />
+ this._getTickLabels(yTicks)[v] || v : undefined}
+ />
+
+ )
+ }
+}
+
+DefaultAxis.propTypes = {
+ xTicks: PropTypes.array,
+ yTicks: PropTypes.array, // [[0, "zero"], [1.2, "one mark"], [2.4, "two marks"]]
+ xAxisLocation: PropTypes.string,
+ yAxisLocation: PropTypes.string,
+ isHorizontal: PropTypes.boolean,
+ showGridLines: PropTypes.boolean,
+};
+
+DefaultAxis.defaultProps = {
+ isHorizontal: false,
+ showGridLines: true,
+}
+
+DefaultAxis.requiresSVG = true;
diff --git a/src/components/xy_chart/index.js b/src/components/xy_chart/index.js
index 3dafdc19dc30..f83a5cdaf939 100644
--- a/src/components/xy_chart/index.js
+++ b/src/components/xy_chart/index.js
@@ -6,7 +6,8 @@ import EuiVerticalBarSeries from './vertical_bar_series';
import EuiHorizontalBarSeries from './horizontal_bar_series';
import EuiVerticalRectSeries from './vertical_rect_series';
import EuiHorizontalRectSeries from './horizontal_rect_series';
-import{ EuiArea } from './area';
+import EuiDefaultAxis from './default_axis';
+import { EuiArea } from './area';
export {
EuiXYChart,
@@ -16,6 +17,7 @@ export {
EuiHorizontalBarSeries,
EuiVerticalRectSeries,
EuiHorizontalRectSeries,
+ EuiDefaultAxis,
utils,
asSeries
};
From 4a629db1c965cf77d6097ca0c384a71ff7356862 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Wed, 13 Jun 2018 09:48:36 +0200
Subject: [PATCH 07/68] Added first branch of tests for rect and bars
---
.../horizontal_bar_series.test.js.snap | 149 ++++++++++++++++++
.../horizontal_rect_series.test.js.snap | 149 ++++++++++++++++++
.../vertical_bar_series.test.js.snap | 8 +-
.../vertical_rect_series.test.js.snap | 8 +-
.../xy_chart/horizontal_bar_series.test.js | 84 ++++++++++
.../xy_chart/horizontal_rect_series.test.js | 84 ++++++++++
.../xy_chart/vertical_bar_series.test.js | 32 +++-
.../xy_chart/vertical_rect_series.test.js | 25 ++-
8 files changed, 521 insertions(+), 18 deletions(-)
create mode 100644 src/components/xy_chart/__snapshots__/horizontal_bar_series.test.js.snap
create mode 100644 src/components/xy_chart/__snapshots__/horizontal_rect_series.test.js.snap
create mode 100644 src/components/xy_chart/horizontal_bar_series.test.js
create mode 100644 src/components/xy_chart/horizontal_rect_series.test.js
diff --git a/src/components/xy_chart/__snapshots__/horizontal_bar_series.test.js.snap b/src/components/xy_chart/__snapshots__/horizontal_bar_series.test.js.snap
new file mode 100644
index 000000000000..2c9143d2c0df
--- /dev/null
+++ b/src/components/xy_chart/__snapshots__/horizontal_bar_series.test.js.snap
@@ -0,0 +1,149 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`EuiHorizontalBarSeries all props are rendered 1`] = `
+
+`;
+
+exports[`EuiHorizontalBarSeries is rendered 1`] = `
+
+`;
+
+exports[`EuiHorizontalBarSeries renders stacked bar chart 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/src/components/xy_chart/__snapshots__/horizontal_rect_series.test.js.snap b/src/components/xy_chart/__snapshots__/horizontal_rect_series.test.js.snap
new file mode 100644
index 000000000000..ba079e6fbb4d
--- /dev/null
+++ b/src/components/xy_chart/__snapshots__/horizontal_rect_series.test.js.snap
@@ -0,0 +1,149 @@
+// Jest Snapshot v1, https://goo.gl/fbAQLP
+
+exports[`EuiHorizontalRectSeries all props are rendered 1`] = `
+
+`;
+
+exports[`EuiHorizontalRectSeries is rendered 1`] = `
+
+`;
+
+exports[`EuiHorizontalRectSeries renders stacked bar chart 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
diff --git a/src/components/xy_chart/__snapshots__/vertical_bar_series.test.js.snap b/src/components/xy_chart/__snapshots__/vertical_bar_series.test.js.snap
index df34319d51bb..654265554d0c 100644
--- a/src/components/xy_chart/__snapshots__/vertical_bar_series.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/vertical_bar_series.test.js.snap
@@ -41,7 +41,7 @@ exports[`EuiVerticalBarSeries all props are rendered 1`] = `
exports[`EuiVerticalBarSeries is rendered 1`] = `
{
+ test('is rendered', () => {
+ const component = mount(
+
+
+
+ );
+
+ expect(component.find('.rv-xy-plot__series')).toHaveLength(1);
+
+ const rects = component.find('.rv-xy-plot__series--bar rect')
+ expect(rects).toHaveLength(2);
+
+ const firstRectProps = rects.at(0).props()
+ expect(firstRectProps.x).toBeDefined()
+ expect(firstRectProps.y).toBeDefined()
+ expect(firstRectProps.width).toBeDefined()
+ expect(firstRectProps.height).toBeDefined()
+
+ const secondRectProps = rects.at(1).props()
+ expect(secondRectProps.x).toBeDefined()
+ expect(secondRectProps.y).toBeDefined()
+ expect(secondRectProps.width).toBeDefined()
+ expect(secondRectProps.height).toBeDefined()
+
+ expect(component.render()).toMatchSnapshot();
+ });
+
+ test('all props are rendered', () => {
+ const component = render(
+
+ {}}
+ />
+
+ );
+
+ expect(component).toMatchSnapshot();
+ });
+
+ test('renders stacked bar chart', () => {
+ const component = render(
+
+ {}}
+ />
+ {}}
+ />
+
+ );
+ expect(component.find('.rv-xy-plot__series')).toHaveLength(2);
+ expect(component.find('.rv-xy-plot__series--bar rect')).toHaveLength(4);
+ expect(component).toMatchSnapshot();
+ });
+});
diff --git a/src/components/xy_chart/horizontal_rect_series.test.js b/src/components/xy_chart/horizontal_rect_series.test.js
new file mode 100644
index 000000000000..cf67a63fc201
--- /dev/null
+++ b/src/components/xy_chart/horizontal_rect_series.test.js
@@ -0,0 +1,84 @@
+import React from 'react';
+import { render, mount } from 'enzyme';
+import { patchRandom, unpatchRandom } from '../../test/patch_random';
+import { requiredProps } from '../../test/required_props';
+
+import EuiXYChart from './chart';
+import EuiHorizontalRectSeries from './horizontal_rect_series';
+
+beforeEach(patchRandom);
+afterEach(unpatchRandom);
+
+describe('EuiHorizontalRectSeries', () => {
+ test('is rendered', () => {
+ const component = mount(
+
+
+
+ );
+
+ expect(component.find('.rv-xy-plot__series')).toHaveLength(1);
+
+ const rects = component.find('.rv-xy-plot__series--rect rect')
+ expect(rects).toHaveLength(2);
+
+ const firstRectProps = rects.at(0).props()
+ expect(firstRectProps.x).toBeDefined()
+ expect(firstRectProps.y).toBeDefined()
+ expect(firstRectProps.width).toBeDefined()
+ expect(firstRectProps.height).toBeDefined()
+
+ const secondRectProps = rects.at(1).props()
+ expect(secondRectProps.x).toBeDefined()
+ expect(secondRectProps.y).toBeDefined()
+ expect(secondRectProps.width).toBeDefined()
+ expect(secondRectProps.height).toBeDefined()
+
+ expect(component.render()).toMatchSnapshot();
+ });
+
+ test('all props are rendered', () => {
+ const component = render(
+
+ {}}
+ />
+
+ );
+
+ expect(component).toMatchSnapshot();
+ });
+
+ test('renders stacked bar chart', () => {
+ const component = render(
+
+ {}}
+ />
+ {}}
+ />
+
+ );
+ expect(component.find('.rv-xy-plot__series')).toHaveLength(2);
+ expect(component.find('.rv-xy-plot__series--rect rect')).toHaveLength(4);
+ expect(component).toMatchSnapshot();
+ });
+});
diff --git a/src/components/xy_chart/vertical_bar_series.test.js b/src/components/xy_chart/vertical_bar_series.test.js
index 8976e8988485..f837305035af 100644
--- a/src/components/xy_chart/vertical_bar_series.test.js
+++ b/src/components/xy_chart/vertical_bar_series.test.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { render } from 'enzyme';
+import { render, mount } from 'enzyme';
import { patchRandom, unpatchRandom } from '../../test/patch_random';
import { requiredProps } from '../../test/required_props';
@@ -12,7 +12,7 @@ afterEach(unpatchRandom);
describe('EuiVerticalBarSeries', () => {
test('is rendered', () => {
- const component = render(
+ const component = mount(
{
);
- expect(component).toMatchSnapshot();
+ expect(component.find('.rv-xy-plot__series')).toHaveLength(1);
+
+ const rects = component.find('.rv-xy-plot__series--bar rect')
+ expect(rects).toHaveLength(2);
+
+ const firstRectProps = rects.at(0).props()
+ expect(firstRectProps.x).toBeDefined()
+ expect(firstRectProps.y).toBeDefined()
+ expect(firstRectProps.width).toBeDefined()
+ expect(firstRectProps.height).toBeDefined()
+
+ const secondRectProps = rects.at(1).props()
+ expect(secondRectProps.x).toBeDefined()
+ expect(secondRectProps.y).toBeDefined()
+ expect(secondRectProps.width).toBeDefined()
+ expect(secondRectProps.height).toBeDefined()
+
+ expect(component.render()).toMatchSnapshot();
});
test('all props are rendered', () => {
@@ -61,12 +78,13 @@ describe('EuiVerticalBarSeries', () => {
/>
);
-
+ expect(component.find('.rv-xy-plot__series')).toHaveLength(2);
+ expect(component.find('.rv-xy-plot__series--bar rect')).toHaveLength(4);
expect(component).toMatchSnapshot();
});
- describe('performance', () => {
- it.skip('renders 1000 items in under 0.5 seconds', () => {
+ describe.skip('performance', () => {
+ it('renders 1000 items in under 0.5 seconds', () => {
const yTicks = [[0, 'zero'], [1, 'one']];
const xTicks = [
[0, '0'],
@@ -95,7 +113,7 @@ describe('EuiVerticalBarSeries', () => {
expect(runtime).toBeLessThan(500);
});
- it.skip('renders 30 lines of 500 items in under 3 seconds', () => {
+ it('renders 30 lines of 500 items in under 3 seconds', () => {
const yTicks = [[0, 'zero'], [1, 'one']];
const xTicks = [
[0, '0'],
diff --git a/src/components/xy_chart/vertical_rect_series.test.js b/src/components/xy_chart/vertical_rect_series.test.js
index 5576d23b17a4..c4f892fb78f9 100644
--- a/src/components/xy_chart/vertical_rect_series.test.js
+++ b/src/components/xy_chart/vertical_rect_series.test.js
@@ -1,5 +1,5 @@
import React from 'react';
-import { render } from 'enzyme';
+import { render, mount } from 'enzyme';
import { patchRandom, unpatchRandom } from '../../test/patch_random';
import { requiredProps } from '../../test/required_props';
@@ -12,7 +12,7 @@ afterEach(unpatchRandom);
describe('EuiVerticalRectSeries', () => {
test('is rendered', () => {
- const component = render(
+ const component = mount(
{
);
- expect(component).toMatchSnapshot();
+ expect(component.find('.rv-xy-plot__series')).toHaveLength(1);
+
+ const rects = component.find('.rv-xy-plot__series--rect rect')
+ expect(rects).toHaveLength(2);
+
+ const firstRectProps = rects.at(0).props()
+ expect(firstRectProps.x).toBeDefined()
+ expect(firstRectProps.y).toBeDefined()
+ expect(firstRectProps.width).toBeDefined()
+ expect(firstRectProps.height).toBeDefined()
+
+ const secondRectProps = rects.at(1).props()
+ expect(secondRectProps.x).toBeDefined()
+ expect(secondRectProps.y).toBeDefined()
+ expect(secondRectProps.width).toBeDefined()
+ expect(secondRectProps.height).toBeDefined()
+
+ expect(component.render()).toMatchSnapshot();
});
test('all props are rendered', () => {
@@ -61,6 +78,8 @@ describe('EuiVerticalRectSeries', () => {
/>
);
+ expect(component.find('.rv-xy-plot__series')).toHaveLength(2);
+ expect(component.find('.rv-xy-plot__series--rect rect')).toHaveLength(4);
expect(component).toMatchSnapshot();
});
From 2daf1a78d55e567b19ad2e5197e7853b40aa3796 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Wed, 13 Jun 2018 15:48:20 +0200
Subject: [PATCH 08/68] Refactoring chart docs
* Splitted into line, area, bar, histogram
* Added new line chart examples
---
src-docs/src/routes.js | 18 +-
.../src/views/xy_chart_area/area_example.js | 68 +
.../area_series.js | 13 +-
.../xy_chart_area/stacked_area_series.js | 33 +
.../src/views/xy_chart_bar/bar_example.js | 161 +
.../horizontal_bar_series.js | 0
.../stacked_horizontal_bar_series.js | 0
.../stacked_vertical_bar_series.js | 0
.../vertical_bar_series.js | 0
.../xy_chart_histogram/histogram_example.js | 136 +
.../horizontal_rect_series.js | 0
.../stacked_horizontal_rect_series.js | 0
.../stacked_vertical_rect_series.js | 0
.../vertical_rect_series.js | 0
.../src/views/xy_chart_line/curved_line.js | 72 +
.../views/xy_chart_line/custom_domain_line.js | 30 +
.../views/xy_chart_line/custom_style_line.js | 127 +
.../line_series.js => xy_chart_line/line.js} | 14 +-
.../src/views/xy_chart_line/line_example.js | 153 +
.../src/views/xy_chart_line/multi_line.js | 36 +
.../views/xy_chart_series/series_example.js | 344 --
.../xy_chart/__snapshots__/area.test.js.snap | 4463 +++--------------
.../xy_chart/__snapshots__/line.test.js.snap | 16 +-
src/components/xy_chart/area.js | 4 +-
src/components/xy_chart/chart.js | 14 +-
src/components/xy_chart/default_axis.js | 10 +-
src/components/xy_chart/line.js | 72 +-
yarn.lock | 92 +-
28 files changed, 1667 insertions(+), 4209 deletions(-)
create mode 100644 src-docs/src/views/xy_chart_area/area_example.js
rename src-docs/src/views/{xy_chart_series => xy_chart_area}/area_series.js (57%)
create mode 100644 src-docs/src/views/xy_chart_area/stacked_area_series.js
create mode 100644 src-docs/src/views/xy_chart_bar/bar_example.js
rename src-docs/src/views/{xy_chart_series => xy_chart_bar}/horizontal_bar_series.js (100%)
rename src-docs/src/views/{xy_chart_series => xy_chart_bar}/stacked_horizontal_bar_series.js (100%)
rename src-docs/src/views/{xy_chart_series => xy_chart_bar}/stacked_vertical_bar_series.js (100%)
rename src-docs/src/views/{xy_chart_series => xy_chart_bar}/vertical_bar_series.js (100%)
create mode 100644 src-docs/src/views/xy_chart_histogram/histogram_example.js
rename src-docs/src/views/{xy_chart_series => xy_chart_histogram}/horizontal_rect_series.js (100%)
rename src-docs/src/views/{xy_chart_series => xy_chart_histogram}/stacked_horizontal_rect_series.js (100%)
rename src-docs/src/views/{xy_chart_series => xy_chart_histogram}/stacked_vertical_rect_series.js (100%)
rename src-docs/src/views/{xy_chart_series => xy_chart_histogram}/vertical_rect_series.js (100%)
create mode 100644 src-docs/src/views/xy_chart_line/curved_line.js
create mode 100644 src-docs/src/views/xy_chart_line/custom_domain_line.js
create mode 100644 src-docs/src/views/xy_chart_line/custom_style_line.js
rename src-docs/src/views/{xy_chart_series/line_series.js => xy_chart_line/line.js} (56%)
create mode 100644 src-docs/src/views/xy_chart_line/line_example.js
create mode 100644 src-docs/src/views/xy_chart_line/multi_line.js
delete mode 100644 src-docs/src/views/xy_chart_series/series_example.js
diff --git a/src-docs/src/routes.js b/src-docs/src/routes.js
index 6263d220b6b4..a20e0e69cdee 100644
--- a/src-docs/src/routes.js
+++ b/src-docs/src/routes.js
@@ -207,8 +207,17 @@ import { ToolTipExample }
import { XYChartExample }
from './views/xy_chart/xy_chart_example';
-import { XYChartSeriesExample }
- from './views/xy_chart_series/series_example'
+import { XYChartBarExample }
+ from './views/xy_chart_bar/bar_example';
+
+import { XYChartHistogramExample }
+ from './views/xy_chart_histogram/histogram_example';
+
+import { XYChartAreaExample }
+ from './views/xy_chart_area/area_example';
+
+import { XYChartLineExample }
+ from './views/xy_chart_line/line_example';
import { Changelog }
from './views/package/changelog';
@@ -330,7 +339,10 @@ const navigation = [{
name: 'Charts',
items: [
XYChartExample,
- XYChartSeriesExample,
+ XYChartLineExample,
+ XYChartAreaExample,
+ XYChartBarExample,
+ XYChartHistogramExample,
].map(example => createExample(example)),
}, {
name: 'Forms',
diff --git a/src-docs/src/views/xy_chart_area/area_example.js b/src-docs/src/views/xy_chart_area/area_example.js
new file mode 100644
index 000000000000..7bd2609bc0f6
--- /dev/null
+++ b/src-docs/src/views/xy_chart_area/area_example.js
@@ -0,0 +1,68 @@
+import React from 'react';
+import { GuideSectionTypes } from '../../components';
+import AreaSeriesExample from './area_series';
+import StackedAreaSeriesExample from './stacked_area_series';
+import {
+ EuiCode,
+ EuiArea,
+} from '../../../../src/components';
+
+export const XYChartAreaExample = {
+ title: 'XYChart Area',
+ sections: [
+ {
+ title: 'Area Series',
+ text: (
+
+
+ Use EuiXYChart to display line, bar, area, and stream charts. Note that charts are composed with{' '}
+ EuiLine , EuiArea , EuiBar , and EuiStream being child
+ components.
+
+
+ ),
+ props: { EuiArea },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./area_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+ )
+ },
+ {
+ title: 'Stacked Area Series',
+ text: (
+
+ ),
+ props: { EuiArea },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./stacked_area_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ ]
+};
diff --git a/src-docs/src/views/xy_chart_series/area_series.js b/src-docs/src/views/xy_chart_area/area_series.js
similarity index 57%
rename from src-docs/src/views/xy_chart_series/area_series.js
rename to src-docs/src/views/xy_chart_area/area_series.js
index a1625acacce9..e551d93b8157 100644
--- a/src-docs/src/views/xy_chart_series/area_series.js
+++ b/src-docs/src/views/xy_chart_area/area_series.js
@@ -2,12 +2,23 @@ import React from 'react';
import { EuiXYChart, EuiArea, EuiDefaultAxis } from '../../../../src/components';
+const DATA_A = [
+ { x: 0, y: 1 },
+ { x: 1, y: 1 },
+ { x: 2, y: 2 },
+ { x: 3, y: 1 },
+ { x: 5, y: 2 },
+];
+
export default () => (
-
+
);
diff --git a/src-docs/src/views/xy_chart_area/stacked_area_series.js b/src-docs/src/views/xy_chart_area/stacked_area_series.js
new file mode 100644
index 000000000000..03b60e9f7c5f
--- /dev/null
+++ b/src-docs/src/views/xy_chart_area/stacked_area_series.js
@@ -0,0 +1,33 @@
+import React from 'react';
+
+import { EuiXYChart, EuiLine, EuiDefaultAxis } from '../../../../src/components';
+
+const dataA = [
+ { x: 0, y: 3, },
+ { x: 1, y: 2, },
+ { x: 2, y: 1, },
+ { x: 3, y: 2, },
+ { x: 4, y: 3, },
+];
+
+const dataB = [
+ { x: 0, y: 1 },
+ { x: 1, y: 1 },
+ { x: 2, y: 4 },
+ { x: 3, y: 1 },
+ { x: 4, y: 1 },
+];
+
+export default () => (
+
+ {/*
+ */}
+
+
+
+
+);
diff --git a/src-docs/src/views/xy_chart_bar/bar_example.js b/src-docs/src/views/xy_chart_bar/bar_example.js
new file mode 100644
index 000000000000..63019624d66e
--- /dev/null
+++ b/src-docs/src/views/xy_chart_bar/bar_example.js
@@ -0,0 +1,161 @@
+import React from 'react';
+import { GuideSectionTypes } from '../../components';
+import VerticalBarSeriesExample from './vertical_bar_series';
+import HorizontalBarSeriesExample from './horizontal_bar_series';
+import StackedVerticalBarSeriesExample from './stacked_vertical_bar_series';
+import StackedHorizontalBarSeriesExample from './stacked_horizontal_bar_series';
+
+import {
+ EuiCode,
+ EuiVerticalBarSeries,
+ EuiHorizontalBarSeries,
+} from '../../../../src/components';
+
+export const XYChartBarExample = {
+ title: 'XYChart Bar Chart',
+ sections: [
+ {
+ title: 'Vertical Bar Chart',
+ text: (
+
+
+ Use EuiXYChart with EuiVerticalBarSeries for displaying
+ vertical bar charts.
+
+
+ Specify EuiXYChart prop xType="ordinal"
+ because we are creating a Bar Chart.
+
+
+ The Y-Axis can be configured with linear ,log ,
+ time , time-utc .
+
+
+ ),
+ props: { EuiVerticalBarSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./vertical_bar_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ {
+ title: 'Stacked Vertical Bar Chart',
+ text: (
+
+
+ Use EuiXYChart with EuiVerticalBarSeries for displaying
+ vertical stacked bar charts.
+ Specify EuiXYChart props like the following:
+
+
+
+ xType="ordinal" because we are creating a Bar Chart
+
+
+ stackBy="y" to stack bars one above the other.
+ If stackBy is not specified, bars are clustered together depending on the X value
+
+
+
+ ),
+ props: { EuiVerticalBarSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./stacked_vertical_bar_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ {
+ title: 'Horizontal Bar Chart',
+ text: (
+
+
+ Use EuiXYChart with EuiHorizontalBarSeries for displaying
+ horizontal bar charts.
+
+
+ Specify EuiXYChart prop yType="ordinal"
+ because we are creating a Bar Chart.
+
+
The X-Axis can be configured with linear ,log ,
+ time , time-utc .
+
+
+ ),
+ props: { EuiHorizontalBarSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./horizontal_bar_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ {
+ title: 'Stacked Horizontal Bar Chart',
+ text: (
+
+
+ Use EuiXYChart with EuiHorizontalBarSeries for displaying
+ horizontal stacked bar charts.
+ Specify EuiXYChart props like the following:
+
+
+
+ yType="ordinal" because we are creating a Bar Chart
+
+
+ stackBy="x" to stack bars one above the other.
+ If stackBy is not specified, bars are clustered together depending on the Y value
+
+
+
+ ),
+ props: { EuiHorizontalBarSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./stacked_horizontal_bar_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ ]
+};
diff --git a/src-docs/src/views/xy_chart_series/horizontal_bar_series.js b/src-docs/src/views/xy_chart_bar/horizontal_bar_series.js
similarity index 100%
rename from src-docs/src/views/xy_chart_series/horizontal_bar_series.js
rename to src-docs/src/views/xy_chart_bar/horizontal_bar_series.js
diff --git a/src-docs/src/views/xy_chart_series/stacked_horizontal_bar_series.js b/src-docs/src/views/xy_chart_bar/stacked_horizontal_bar_series.js
similarity index 100%
rename from src-docs/src/views/xy_chart_series/stacked_horizontal_bar_series.js
rename to src-docs/src/views/xy_chart_bar/stacked_horizontal_bar_series.js
diff --git a/src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js b/src-docs/src/views/xy_chart_bar/stacked_vertical_bar_series.js
similarity index 100%
rename from src-docs/src/views/xy_chart_series/stacked_vertical_bar_series.js
rename to src-docs/src/views/xy_chart_bar/stacked_vertical_bar_series.js
diff --git a/src-docs/src/views/xy_chart_series/vertical_bar_series.js b/src-docs/src/views/xy_chart_bar/vertical_bar_series.js
similarity index 100%
rename from src-docs/src/views/xy_chart_series/vertical_bar_series.js
rename to src-docs/src/views/xy_chart_bar/vertical_bar_series.js
diff --git a/src-docs/src/views/xy_chart_histogram/histogram_example.js b/src-docs/src/views/xy_chart_histogram/histogram_example.js
new file mode 100644
index 000000000000..da70522970d9
--- /dev/null
+++ b/src-docs/src/views/xy_chart_histogram/histogram_example.js
@@ -0,0 +1,136 @@
+import React from 'react';
+import { GuideSectionTypes } from '../../components';
+import VerticalRectSeriesExample from './vertical_rect_series';
+import StackedVerticalRectSeriesExample from './stacked_vertical_rect_series';
+import HorizontalRectSeriesExample from './horizontal_rect_series';
+import StackedHorizontalRectSeriesExample from './stacked_horizontal_rect_series';
+
+import {
+ EuiCode,
+ EuiVerticalRectSeries,
+ EuiHorizontalRectSeries,
+} from '../../../../src/components';
+
+export const XYChartHistogramExample = {
+ title: 'XYChart Histogram',
+ sections: [
+ {
+ title: 'Vertical Histogram',
+ text: (
+
+
+ Use EuiXYChart with EuiVerticalRectSeries for displaying
+ vertical histograms.
+ The Y-Axis needs can be configured with linear ,log ,
+ time , time-utc .
+ The same for X-Axis.
+
+
+ ),
+ props: { EuiVerticalRectSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./vertical_rect_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ {
+ title: 'Stacked Vertical Histogram',
+ text: (
+
+
+ Use EuiXYChart with EuiVerticalRectSeries for displaying
+ stacked vedrtical histograms.
+
+
Specify stackBy="x" to stack bars together.
+
Note: Is not possible to "cluster" bars by the same X value.
+
+ ),
+ props: { EuiVerticalRectSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./stacked_vertical_rect_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ {
+ title: 'Horizontal Histogram',
+ text: (
+
+
+ Use EuiXYChart with EuiHorizontalRectSeries for displaying
+ horizontal histograms.
+ The Y-Axis needs can be configured as linear ,log ,
+ time , time-utc .
+ The same for X-Axis.
+
+
+ ),
+ props: { EuiHorizontalRectSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./vertical_rect_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ {
+ title: 'Stacked Horizontal Histogram',
+ text: (
+
+
+ Use EuiXYChart with EuiHorizontalRectSeries to display
+ stacked horizontal histograms.
+
+
Specify stackBy="x" to stack bars together.
+
Note: Is not possible to "cluster" bars by the same Y value.
+
+ ),
+ props: { EuiHorizontalRectSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./stacked_horizontal_rect_series')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ ]
+};
diff --git a/src-docs/src/views/xy_chart_series/horizontal_rect_series.js b/src-docs/src/views/xy_chart_histogram/horizontal_rect_series.js
similarity index 100%
rename from src-docs/src/views/xy_chart_series/horizontal_rect_series.js
rename to src-docs/src/views/xy_chart_histogram/horizontal_rect_series.js
diff --git a/src-docs/src/views/xy_chart_series/stacked_horizontal_rect_series.js b/src-docs/src/views/xy_chart_histogram/stacked_horizontal_rect_series.js
similarity index 100%
rename from src-docs/src/views/xy_chart_series/stacked_horizontal_rect_series.js
rename to src-docs/src/views/xy_chart_histogram/stacked_horizontal_rect_series.js
diff --git a/src-docs/src/views/xy_chart_series/stacked_vertical_rect_series.js b/src-docs/src/views/xy_chart_histogram/stacked_vertical_rect_series.js
similarity index 100%
rename from src-docs/src/views/xy_chart_series/stacked_vertical_rect_series.js
rename to src-docs/src/views/xy_chart_histogram/stacked_vertical_rect_series.js
diff --git a/src-docs/src/views/xy_chart_series/vertical_rect_series.js b/src-docs/src/views/xy_chart_histogram/vertical_rect_series.js
similarity index 100%
rename from src-docs/src/views/xy_chart_series/vertical_rect_series.js
rename to src-docs/src/views/xy_chart_histogram/vertical_rect_series.js
diff --git a/src-docs/src/views/xy_chart_line/curved_line.js b/src-docs/src/views/xy_chart_line/curved_line.js
new file mode 100644
index 000000000000..4a2229e4d8bf
--- /dev/null
+++ b/src-docs/src/views/xy_chart_line/curved_line.js
@@ -0,0 +1,72 @@
+import React, { Component, Fragment } from 'react';
+
+import {
+ EuiSelect,
+ EuiSpacer,
+ EuiXYChart,
+ EuiLine,
+ EuiDefaultAxis } from '../../../../src/components';
+
+const DATA_A = [
+ { x: 0, y: 1 },
+ { x: 1, y: 1 },
+ { x: 2, y: 2 },
+ { x: 3, y: -1 },
+ { x: 5, y: 2 },
+];
+
+export default class extends Component {
+ constructor(props) {
+ super(props);
+
+ this.options = [
+ { value: 'linear', text: 'Linear' },
+ { value: 'curveCardinal', text: 'Curve Cardinal' },
+ { value: 'curveNatural', text: 'Curve Natural' },
+ { value: 'curveMonotoneX', text: 'Curve Monotone X' },
+ { value: 'curveMonotoneY', text: 'Curve Monotone Y' },
+ { value: 'curveBasis', text: 'Curve Basis' },
+ { value: 'curveBundle', text: 'Curve Bundle' },
+ { value: 'curveCatmullRom', text: 'Curve Catmull Rom' },
+ { value: 'curveStep', text: 'Curve Step' },
+ { value: 'curveStepAfter', text: 'Curve Step After' },
+ { value: 'curveStepBefore', text: 'Curve Step Before' },
+ ];
+
+ this.state = {
+ value: this.options[0].value,
+ };
+ }
+
+ onChange = e => {
+ this.setState({
+ value: e.target.value,
+ });
+ };
+
+ render() {
+ return (
+
+
+
+
+
+
+
+
+
+
+ )
+ }
+}
diff --git a/src-docs/src/views/xy_chart_line/custom_domain_line.js b/src-docs/src/views/xy_chart_line/custom_domain_line.js
new file mode 100644
index 000000000000..bf5bbfc84694
--- /dev/null
+++ b/src-docs/src/views/xy_chart_line/custom_domain_line.js
@@ -0,0 +1,30 @@
+import React from 'react';
+
+import { EuiXYChart, EuiLine, EuiDefaultAxis } from '../../../../src/components';
+
+const X_DOMAIN = [ -1, 6 ];
+const Y_DOMAIN = [ 0, 3 ];
+
+const DATA_A = [
+ { x: 0, y: 1 },
+ { x: 1, y: 1 },
+ { x: 2, y: 2 },
+ { x: 3, y: 1 },
+ { x: 5, y: 2 },
+];
+
+export default () => (
+
+
+
+
+
+);
diff --git a/src-docs/src/views/xy_chart_line/custom_style_line.js b/src-docs/src/views/xy_chart_line/custom_style_line.js
new file mode 100644
index 000000000000..f6a97df3ae0a
--- /dev/null
+++ b/src-docs/src/views/xy_chart_line/custom_style_line.js
@@ -0,0 +1,127 @@
+import React, { Component, Fragment } from 'react';
+
+import {
+ EuiForm,
+ EuiFormRow,
+ EuiRange,
+ EuiSpacer,
+ EuiXYChart,
+ EuiLine,
+ EuiDefaultAxis,
+ EuiCheckboxGroup,
+} from '../../../../src/components';
+
+import makeId from '../../../../src/components/form/form_row/make_id';
+
+
+const DATA_A = [
+ { x: 0, y: 1 },
+ { x: 1, y: 1 },
+ { x: 2, y: 2 },
+ { x: 3, y: -1 },
+ { x: 5, y: 2 },
+];
+
+export default class extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ lineMarkSize: '4',
+ lineSize: '2',
+ lineProps: [
+ {
+ id: `showLine`,
+ label: 'Show Line',
+ },
+ {
+ id: `showLineMarks`,
+ label: 'Show Line Marks',
+ },
+ ],
+ linePropsIdToSelectedMap: {
+ showLine: true,
+ showLineMarks: true,
+ },
+ };
+ };
+
+ onLinePropsChange = optionId => {
+ const newLinePropsIdToSelectedMap = ({ ...this.state.linePropsIdToSelectedMap, ...{
+ [optionId]: !this.state.linePropsIdToSelectedMap[optionId],
+ } });
+
+ this.setState({
+ linePropsIdToSelectedMap: newLinePropsIdToSelectedMap,
+ });
+ };
+
+ onChangeLineSize = e => {
+ this.setState({
+ lineSize: e.target.value,
+ });
+ };
+
+ onChangeLineMarkSize = e => {
+ this.setState({
+ lineMarkSize: e.target.value,
+ });
+ };
+
+ render() {
+ const { linePropsIdToSelectedMap: { showLine, showLineMarks }, lineSize, lineMarkSize } = this.state
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+ }
+}
diff --git a/src-docs/src/views/xy_chart_series/line_series.js b/src-docs/src/views/xy_chart_line/line.js
similarity index 56%
rename from src-docs/src/views/xy_chart_series/line_series.js
rename to src-docs/src/views/xy_chart_line/line.js
index c50bb2fa8558..daa9c6db2df5 100644
--- a/src-docs/src/views/xy_chart_series/line_series.js
+++ b/src-docs/src/views/xy_chart_line/line.js
@@ -2,12 +2,24 @@ import React from 'react';
import { EuiXYChart, EuiLine, EuiDefaultAxis } from '../../../../src/components';
+const DATA_A = [
+ { x: 0, y: 1 },
+ { x: 1, y: 1 },
+ { x: 2, y: 2 },
+ { x: 3, y: -1 },
+ { x: 5, y: 2 },
+];
+
export default () => (
-
+
+
);
diff --git a/src-docs/src/views/xy_chart_line/line_example.js b/src-docs/src/views/xy_chart_line/line_example.js
new file mode 100644
index 000000000000..141fbfda2172
--- /dev/null
+++ b/src-docs/src/views/xy_chart_line/line_example.js
@@ -0,0 +1,153 @@
+import React from 'react';
+import { GuideSectionTypes } from '../../components';
+import LineChartExample from './line';
+import CustomDomainLineChartExample from './custom_domain_line';
+import MultiLineChartExample from './multi_line';
+import CurvedLineChartExample from './curved_line';
+import CustomStyleLineChartExample from './custom_style_line';
+import {
+ EuiCode,
+ EuiLine,
+ EuiLink,
+} from '../../../../src/components';
+
+export const XYChartLineExample = {
+ title: 'XYChart Line',
+ sections: [
+ {
+ title: 'Line chart',
+ text: (
+
+
+ Use EuiLine to display line charts. The chart domain
+ will cover the whole extent and doesn't add any padding.
+
+
+ ),
+ props: { EuiLine },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./line')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ {
+ title: 'Custom domain line chart',
+ text: (
+
+
+ Use EuiLine to display line charts.
+ Specify xDomain and/or yDomain
+ props to use custom domains.
+
+
+ ),
+ props: { EuiLine },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./custom_domain_line')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ {
+ title: 'Multi Line chart',
+ text: (
+
+
+ Use multiple EuiLine to display a milti-line chart.
+
+
+ ),
+ props: { EuiLine },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./multi_line')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ {
+ title: 'Curved Line chart',
+ text: (
+
+
+ Use the curve prop to change the curve representation.
+ Visit d3-shape#curves
+ for all possible values.
+
+
+ ),
+ props: { EuiLine },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./curved_line')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ {
+ title: 'Custom style Line chart',
+ text: (
+
+
+ Use multiple EuiLine to display a milti-line chart.
+
+
+ ),
+ props: { EuiLine },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./custom_style_line')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ ]
+};
diff --git a/src-docs/src/views/xy_chart_line/multi_line.js b/src-docs/src/views/xy_chart_line/multi_line.js
new file mode 100644
index 000000000000..baf3dfe6cc4f
--- /dev/null
+++ b/src-docs/src/views/xy_chart_line/multi_line.js
@@ -0,0 +1,36 @@
+import React from 'react';
+
+import { EuiXYChart, EuiLine, EuiDefaultAxis } from '../../../../src/components';
+
+const DATA_A = [
+ { x: 0, y: 1 },
+ { x: 1, y: 1 },
+ { x: 2, y: 2 },
+ { x: 3, y: -1 },
+ { x: 5, y: 2 },
+];
+const DATA_B = [
+ { x: 0, y: 3 },
+ { x: 1, y: 4 },
+ { x: 2, y: 1 },
+ { x: 3, y: 2 },
+ { x: 5, y: 5 },
+];
+
+export default () => (
+
+
+
+
+
+
+);
diff --git a/src-docs/src/views/xy_chart_series/series_example.js b/src-docs/src/views/xy_chart_series/series_example.js
deleted file mode 100644
index 04a79f10178e..000000000000
--- a/src-docs/src/views/xy_chart_series/series_example.js
+++ /dev/null
@@ -1,344 +0,0 @@
-import React from 'react';
-import { GuideSectionTypes } from '../../components';
-import LineSeriesExample from './line_series';
-import VerticalBarSeriesExample from './vertical_bar_series';
-import HorizontalBarSeriesExample from './horizontal_bar_series';
-import StackedHorizontalBarSeriesExample from './stacked_horizontal_bar_series';
-import StackedHorizontalRectSeriesExample from './stacked_horizontal_rect_series';
-import StackedVerticalBarSeriesExample from './stacked_vertical_bar_series';
-import StackedVerticalRectSeriesExample from './stacked_vertical_rect_series';
-import VerticalRectSeriesExample from './vertical_rect_series';
-import HorizontalRectSeriesExample from './horizontal_rect_series';
-import AreaSeriesExample from './area_series';
-import {
- EuiCode,
- EuiVerticalBarSeries,
- EuiVerticalRectSeries,
- EuiHorizontalBarSeries,
- EuiHorizontalRectSeries,
- EuiLine,
- EuiArea,
-} from '../../../../src/components';
-
-export const XYChartSeriesExample = {
- title: 'XYChart Series',
- sections: [
- {
- title: 'Line Series',
- text: (
-
-
- Use EuiXYChart to display line, bar, area, and stream charts. Note that charts are composed with{' '}
- EuiLine , EuiArea , EuiBar , and EuiStream being child
- components.
-
-
- ),
- props: { EuiLine },
- source: [
- {
- type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./line_series')
- },
- {
- type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
- ],
- demo: (
-
-
-
- )
- },
- {
- title: 'Area Series',
- text: (
-
-
- Use EuiXYChart to display line, bar, area, and stream charts. Note that charts are composed with{' '}
- EuiLine , EuiArea , EuiBar , and EuiStream being child
- components.
-
-
- ),
- props: { EuiArea },
- source: [
- {
- type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./area_series')
- },
- {
- type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
- ],
- demo: (
-
- )
- },
- {
- title: 'Vertical Bar Chart',
- text: (
-
-
- Use EuiXYChart with EuiVerticalBarSeries for displaying
- vertical bar charts.
-
-
- Specify EuiXYChart prop xType="ordinal"
- because we are creating a Bar Chart.
-
-
- The Y-Axis can be configured with linear ,log ,
- time , time-utc .
-
-
- ),
- props: { EuiVerticalBarSeries },
- source: [
- {
- type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./vertical_bar_series')
- },
- {
- type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
- ],
- demo: (
-
-
-
- )
- },
- {
- title: 'Horizontal Bar Chart',
- text: (
-
-
- Use EuiXYChart with EuiHorizontalBarSeries for displaying
- horizontal bar charts.
-
-
- Specify EuiXYChart prop yType="ordinal"
- because we are creating a Bar Chart.
-
-
The X-Axis can be configured with linear ,log ,
- time , time-utc .
-
-
- ),
- props: { EuiHorizontalBarSeries },
- source: [
- {
- type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./horizontal_bar_series')
- },
- {
- type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
- ],
- demo: (
-
-
-
- )
- },
- {
- title: 'Vertical Histogram',
- text: (
-
-
- Use EuiXYChart with EuiVerticalRectSeries for displaying
- vertical histograms.
- The Y-Axis needs can be configured with linear ,log ,
- time , time-utc .
- The same for X-Axis.
-
-
- ),
- props: { EuiVerticalRectSeries },
- source: [
- {
- type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./vertical_rect_series')
- },
- {
- type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
- ],
- demo: (
-
-
-
- )
- },
- {
- title: 'Horizontal Histogram',
- text: (
-
-
- Use EuiXYChart with EuiHorizontalRectSeries for displaying
- horizontal histograms.
- The Y-Axis needs can be configured as linear ,log ,
- time , time-utc .
- The same for X-Axis.
-
-
- ),
- props: { EuiHorizontalRectSeries },
- source: [
- {
- type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./vertical_rect_series')
- },
- {
- type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
- ],
- demo: (
-
-
-
- )
- },
- {
- title: 'Stacked Horizontal Bar Chart',
- text: (
-
-
- Use EuiXYChart with EuiHorizontalBarSeries for displaying
- horizontal stacked bar charts.
- Specify EuiXYChart props like the following:
-
-
-
- yType="ordinal" because we are creating a Bar Chart
-
-
- stackBy="x" to stack bars one above the other.
- If stackBy is not specified, bars are clustered together depending on the Y value
-
-
-
- ),
- props: { EuiHorizontalBarSeries },
- source: [
- {
- type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./stacked_horizontal_bar_series')
- },
- {
- type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
- ],
- demo: (
-
-
-
- )
- },
- {
- title: 'Stacked Vertical Bar Chart',
- text: (
-
-
- Use EuiXYChart with EuiVerticalBarSeries for displaying
- vertical stacked bar charts.
- Specify EuiXYChart props like the following:
-
-
-
- xType="ordinal" because we are creating a Bar Chart
-
-
- stackBy="y" to stack bars one above the other.
- If stackBy is not specified, bars are clustered together depending on the X value
-
-
-
- ),
- props: { EuiVerticalBarSeries },
- source: [
- {
- type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./stacked_vertical_bar_series')
- },
- {
- type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
- ],
- demo: (
-
-
-
- )
- },
- {
- title: 'Stacked Vertical Histogram',
- text: (
-
-
- Use EuiXYChart with EuiVerticalRectSeries for displaying
- stacked vedrtical histograms.
-
-
Specify stackBy="x" to stack bars together.
-
Note: Is not possible to "cluster" bars by the same X value.
-
- ),
- props: { EuiVerticalRectSeries },
- source: [
- {
- type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./stacked_vertical_rect_series')
- },
- {
- type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
- ],
- demo: (
-
-
-
- )
- },
- {
- title: 'Stacked Horizontal Histogram',
- text: (
-
-
- Use EuiXYChart with EuiHorizontalRectSeries to display
- stacked horizontal histograms.
-
-
Specify stackBy="x" to stack bars together.
-
Note: Is not possible to "cluster" bars by the same Y value.
-
- ),
- props: { EuiHorizontalRectSeries },
- source: [
- {
- type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./stacked_horizontal_rect_series')
- },
- {
- type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
- ],
- demo: (
-
-
-
- )
- },
- ]
-};
diff --git a/src/components/xy_chart/__snapshots__/area.test.js.snap b/src/components/xy_chart/__snapshots__/area.test.js.snap
index b62dcf527bf9..d118720408e2 100644
--- a/src/components/xy_chart/__snapshots__/area.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/area.test.js.snap
@@ -666,3505 +666,458 @@ exports[`EuiArea all props are rendered 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`EuiArea is rendered 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`EuiArea is rendered 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
+ transform="translate(2,2)"
+ />
+
+
+
+
diff --git a/src/components/xy_chart/__snapshots__/line.test.js.snap b/src/components/xy_chart/__snapshots__/line.test.js.snap
index 3d1e205a43d7..2910fd5ac3ed 100644
--- a/src/components/xy_chart/__snapshots__/line.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/line.test.js.snap
@@ -135,6 +135,7 @@ exports[`EuiLine all props are rendered 1`] = `
key=".0:$.0"
lineMarkColor="#00ff00"
lineMarkSize={13}
+ lineSize={2}
marginBottom={2}
marginLeft={2}
marginRight={2}
@@ -148,6 +149,8 @@ exports[`EuiLine all props are rendered 1`] = `
sameTypeIndex={0}
sameTypeTotal={1}
seriesIndex={0}
+ showLine={true}
+ showLineMarks={true}
sizeDomain={Array []}
sizeRange={
Array [
@@ -261,6 +264,7 @@ exports[`EuiLine all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
+ hasLineMarks={true}
id="chart-0"
innerHeight={196}
innerWidth={596}
@@ -434,6 +438,7 @@ exports[`EuiLine all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
+ hasLineMarks={true}
id="chart-0"
innerHeight={196}
innerWidth={596}
@@ -588,6 +593,7 @@ exports[`EuiLine all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
+ hasLineMarks={true}
id="chart-0"
innerHeight={196}
innerWidth={596}
@@ -744,6 +750,7 @@ exports[`EuiLine all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
+ hasLineMarks={true}
id="chart-0"
innerHeight={196}
innerWidth={596}
@@ -917,6 +924,7 @@ exports[`EuiLine all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
+ hasLineMarks={true}
id="chart-0"
innerHeight={196}
innerWidth={596}
@@ -1071,6 +1079,7 @@ exports[`EuiLine all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
+ hasLineMarks={true}
id="chart-0"
innerHeight={196}
innerWidth={596}
@@ -1224,6 +1233,7 @@ exports[`EuiLine all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
+ hasLineMarks={true}
id="chart-0"
innerHeight={196}
innerWidth={596}
@@ -1392,6 +1402,7 @@ exports[`EuiLine all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
+ hasLineMarks={true}
id="chart-0"
innerHeight={196}
innerWidth={596}
@@ -1541,6 +1552,7 @@ exports[`EuiLine all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
+ hasLineMarks={true}
id="chart-0"
innerHeight={196}
innerWidth={596}
@@ -1902,12 +1914,12 @@ exports[`EuiLine is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- hasLineMarks={true}
id="chart-0"
innerHeight={196}
innerWidth={596}
key=".0:$.0"
lineMarkSize={5}
+ lineSize={2}
marginBottom={2}
marginLeft={2}
marginRight={2}
@@ -1919,6 +1931,8 @@ exports[`EuiLine is rendered 1`] = `
sameTypeIndex={0}
sameTypeTotal={1}
seriesIndex={0}
+ showLine={true}
+ showLineMarks={true}
sizeDomain={Array []}
sizeRange={
Array [
diff --git a/src/components/xy_chart/area.js b/src/components/xy_chart/area.js
index 98cc05d34b55..e7e57b917cd7 100644
--- a/src/components/xy_chart/area.js
+++ b/src/components/xy_chart/area.js
@@ -1,6 +1,5 @@
import React from 'react';
import PropTypes from 'prop-types';
-import { EuiLine } from './line';
import { AreaSeries, AbstractSeries } from 'react-vis';
export class EuiArea extends AbstractSeries {
@@ -9,7 +8,6 @@ export class EuiArea extends AbstractSeries {
return (
-
);
}
@@ -43,4 +41,4 @@ EuiArea.defaultProps = {
curve: 'linear',
hasLineMarks: true,
lineMarkSize: 5
-};
\ No newline at end of file
+};
diff --git a/src/components/xy_chart/chart.js b/src/components/xy_chart/chart.js
index cbf2000eafcd..3f0d585d6b91 100644
--- a/src/components/xy_chart/chart.js
+++ b/src/components/xy_chart/chart.js
@@ -1,5 +1,5 @@
import React, { PureComponent } from 'react';
-import { XYPlot, makeWidthFlexible, Crosshair } from 'react-vis';
+import { XYPlot, makeWidthFlexible, Crosshair, AbstractSeries } from 'react-vis';
import PropTypes from 'prop-types';
import { getPlotValues } from './utils';
import Highlight from './highlight';
@@ -85,6 +85,12 @@ export class XYChart extends PureComponent {
}
_renderChildren = (child, i) => {
+ const { prototype } = child.type;
+ // Avoid applying chart props to non series children
+ if (!(prototype instanceof AbstractSeries)) {
+ return child;
+ }
+
const props = {
id: `chart-${i}`,
};
@@ -121,6 +127,8 @@ export class XYChart extends PureComponent {
showTooltips,
onSelectEnd,
children,
+ xDomain,
+ yDomain,
animation, // eslint-disable-line no-unused-vars
onCrosshairUpdate, // eslint-disable-line no-unused-vars
truncateLegends, // eslint-disable-line no-unused-vars
@@ -147,6 +155,8 @@ export class XYChart extends PureComponent {
margin={2}
xType={xType}
yType={yType}
+ xDomain={xDomain}
+ yDomain={yDomain}
stackBy={stackBy}
>
@@ -188,6 +198,8 @@ XYChart.propTypes = {
errorText: PropTypes.string,
crosshairX: PropTypes.number,
onCrosshairUpdate: PropTypes.func,
+ xDomain: PropTypes.array,
+ yDomain: PropTypes.array,
};
XYChart.defaultProps = {
diff --git a/src/components/xy_chart/default_axis.js b/src/components/xy_chart/default_axis.js
index b419af8198d3..aabbdd83f549 100644
--- a/src/components/xy_chart/default_axis.js
+++ b/src/components/xy_chart/default_axis.js
@@ -30,6 +30,8 @@ export default class DefaultAxis extends PureComponent {
yAxisLocation,
showGridLines,
isHorizontal,
+ yOn0,
+ xOn0,
...rest } = this.props;
return (
@@ -62,12 +64,14 @@ export default class DefaultAxis extends PureComponent {
key="x"
orientation={xAxisLocation === 'top' ? 'top' : 'bottom'}
tickSize={1}
+ on0={xOn0}
{...rest}
tickValues={this._getTicks(xTicks)}
tickFormat={xTicks ? v => this._getTickLabels(xTicks)[v] || v : undefined}
/>
-
-
+ {showLine &&
+
+ }
+ {showLine &&
+
+ }
- {hasLineMarks && (
+ {showLineMarks && (
= 2.1.2 < 3"
+
icss-replace-symbols@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/icss-replace-symbols/-/icss-replace-symbols-1.1.0.tgz#06ea6f83679a7749e386cfe1fe812ae5db223ded"
@@ -7349,6 +7386,20 @@ performance-now@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
+phantomjs-prebuilt@^2.1.16:
+ version "2.1.16"
+ resolved "https://registry.yarnpkg.com/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz#efd212a4a3966d3647684ea8ba788549be2aefef"
+ dependencies:
+ es6-promise "^4.0.3"
+ extract-zip "^1.6.5"
+ fs-extra "^1.0.0"
+ hasha "^2.2.0"
+ kew "^0.7.0"
+ progress "^1.1.8"
+ request "^2.81.0"
+ request-progress "^2.0.1"
+ which "^1.2.10"
+
pify@^2.0.0, pify@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
@@ -7806,6 +7857,10 @@ progress@2.0.0, progress@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f"
+progress@^1.1.8:
+ version "1.1.8"
+ resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be"
+
promise-timeout@1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/promise-timeout/-/promise-timeout-1.3.0.tgz#d1c78dd50a607d5f0a5207410252a3a0914e1014"
@@ -7822,7 +7877,7 @@ promisify-node@~0.3.0:
dependencies:
nodegit-promise "~4.0.0"
-prop-types@^15.5.10, prop-types@^15.5.6, prop-types@^15.5.8, prop-types@^15.6.0:
+prop-types@^15.5.10, prop-types@^15.5.6, prop-types@^15.6.0:
version "15.6.0"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.0.tgz#ceaf083022fc46b4a35f69e13ef75aed0d639856"
dependencies:
@@ -7830,7 +7885,7 @@ prop-types@^15.5.10, prop-types@^15.5.6, prop-types@^15.5.8, prop-types@^15.6.0:
loose-envify "^1.3.1"
object-assign "^4.1.1"
-prop-types@^15.6.1:
+prop-types@^15.5.8, prop-types@^15.6.1:
version "15.6.1"
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.1.tgz#36644453564255ddda391191fb3a125cbdf654ca"
dependencies:
@@ -8131,8 +8186,8 @@ react-virtualized@^9.18.5:
prop-types "^15.6.0"
react-vis@^1.9.3:
- version "1.9.3"
- resolved "https://registry.yarnpkg.com/react-vis/-/react-vis-1.9.3.tgz#2e5ea8e6bfa0f03bf6e7954d4559b4fd0bc3987c"
+ version "1.9.4"
+ resolved "https://registry.yarnpkg.com/react-vis/-/react-vis-1.9.4.tgz#367934fb8fc9bc53026e5d29a3ff810d97f72b03"
dependencies:
d3-array "^1.2.0"
d3-collection "^1.0.3"
@@ -8468,6 +8523,12 @@ replace-ext@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-1.0.0.tgz#de63128373fcbf7c3ccfa4de5a480c45a67958eb"
+request-progress@^2.0.1:
+ version "2.0.1"
+ resolved "https://registry.yarnpkg.com/request-progress/-/request-progress-2.0.1.tgz#5d36bb57961c673aa5b788dbc8141fdf23b44e08"
+ dependencies:
+ throttleit "^1.0.0"
+
request-promise-core@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.1.tgz#3eee00b2c5aa83239cfb04c5700da36f81cd08b6"
@@ -8738,6 +8799,10 @@ safe-buffer@5.1.1, safe-buffer@^5.0.1, safe-buffer@^5.1.0, safe-buffer@^5.1.1, s
version "5.1.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"
+"safer-buffer@>= 2.1.2 < 3":
+ version "2.1.2"
+ resolved "https://registry.yarnpkg.com/safer-buffer/-/safer-buffer-2.1.2.tgz#44fa161b0187b9549dd84bb91802f9bd8385cd6a"
+
samsam@1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/samsam/-/samsam-1.3.0.tgz#8d1d9350e25622da30de3e44ba692b5221ab7c50"
@@ -9706,6 +9771,10 @@ throat@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a"
+throttleit@^1.0.0:
+ version "1.0.0"
+ resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-1.0.0.tgz#9e785836daf46743145a5984b6268d828528ac6c"
+
through2@^2.0.0, through2@^2.0.1:
version "2.0.3"
resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be"
@@ -9886,9 +9955,9 @@ typedarray@^0.0.6:
version "0.0.6"
resolved "https://registry.yarnpkg.com/typedarray/-/typedarray-0.0.6.tgz#867ac74e3864187b1d3d47d996a78ec5c8830777"
-ua-parser-js@^0.7.9:
- version "0.7.17"
- resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.17.tgz#e9ec5f9498b9ec910e7ae3ac626a805c4d09ecac"
+ua-parser-js@^0.7.18, ua-parser-js@^0.7.9:
+ version "0.7.18"
+ resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.18.tgz#a7bfd92f56edfb117083b69e31d2aa8882d4b1ed"
uc.micro@^1.0.1, uc.micro@^1.0.5:
version "1.0.5"
@@ -10330,7 +10399,6 @@ wdio-visual-regression-service@silne30/wdio-visual-regression-service#Add_Filena
lodash "^4.13.1"
node-resemble-js "0.0.5"
nodeclient-spectre "^1.0.3"
- phantomjs-prebuilt "^2.1.16"
platform "^1.3.1"
wdio-screenshot "^0.6.0"
@@ -10462,8 +10530,8 @@ whatwg-encoding@^1.0.1, whatwg-encoding@^1.0.3:
iconv-lite "0.4.19"
whatwg-fetch@>=0.10.0:
- version "2.0.3"
- resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.3.tgz#9c84ec2dcf68187ff00bc64e1274b442176e1c84"
+ version "2.0.4"
+ resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f"
whatwg-url@^6.4.0:
version "6.4.0"
From 1cb0e8a58a133d5d00d8840d5389b81ed557ca46 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Wed, 13 Jun 2018 16:09:19 +0200
Subject: [PATCH 09/68] Updated line examples descriptions
---
.../src/views/xy_chart_line/curved_line.js | 19 ++++++++++++++-----
.../src/views/xy_chart_line/line_example.js | 10 +++++++---
2 files changed, 21 insertions(+), 8 deletions(-)
diff --git a/src-docs/src/views/xy_chart_line/curved_line.js b/src-docs/src/views/xy_chart_line/curved_line.js
index 4a2229e4d8bf..44aa6f25bad2 100644
--- a/src-docs/src/views/xy_chart_line/curved_line.js
+++ b/src-docs/src/views/xy_chart_line/curved_line.js
@@ -1,6 +1,8 @@
import React, { Component, Fragment } from 'react';
import {
+ EuiForm,
+ EuiFormRow,
EuiSelect,
EuiSpacer,
EuiXYChart,
@@ -47,13 +49,20 @@ export default class extends Component {
render() {
return (
-
+
+
+
+
+
+
-
- Use multiple EuiLine to display a milti-line chart.
-
+ Use the following props to change the style of the Line Chart
+
+ lineSize to change the size/width of the line.
+ lineMarkSize to change the size/radius of marks.
+ showLine to show/hide the line.
+ showLineMarks to show/hide the line marks.
+
),
props: { EuiLine },
From 51ea2495a1e7f684065673d0d08f065940e8a9e3 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Wed, 13 Jun 2018 17:12:49 +0200
Subject: [PATCH 10/68] Refactored area examples
---
.../xy_chart_area/{area_series.js => area.js} | 0
.../src/views/xy_chart_area/area_example.js | 47 ++++++++--
.../src/views/xy_chart_area/curved_area.js | 93 +++++++++++++++++++
...stacked_area_series.js => stacked_area.js} | 8 +-
.../xy_chart/__snapshots__/area.test.js.snap | 62 ++++++++-----
src/components/xy_chart/area.js | 16 ++--
6 files changed, 185 insertions(+), 41 deletions(-)
rename src-docs/src/views/xy_chart_area/{area_series.js => area.js} (100%)
create mode 100644 src-docs/src/views/xy_chart_area/curved_area.js
rename src-docs/src/views/xy_chart_area/{stacked_area_series.js => stacked_area.js} (62%)
diff --git a/src-docs/src/views/xy_chart_area/area_series.js b/src-docs/src/views/xy_chart_area/area.js
similarity index 100%
rename from src-docs/src/views/xy_chart_area/area_series.js
rename to src-docs/src/views/xy_chart_area/area.js
diff --git a/src-docs/src/views/xy_chart_area/area_example.js b/src-docs/src/views/xy_chart_area/area_example.js
index 7bd2609bc0f6..4f6069a6787f 100644
--- a/src-docs/src/views/xy_chart_area/area_example.js
+++ b/src-docs/src/views/xy_chart_area/area_example.js
@@ -1,10 +1,13 @@
import React from 'react';
import { GuideSectionTypes } from '../../components';
-import AreaSeriesExample from './area_series';
-import StackedAreaSeriesExample from './stacked_area_series';
+import AreaSeriesExample from './area';
+import StackedAreaSeriesExample from './stacked_area';
+import CurvedAreaExample from './curved_area';
+
import {
EuiCode,
EuiArea,
+ EuiLink,
} from '../../../../src/components';
export const XYChartAreaExample = {
@@ -15,9 +18,7 @@ export const XYChartAreaExample = {
text: (
- Use EuiXYChart to display line, bar, area, and stream charts. Note that charts are composed with{' '}
- EuiLine , EuiArea , EuiBar , and EuiStream being child
- components.
+ Use EuiArea to display area charts.
),
@@ -25,7 +26,7 @@ export const XYChartAreaExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./area_series')
+ code: require('!!raw-loader!./area')
},
{
type: GuideSectionTypes.HTML,
@@ -43,7 +44,9 @@ export const XYChartAreaExample = {
text: (
- TODO
+ Use multiple EuiArea to display stacked area charts
+ specifying the stackBy:y prop on the EuiXYChart
+ to enable stacking.
),
@@ -51,7 +54,7 @@ export const XYChartAreaExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./stacked_area_series')
+ code: require('!!raw-loader!./stacked_area')
},
{
type: GuideSectionTypes.HTML,
@@ -64,5 +67,33 @@ export const XYChartAreaExample = {
)
},
+ {
+ title: 'Curved Area Series',
+ text: (
+
+
+ Use the curve prop to change the curve representation.
+ Visit d3-shape#curves
+ for available values (the bundle curve does not work with area chart).
+
+
+ ),
+ props: { EuiArea },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./curved_area')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ }
]
};
diff --git a/src-docs/src/views/xy_chart_area/curved_area.js b/src-docs/src/views/xy_chart_area/curved_area.js
new file mode 100644
index 000000000000..7cdc14676ef0
--- /dev/null
+++ b/src-docs/src/views/xy_chart_area/curved_area.js
@@ -0,0 +1,93 @@
+import React, { Component, Fragment } from 'react';
+
+import {
+ EuiForm,
+ EuiFormRow,
+ EuiSelect,
+ EuiSpacer,
+ EuiXYChart,
+ EuiArea,
+ EuiDefaultAxis } from '../../../../src/components';
+
+const DATA_A = [
+ { x: 0, y: 1 },
+ { x: 1, y: 1 },
+ { x: 2, y: 2 },
+ { x: 3, y: -1 },
+ { x: 5, y: 2 },
+];
+const DATA_B = [
+ { x: 0, y: 3 },
+ { x: 1, y: 2 },
+ { x: 2, y: 4 },
+ { x: 3, y: 1 },
+ { x: 5, y: 3 },
+];
+
+export default class extends Component {
+ constructor(props) {
+ super(props);
+
+ this.options = [
+ { value: 'linear', text: 'Linear' },
+ { value: 'curveCardinal', text: 'Curve Cardinal' },
+ { value: 'curveNatural', text: 'Curve Natural' },
+ { value: 'curveMonotoneX', text: 'Curve Monotone X' },
+ { value: 'curveMonotoneY', text: 'Curve Monotone Y' },
+ { value: 'curveBasis', text: 'Curve Basis' },
+ { value: 'curveCatmullRom', text: 'Curve Catmull Rom' },
+ { value: 'curveStep', text: 'Curve Step' },
+ { value: 'curveStepAfter', text: 'Curve Step After' },
+ { value: 'curveStepBefore', text: 'Curve Step Before' },
+ ];
+
+ this.state = {
+ value: this.options[0].value,
+ };
+ }
+
+ onChange = e => {
+ this.setState({
+ value: e.target.value,
+ });
+ };
+
+ render() {
+ return (
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ )
+ }
+}
diff --git a/src-docs/src/views/xy_chart_area/stacked_area_series.js b/src-docs/src/views/xy_chart_area/stacked_area.js
similarity index 62%
rename from src-docs/src/views/xy_chart_area/stacked_area_series.js
rename to src-docs/src/views/xy_chart_area/stacked_area.js
index 03b60e9f7c5f..89d1ff17777a 100644
--- a/src-docs/src/views/xy_chart_area/stacked_area_series.js
+++ b/src-docs/src/views/xy_chart_area/stacked_area.js
@@ -1,6 +1,6 @@
import React from 'react';
-import { EuiXYChart, EuiLine, EuiDefaultAxis } from '../../../../src/components';
+import { EuiXYChart, EuiArea, EuiDefaultAxis } from '../../../../src/components';
const dataA = [
{ x: 0, y: 3, },
@@ -24,10 +24,8 @@ export default () => (
height={200}
stackBy="y"
>
- {/*
- */}
-
-
+
+
);
diff --git a/src/components/xy_chart/__snapshots__/area.test.js.snap b/src/components/xy_chart/__snapshots__/area.test.js.snap
index d118720408e2..de859842e29b 100644
--- a/src/components/xy_chart/__snapshots__/area.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/area.test.js.snap
@@ -206,7 +206,7 @@ exports[`EuiArea all props are rendered 1`] = `
]
}
_colorValue="#ff0000"
- _opacityValue={0.2}
+ _opacityValue={1}
angleDomain={Array []}
animation={true}
className=""
@@ -296,7 +296,11 @@ exports[`EuiArea all props are rendered 1`] = `
"#FF9833",
]
}
- style={Object {}}
+ style={
+ Object {
+ "strokeWidth": 0,
+ }
+ }
xDomain={
Array [
0,
@@ -340,7 +344,7 @@ exports[`EuiArea all props are rendered 1`] = `
]
}
_colorValue="#ff0000"
- _opacityValue={0.2}
+ _opacityValue={1}
angleDomain={Array []}
animatedProps={
Array [
@@ -467,7 +471,11 @@ exports[`EuiArea all props are rendered 1`] = `
"#FF9833",
]
}
- style={Object {}}
+ style={
+ Object {
+ "strokeWidth": 0,
+ }
+ }
xDomain={
Array [
0,
@@ -531,7 +539,7 @@ exports[`EuiArea all props are rendered 1`] = `
}
_animation={0.00002}
_colorValue="#ff0000"
- _opacityValue={0.2}
+ _opacityValue={1}
angleDomain={Array []}
animation={null}
className=""
@@ -620,7 +628,11 @@ exports[`EuiArea all props are rendered 1`] = `
"#FF9833",
]
}
- style={Object {}}
+ style={
+ Object {
+ "strokeWidth": 0,
+ }
+ }
xDomain={
Array [
0,
@@ -656,8 +668,9 @@ exports[`EuiArea all props are rendered 1`] = `
style={
Object {
"fill": "#ff0000",
- "opacity": 0.2,
+ "opacity": 1,
"stroke": "#ff0000",
+ "strokeWidth": 0,
}
}
transform="translate(2,2)"
@@ -925,12 +938,10 @@ exports[`EuiArea is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- hasLineMarks={true}
id="chart-0"
innerHeight={196}
innerWidth={596}
key=".0:$.0"
- lineMarkSize={5}
marginBottom={2}
marginLeft={2}
marginRight={2}
@@ -1000,7 +1011,7 @@ exports[`EuiArea is rendered 1`] = `
]
}
_colorValue="#00B3A4"
- _opacityValue={0.2}
+ _opacityValue={1}
angleDomain={Array []}
animation={true}
className=""
@@ -1056,12 +1067,10 @@ exports[`EuiArea is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- hasLineMarks={true}
id="chart-0"
innerHeight={196}
innerWidth={596}
key="somename-area"
- lineMarkSize={5}
marginBottom={2}
marginLeft={2}
marginRight={2}
@@ -1087,7 +1096,11 @@ exports[`EuiArea is rendered 1`] = `
"#FF9833",
]
}
- style={Object {}}
+ style={
+ Object {
+ "strokeWidth": 0,
+ }
+ }
xDomain={
Array [
0,
@@ -1131,7 +1144,7 @@ exports[`EuiArea is rendered 1`] = `
]
}
_colorValue="#00B3A4"
- _opacityValue={0.2}
+ _opacityValue={1}
angleDomain={Array []}
animatedProps={
Array [
@@ -1225,11 +1238,9 @@ exports[`EuiArea is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- hasLineMarks={true}
id="chart-0"
innerHeight={196}
innerWidth={596}
- lineMarkSize={5}
marginBottom={2}
marginLeft={2}
marginRight={2}
@@ -1255,7 +1266,11 @@ exports[`EuiArea is rendered 1`] = `
"#FF9833",
]
}
- style={Object {}}
+ style={
+ Object {
+ "strokeWidth": 0,
+ }
+ }
xDomain={
Array [
0,
@@ -1319,7 +1334,7 @@ exports[`EuiArea is rendered 1`] = `
}
_animation={0.00002}
_colorValue="#00B3A4"
- _opacityValue={0.2}
+ _opacityValue={1}
angleDomain={Array []}
animation={null}
className=""
@@ -1375,11 +1390,9 @@ exports[`EuiArea is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- hasLineMarks={true}
id="chart-0"
innerHeight={196}
innerWidth={596}
- lineMarkSize={5}
marginBottom={2}
marginLeft={2}
marginRight={2}
@@ -1405,7 +1418,11 @@ exports[`EuiArea is rendered 1`] = `
"#FF9833",
]
}
- style={Object {}}
+ style={
+ Object {
+ "strokeWidth": 0,
+ }
+ }
xDomain={
Array [
0,
@@ -1441,8 +1458,9 @@ exports[`EuiArea is rendered 1`] = `
style={
Object {
"fill": "#00B3A4",
- "opacity": 0.2,
+ "opacity": 1,
"stroke": "#00B3A4",
+ "strokeWidth": 0,
}
}
transform="translate(2,2)"
diff --git a/src/components/xy_chart/area.js b/src/components/xy_chart/area.js
index e7e57b917cd7..5cabe36fc0c0 100644
--- a/src/components/xy_chart/area.js
+++ b/src/components/xy_chart/area.js
@@ -7,7 +7,16 @@ export class EuiArea extends AbstractSeries {
const { name, data, curve, color, ...rest } = this.props;
return (
-
+
);
}
@@ -30,15 +39,10 @@ EuiArea.propTypes = {
/** Without a color set, a random EUI color palette color will be chosen */
color: PropTypes.string,
curve: PropTypes.string,
- hasLineMarks: PropTypes.bool,
- lineMarkColor: PropTypes.string,
- lineMarkSize: PropTypes.number,
onClick: PropTypes.func,
onMarkClick: PropTypes.func
}
EuiArea.defaultProps = {
curve: 'linear',
- hasLineMarks: true,
- lineMarkSize: 5
};
From b7d7678126277118d46d9c82d50d3431b21575e0 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Wed, 13 Jun 2018 17:41:22 +0200
Subject: [PATCH 11/68] Fix existing charts examples
---
.../src/views/xy_chart/example-auto-axis.js | 9 +++++++--
.../src/views/xy_chart/example-crosshair.js | 14 ++++++++++----
src-docs/src/views/xy_chart/examples.js | 18 ++++++++++--------
3 files changed, 27 insertions(+), 14 deletions(-)
diff --git a/src-docs/src/views/xy_chart/example-auto-axis.js b/src-docs/src/views/xy_chart/example-auto-axis.js
index db95d1d216bc..57454e04c430 100644
--- a/src-docs/src/views/xy_chart/example-auto-axis.js
+++ b/src-docs/src/views/xy_chart/example-auto-axis.js
@@ -1,12 +1,17 @@
import React from 'react';
-import { EuiXYChart, EuiBar } from '../../../../src/components';
+import {
+ EuiXYChart,
+ EuiVerticalBarSeries,
+ EuiDefaultAxis,
+} from '../../../../src/components';
export default () => (
-
+
+
);
diff --git a/src-docs/src/views/xy_chart/example-crosshair.js b/src-docs/src/views/xy_chart/example-crosshair.js
index c73729f8d45a..3c06b875c533 100644
--- a/src-docs/src/views/xy_chart/example-crosshair.js
+++ b/src-docs/src/views/xy_chart/example-crosshair.js
@@ -1,6 +1,10 @@
import React from 'react';
-import { EuiXYChart, EuiBar } from '../../../../src/components';
+import {
+ EuiXYChart,
+ EuiVerticalBarSeries,
+ EuiDefaultAxis,
+} from '../../../../src/components';
// eslint-disable-next-line
export class ExampleCrosshair extends React.Component {
@@ -19,7 +23,8 @@ export class ExampleCrosshair extends React.Component {
width={600}
height={200}
>
-
+
+
-
+
+
);
}
-}
\ No newline at end of file
+}
diff --git a/src-docs/src/views/xy_chart/examples.js b/src-docs/src/views/xy_chart/examples.js
index 137475163009..608e35968b5f 100644
--- a/src-docs/src/views/xy_chart/examples.js
+++ b/src-docs/src/views/xy_chart/examples.js
@@ -1,6 +1,6 @@
import React from 'react';
-import { EuiXYChart, EuiBar, EuiArea, EuiLine } from '../../../../src/components';
+import { EuiXYChart, EuiVerticalBarSeries, EuiArea, EuiLine, EuiDefaultAxis } from '../../../../src/components';
export default () => {
const yTicks = [[0, 'zero'], [1, 'one']];
@@ -34,11 +34,7 @@ export default () => {
xTicks={xTicks}
yTicks={yTicks}
>
-
+
{
@@ -46,9 +42,15 @@ export default () => {
}}
data={[{ x: 0, y: 0 }, { x: 1, y: 2 }, { x: 2, y: 1 }, { x: 3, y: 2 },{ x: 4, y: 1 }, { x: 10, y: 1 }, { x: 20, y: 2 } ]}
/>
+
{barData.map((data, index) => (
-
+
))}
+
)
-}
\ No newline at end of file
+}
From a5a93b531c0c99a37fe2b73609c6bc8fe7a2ba0d Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Wed, 13 Jun 2018 22:58:59 +0200
Subject: [PATCH 12/68] Add first draft of EuiAxis and EuiGrids
---
src-docs/src/routes.js | 4 +
.../src/views/xy_chart_axis/simple_axis.js | 39 +++++++
.../views/xy_chart_axis/xy_axis_example.js | 38 +++++++
src/components/index.js | 4 +
.../xy_chart/__snapshots__/area.test.js.snap | 28 +++++
.../xy_chart/__snapshots__/chart.test.js.snap | 2 +
.../xy_chart/__snapshots__/line.test.js.snap | 52 +++++++++
src/components/xy_chart/axis/axis.js | 0
src/components/xy_chart/axis/default_axis.js | 53 +++++++++
.../xy_chart/axis/horizontal_grid.js | 20 ++++
src/components/xy_chart/axis/vertical_grid.js | 20 ++++
src/components/xy_chart/axis/x_axis.js | 71 ++++++++++++
src/components/xy_chart/axis/y_axis.js | 54 ++++++++++
src/components/xy_chart/chart.js | 8 ++
src/components/xy_chart/default_axis.js | 102 ------------------
src/components/xy_chart/index.js | 10 +-
src/components/xy_chart/utils/axis_utils.js | 15 +++
src/components/xy_chart/utils/text_utils.js | 22 ++++
18 files changed, 439 insertions(+), 103 deletions(-)
create mode 100644 src-docs/src/views/xy_chart_axis/simple_axis.js
create mode 100644 src-docs/src/views/xy_chart_axis/xy_axis_example.js
create mode 100644 src/components/xy_chart/axis/axis.js
create mode 100644 src/components/xy_chart/axis/default_axis.js
create mode 100644 src/components/xy_chart/axis/horizontal_grid.js
create mode 100644 src/components/xy_chart/axis/vertical_grid.js
create mode 100644 src/components/xy_chart/axis/x_axis.js
create mode 100644 src/components/xy_chart/axis/y_axis.js
delete mode 100644 src/components/xy_chart/default_axis.js
create mode 100644 src/components/xy_chart/utils/axis_utils.js
create mode 100644 src/components/xy_chart/utils/text_utils.js
diff --git a/src-docs/src/routes.js b/src-docs/src/routes.js
index a20e0e69cdee..ccf312924607 100644
--- a/src-docs/src/routes.js
+++ b/src-docs/src/routes.js
@@ -207,6 +207,9 @@ import { ToolTipExample }
import { XYChartExample }
from './views/xy_chart/xy_chart_example';
+import { XYChartAxisExample }
+ from './views/xy_chart_axis/xy_axis_example';
+
import { XYChartBarExample }
from './views/xy_chart_bar/bar_example';
@@ -339,6 +342,7 @@ const navigation = [{
name: 'Charts',
items: [
XYChartExample,
+ XYChartAxisExample,
XYChartLineExample,
XYChartAreaExample,
XYChartBarExample,
diff --git a/src-docs/src/views/xy_chart_axis/simple_axis.js b/src-docs/src/views/xy_chart_axis/simple_axis.js
new file mode 100644
index 000000000000..ab9613ce0375
--- /dev/null
+++ b/src-docs/src/views/xy_chart_axis/simple_axis.js
@@ -0,0 +1,39 @@
+import React from 'react';
+
+import {
+ EuiLine,
+ EuiXAxis,
+ EuiYAxis,
+ EuiXYChart,
+ EuiXYChartAxisUtils,
+ EuiXYChartTextUtils,
+} from '../../../../src/components';
+
+const DATA = [{ x: 0, y: 5 }, { x: 1, y: 3 }, { x: 2, y: 2 }, { x: 3, y: 3 }];
+
+function xAxisTickFormatter(value) {
+ return EuiXYChartTextUtils.tspanTextWrapper(['MY VALUE', value]);
+}
+
+export default () => (
+
+
+
+
+
+
+
+);
diff --git a/src-docs/src/views/xy_chart_axis/xy_axis_example.js b/src-docs/src/views/xy_chart_axis/xy_axis_example.js
new file mode 100644
index 000000000000..03aeb24f0287
--- /dev/null
+++ b/src-docs/src/views/xy_chart_axis/xy_axis_example.js
@@ -0,0 +1,38 @@
+import React from 'react';
+import { GuideSectionTypes } from '../../components';
+import { EuiCode, EuiXAxis, EuiYAxis } from '../../../../src/components';
+import SimpleAxisExampleCode from './simple_axis';
+
+export const XYChartAxisExample = {
+ title: 'Axis',
+ sections: [
+ {
+ title: 'Complex Axis example',
+ text: (
+
+
+ EuiYAxis and EuiXAxis can be used
+ instead of the EuiDefaultAxis to allow higher
+ axis customization. See the JS example to check the available properties.
+
+
+ ),
+ props: { EuiXAxis, EuiYAxis },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./simple_axis')
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React'
+ }
+ ],
+ demo: (
+
+
+
+ )
+ },
+ ]
+};
diff --git a/src/components/index.js b/src/components/index.js
index 27c70d831e0b..294acc7f27fc 100644
--- a/src/components/index.js
+++ b/src/components/index.js
@@ -304,6 +304,8 @@ export {
export {
EuiXYChart,
+ EuiXYChartAxisUtils,
+ EuiXYChartTextUtils,
EuiLine,
EuiArea,
EuiVerticalBarSeries,
@@ -311,4 +313,6 @@ export {
EuiVerticalRectSeries,
EuiHorizontalRectSeries,
EuiDefaultAxis,
+ EuiXAxis,
+ EuiYAxis,
} from './xy_chart';
diff --git a/src/components/xy_chart/__snapshots__/area.test.js.snap b/src/components/xy_chart/__snapshots__/area.test.js.snap
index de859842e29b..41dcc90f1839 100644
--- a/src/components/xy_chart/__snapshots__/area.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/area.test.js.snap
@@ -19,6 +19,8 @@ exports[`EuiArea all props are rendered 1`] = `
showTooltips={true}
truncateLegends={false}
width={600}
+ xPadding={0}
+ yPadding={0}
>
{
+ return v[1];
+ });
+ }
+
+ _getTicks(ticks) {
+ if (!ticks) return;
+
+ {
+ return ticks.map(v => {
+ return v[0];
+ });
+ }
+ }
+
+ render() {
+ const { showGridLines, isHorizontal, ...rest } = this.props;
+ return (
+
+ {showGridLines && !isHorizontal && }
+ {showGridLines && isHorizontal && }
+
+
+
+
+ );
+ }
+}
+
+EuiDefaultAxis.propTypes = {
+ isHorizontal: PropTypes.bool,
+ showGridLines: PropTypes.bool,
+ yOn0: PropTypes.bool,
+ xOn0: PropTypes.bool,
+};
+
+EuiDefaultAxis.defaultProps = {
+ isHorizontal: false,
+ showGridLines: true,
+};
+
+EuiDefaultAxis.requiresSVG = true;
diff --git a/src/components/xy_chart/axis/horizontal_grid.js b/src/components/xy_chart/axis/horizontal_grid.js
new file mode 100644
index 000000000000..e8d7c68b8c4f
--- /dev/null
+++ b/src/components/xy_chart/axis/horizontal_grid.js
@@ -0,0 +1,20 @@
+import React, { PureComponent } from 'react';
+import { HorizontalGridLines } from 'react-vis';
+
+export default class EuiHorizontalGrid extends PureComponent {
+ render() {
+ const style = {
+ strokeDasharray: '5 5',
+ strokeOpacity: 0.3,
+ };
+ return (
+
+ )
+
+ }
+}
+
+EuiHorizontalGrid.requiresSVG = true;
diff --git a/src/components/xy_chart/axis/vertical_grid.js b/src/components/xy_chart/axis/vertical_grid.js
new file mode 100644
index 000000000000..cded870d3d77
--- /dev/null
+++ b/src/components/xy_chart/axis/vertical_grid.js
@@ -0,0 +1,20 @@
+import React, { PureComponent } from 'react';
+import { VerticalGridLines } from 'react-vis';
+
+export default class EuiVerticalGrid extends PureComponent {
+ render() {
+ const style = {
+ strokeDasharray: '5 5',
+ strokeOpacity: 0.3,
+ };
+ return (
+
+ )
+
+ }
+}
+
+EuiVerticalGrid.requiresSVG = true;
diff --git a/src/components/xy_chart/axis/x_axis.js b/src/components/xy_chart/axis/x_axis.js
new file mode 100644
index 000000000000..4f3bdb00557b
--- /dev/null
+++ b/src/components/xy_chart/axis/x_axis.js
@@ -0,0 +1,71 @@
+import React, { PureComponent } from 'react';
+import PropTypes from 'prop-types';
+import { XAxis } from 'react-vis';
+import { ORIENTATION, TITLE_POSITION } from '../utils/axis_utils'
+
+
+export default class EuiXAxis extends PureComponent {
+ render() {
+ const {
+ title,
+ titlePosition,
+ orientation,
+ tickSize,
+ tickLabelAngle,
+ tickFormat,
+ tickValues,
+ on0,
+ ...rest
+ } = this.props;
+ return (
+
+ )
+
+ }
+}
+
+EuiXAxis.propTypes = {
+ title: PropTypes.string, /** The axis title */
+ /** The axis title position */
+ titlePosition: PropTypes.oneOf([
+ TITLE_POSITION.START,
+ TITLE_POSITION.MIDDLE,
+ TITLE_POSITION.END,
+ ]),
+ /** The axis orientation */
+ orientation: PropTypes.oneOf([
+ ORIENTATION.TOP,
+ ORIENTATION.BOTTOM,
+ ]),
+ /** Fix the axis at zero value */
+ on0: PropTypes.bool,
+ /** An array of ticks values */
+ ticks: PropTypes.array,
+ /** The height of the ticks in pixels */
+ tickSize: PropTypes.number,
+ /** TODO */
+ tickValues: PropTypes.array,
+ /** A formatter function in the form of function(value, index, scale, tickTotal) */
+ tickFormat: PropTypes.func,
+ /** the rotation angle in degree of the tick label */
+ tickLabelAngle: PropTypes.number,
+};
+
+EuiXAxis.defaultProps = {
+ on0: false,
+ titlePosition: TITLE_POSITION.MIDDLE,
+ orientation: ORIENTATION.BOTTOM,
+ tickSize: 5,
+}
+
+EuiXAxis.requiresSVG = true;
diff --git a/src/components/xy_chart/axis/y_axis.js b/src/components/xy_chart/axis/y_axis.js
new file mode 100644
index 000000000000..03f69902cbd3
--- /dev/null
+++ b/src/components/xy_chart/axis/y_axis.js
@@ -0,0 +1,54 @@
+import React, { PureComponent } from 'react';
+import PropTypes from 'prop-types';
+import { YAxis } from 'react-vis';
+import { ORIENTATION, TITLE_POSITION } from '../utils/axis_utils';
+
+export default class EuiYAxis extends PureComponent {
+ render() {
+ const {
+ title,
+ titlePosition,
+ orientation,
+ tickSize,
+ tickLabelAngle,
+ tickFormat,
+ tickValues,
+ on0,
+ ...rest
+ } = this.props;
+ return (
+
+ );
+ }
+}
+
+EuiYAxis.propTypes = {
+ title: PropTypes.string,
+ titlePosition: PropTypes.oneOf([TITLE_POSITION.START, TITLE_POSITION.MIDDLE, TITLE_POSITION.END]),
+ orientation: PropTypes.oneOf([ORIENTATION.LEFT, ORIENTATION.RIGHT]),
+ on0: PropTypes.bool,
+ ticks: PropTypes.array,
+ tickSize: PropTypes.number,
+ tickValues: PropTypes.array,
+ tickFormat: PropTypes.func,
+ tickLabelAngle: PropTypes.number,
+};
+
+EuiYAxis.defaultProps = {
+ on0: false,
+ titlePosition: TITLE_POSITION.MIDDLE,
+ orientation: ORIENTATION.LEFT,
+ tickSize: 5,
+};
+
+EuiYAxis.requiresSVG = true;
diff --git a/src/components/xy_chart/chart.js b/src/components/xy_chart/chart.js
index 3f0d585d6b91..6a413dbf6e5f 100644
--- a/src/components/xy_chart/chart.js
+++ b/src/components/xy_chart/chart.js
@@ -129,6 +129,8 @@ export class XYChart extends PureComponent {
children,
xDomain,
yDomain,
+ yPadding,
+ xPadding,
animation, // eslint-disable-line no-unused-vars
onCrosshairUpdate, // eslint-disable-line no-unused-vars
truncateLegends, // eslint-disable-line no-unused-vars
@@ -158,6 +160,8 @@ export class XYChart extends PureComponent {
xDomain={xDomain}
yDomain={yDomain}
stackBy={stackBy}
+ yPadding={yPadding}
+ xPadding={xPadding}
>
{React.Children.map(children, this._renderChildren)}
@@ -200,12 +204,16 @@ XYChart.propTypes = {
onCrosshairUpdate: PropTypes.func,
xDomain: PropTypes.array,
yDomain: PropTypes.array,
+ xPadding: PropTypes.number,
+ yPadding: PropTypes.number,
};
XYChart.defaultProps = {
truncateLegends: false,
// showAxis: true,
showTooltips: true,
+ yPadding: 0,
+ xPadding: 0,
};
export default makeWidthFlexible(XYChart);
diff --git a/src/components/xy_chart/default_axis.js b/src/components/xy_chart/default_axis.js
deleted file mode 100644
index aabbdd83f549..000000000000
--- a/src/components/xy_chart/default_axis.js
+++ /dev/null
@@ -1,102 +0,0 @@
-import React, { Fragment, PureComponent } from 'react';
-import PropTypes from 'prop-types';
-import { XAxis, YAxis, HorizontalGridLines, VerticalGridLines } from 'react-vis';
-
-export default class DefaultAxis extends PureComponent {
-
- _getTickLabels(ticks) {
- if (!ticks) return;
-
- return ticks.map(v => {
- return v[1];
- });
- }
-
- _getTicks(ticks) {
- if (!ticks) return;
-
- {
- return ticks.map(v => {
- return v[0];
- });
- }
- }
-
- render() {
- const {
- yTicks,
- xTicks,
- xAxisLocation,
- yAxisLocation,
- showGridLines,
- isHorizontal,
- yOn0,
- xOn0,
- ...rest } = this.props;
- return (
-
- {
- showGridLines && !isHorizontal &&
-
- }
- {
- showGridLines && isHorizontal &&
-
- }
-
- this._getTickLabels(xTicks)[v] || v : undefined}
- />
- this._getTickLabels(yTicks)[v] || v : undefined}
- />
-
- )
- }
-}
-
-DefaultAxis.propTypes = {
- xTicks: PropTypes.array,
- yTicks: PropTypes.array, // [[0, "zero"], [1.2, "one mark"], [2.4, "two marks"]]
- xAxisLocation: PropTypes.string,
- yAxisLocation: PropTypes.string,
- isHorizontal: PropTypes.bool,
- showGridLines: PropTypes.bool,
- yOn0: PropTypes.bool,
- xOn0: PropTypes.bool,
-};
-
-DefaultAxis.defaultProps = {
- isHorizontal: false,
- showGridLines: true,
-}
-
-DefaultAxis.requiresSVG = true;
diff --git a/src/components/xy_chart/index.js b/src/components/xy_chart/index.js
index f83a5cdaf939..95830abc0458 100644
--- a/src/components/xy_chart/index.js
+++ b/src/components/xy_chart/index.js
@@ -6,8 +6,12 @@ import EuiVerticalBarSeries from './vertical_bar_series';
import EuiHorizontalBarSeries from './horizontal_bar_series';
import EuiVerticalRectSeries from './vertical_rect_series';
import EuiHorizontalRectSeries from './horizontal_rect_series';
-import EuiDefaultAxis from './default_axis';
+import EuiDefaultAxis from './axis/default_axis';
+import EuiXAxis from './axis/x_axis';
+import EuiYAxis from './axis/y_axis';
import { EuiArea } from './area';
+import * as EuiXYChartAxisUtils from './utils/axis_utils';
+import * as EuiXYChartTextUtils from './utils/text_utils';
export {
EuiXYChart,
@@ -18,6 +22,10 @@ export {
EuiVerticalRectSeries,
EuiHorizontalRectSeries,
EuiDefaultAxis,
+ EuiXAxis,
+ EuiYAxis,
+ EuiXYChartAxisUtils,
+ EuiXYChartTextUtils,
utils,
asSeries
};
diff --git a/src/components/xy_chart/utils/axis_utils.js b/src/components/xy_chart/utils/axis_utils.js
new file mode 100644
index 000000000000..d893a8a5752c
--- /dev/null
+++ b/src/components/xy_chart/utils/axis_utils.js
@@ -0,0 +1,15 @@
+import { AxisUtils } from 'react-vis';
+
+export const ORIENTATION = AxisUtils.ORIENTATION;
+
+export const TITLE_POSITION = {
+ MIDDLE: 'middle',
+ START: 'start',
+ END: 'end',
+};
+
+export const GRID_TYPE = {
+ HORIZONTAL: 'horizontal',
+ VERTICAL: 'vertical',
+ BOTH: 'both',
+}
diff --git a/src/components/xy_chart/utils/text_utils.js b/src/components/xy_chart/utils/text_utils.js
new file mode 100644
index 000000000000..4ccfbc31fa67
--- /dev/null
+++ b/src/components/xy_chart/utils/text_utils.js
@@ -0,0 +1,22 @@
+import React from 'react'
+
+/**
+ * Simplified version of tspan wrapper that takes an array of Strings.
+ * and return a SVG component composed by tspan tags.
+ * @param {Array of Strings} texts - an array of splitted text, one per line
+ * @return {Object} Returns an Object to use with dangerouslySetInnerHTML
+ * with the rendered markdown HTML
+ */
+export function tspanTextWrapper(texts) {
+ return (
+
+ {
+ texts.map((piece) => {
+ return (
+ {piece}
+ )
+ })
+ }
+
+ )
+}
From f34a0650ed3d04525b595b64b8151b9d401b4681 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Wed, 13 Jun 2018 23:13:28 +0200
Subject: [PATCH 13/68] Update docs example groups names
---
src-docs/src/views/xy_chart/xy_chart_example.js | 2 +-
src-docs/src/views/xy_chart_area/area_example.js | 2 +-
src-docs/src/views/xy_chart_bar/bar_example.js | 2 +-
src-docs/src/views/xy_chart_histogram/histogram_example.js | 2 +-
src-docs/src/views/xy_chart_line/line_example.js | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src-docs/src/views/xy_chart/xy_chart_example.js b/src-docs/src/views/xy_chart/xy_chart_example.js
index 05ac54d72178..259cd8e0e7df 100644
--- a/src-docs/src/views/xy_chart/xy_chart_example.js
+++ b/src-docs/src/views/xy_chart/xy_chart_example.js
@@ -7,7 +7,7 @@ import AutoAxisChartExampleCode from './example-auto-axis';
import { ExampleCrosshair } from './example-crosshair';
export const XYChartExample = {
- title: 'XYChart',
+ title: 'General',
sections: [
{
title: 'Complex example',
diff --git a/src-docs/src/views/xy_chart_area/area_example.js b/src-docs/src/views/xy_chart_area/area_example.js
index 4f6069a6787f..e640416a5b42 100644
--- a/src-docs/src/views/xy_chart_area/area_example.js
+++ b/src-docs/src/views/xy_chart_area/area_example.js
@@ -11,7 +11,7 @@ import {
} from '../../../../src/components';
export const XYChartAreaExample = {
- title: 'XYChart Area',
+ title: 'Area chart',
sections: [
{
title: 'Area Series',
diff --git a/src-docs/src/views/xy_chart_bar/bar_example.js b/src-docs/src/views/xy_chart_bar/bar_example.js
index 63019624d66e..57e03563c162 100644
--- a/src-docs/src/views/xy_chart_bar/bar_example.js
+++ b/src-docs/src/views/xy_chart_bar/bar_example.js
@@ -12,7 +12,7 @@ import {
} from '../../../../src/components';
export const XYChartBarExample = {
- title: 'XYChart Bar Chart',
+ title: 'Bar chart',
sections: [
{
title: 'Vertical Bar Chart',
diff --git a/src-docs/src/views/xy_chart_histogram/histogram_example.js b/src-docs/src/views/xy_chart_histogram/histogram_example.js
index da70522970d9..f50c52b47483 100644
--- a/src-docs/src/views/xy_chart_histogram/histogram_example.js
+++ b/src-docs/src/views/xy_chart_histogram/histogram_example.js
@@ -12,7 +12,7 @@ import {
} from '../../../../src/components';
export const XYChartHistogramExample = {
- title: 'XYChart Histogram',
+ title: 'Histogram',
sections: [
{
title: 'Vertical Histogram',
diff --git a/src-docs/src/views/xy_chart_line/line_example.js b/src-docs/src/views/xy_chart_line/line_example.js
index d3ff89c5bb91..e1ed683a57eb 100644
--- a/src-docs/src/views/xy_chart_line/line_example.js
+++ b/src-docs/src/views/xy_chart_line/line_example.js
@@ -12,7 +12,7 @@ import {
} from '../../../../src/components';
export const XYChartLineExample = {
- title: 'XYChart Line',
+ title: 'Line chart',
sections: [
{
title: 'Line chart',
From 9197739e2f47f9b6767de7aa40f0c6d9cdcbeded Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Thu, 14 Jun 2018 16:20:38 +0200
Subject: [PATCH 14/68] First version of multi axis chart
---
.../src/views/xy_chart/example_dual_axis.js | 71 +++++++++++++++++++
src-docs/src/views/xy_chart/examples.js | 46 +++++++-----
.../src/views/xy_chart/xy_chart_example.js | 10 +--
src-docs/src/views/xy_chart_line/line.js | 1 +
4 files changed, 107 insertions(+), 21 deletions(-)
create mode 100644 src-docs/src/views/xy_chart/example_dual_axis.js
diff --git a/src-docs/src/views/xy_chart/example_dual_axis.js b/src-docs/src/views/xy_chart/example_dual_axis.js
new file mode 100644
index 000000000000..f2629aab8e2d
--- /dev/null
+++ b/src-docs/src/views/xy_chart/example_dual_axis.js
@@ -0,0 +1,71 @@
+import React from 'react';
+
+import {
+ EuiXYChart,
+ EuiLine,
+ EuiXAxis,
+ EuiYAxis,
+ EuiXYChartAxisUtils,
+} from '../../../../src/components';
+import { VISUALIZATION_COLORS } from '../../../../src/services';
+
+const DATA_A = [{ x: 0, y: 0 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: 1 }, { x: 5, y: 2 }];
+const DATA_B = [{ x: 0, y: 100 }, { x: 1, y: 200 }, { x: 2, y: 150 }, { x: 3, y: 55 }, { x: 5, y: 95 }];
+const DATA_C = [{ x: 0, y: 30 }, { x: 1, y: 45 }, { x: 2, y: 67 }, { x: 3, y: 22 }, { x: 5, y: 44 }];
+
+const DATA_A_DOMAIN = [-0.5, 3];
+const DATA_B_DOMAIN = [0, 200];
+const DATA_C_DOMAIN = [15, 80];
+
+export default () => (
+
+
+
+
+
+
+
+
+
+);
diff --git a/src-docs/src/views/xy_chart/examples.js b/src-docs/src/views/xy_chart/examples.js
index 608e35968b5f..6782db326584 100644
--- a/src-docs/src/views/xy_chart/examples.js
+++ b/src-docs/src/views/xy_chart/examples.js
@@ -1,23 +1,23 @@
import React from 'react';
-import { EuiXYChart, EuiVerticalBarSeries, EuiArea, EuiLine, EuiDefaultAxis } from '../../../../src/components';
+import {
+ EuiXYChart,
+ EuiVerticalBarSeries,
+ EuiArea,
+ EuiLine,
+ EuiDefaultAxis,
+} from '../../../../src/components';
export default () => {
const yTicks = [[0, 'zero'], [1, 'one']];
- const xTicks = [
- [0, '0'],
- [5, '5'],
- [10, '10'],
- [15, '15'],
- [20, '20']
- ];
+ const xTicks = [[0, '0'], [5, '5'], [10, '10'], [15, '15'], [20, '20']];
const barData = [];
for (let i = 0; i < 10; i++) {
const data = [];
for (let i = 0; i < 20; i++) {
- data.push({ x: i, y: Math.random() });
+ data.push({ x: i, y: Number(Math.random().toFixed(2)) });
}
barData.push(data);
@@ -34,23 +34,37 @@ export default () => {
xTicks={xTicks}
yTicks={yTicks}
>
-
{
alert('clicked!');
}}
- data={[{ x: 0, y: 0 }, { x: 1, y: 2 }, { x: 2, y: 1 }, { x: 3, y: 2 },{ x: 4, y: 1 }, { x: 10, y: 1 }, { x: 20, y: 2 } ]}
+ data={[
+ { x: 0, y: 0 },
+ { x: 1, y: 2 },
+ { x: 2, y: 1 },
+ { x: 3, y: 2 },
+ { x: 4, y: 1 },
+ { x: 10, y: 1 },
+ { x: 20, y: 2 },
+ ]}
/>
+ {barData
+ .slice(0, 1)
+ .map((data, index) => (
+
+ ))}
- {barData.map((data, index) => (
-
- ))}
- )
-}
+ );
+};
diff --git a/src-docs/src/views/xy_chart/xy_chart_example.js b/src-docs/src/views/xy_chart/xy_chart_example.js
index 259cd8e0e7df..7bc253275e7c 100644
--- a/src-docs/src/views/xy_chart/xy_chart_example.js
+++ b/src-docs/src/views/xy_chart/xy_chart_example.js
@@ -3,11 +3,11 @@ import { GuideSectionTypes } from '../../components';
import { EuiCode } from '../../../../src/components';
import ChartExampleCode from './examples';
import EmptyExampleCode from './example-empty';
-import AutoAxisChartExampleCode from './example-auto-axis';
+import MultiAxisChartExampleCode from './example_dual_axis';
import { ExampleCrosshair } from './example-crosshair';
export const XYChartExample = {
- title: 'General',
+ title: 'General',
sections: [
{
title: 'Complex example',
@@ -87,7 +87,7 @@ export const XYChartExample = {
)
},
{
- title: 'Auto Axis',
+ title: 'Multi Axis',
text: (
@@ -98,7 +98,7 @@ export const XYChartExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./example-auto-axis')
+ code: require('!!raw-loader!./example_dual_axis')
},
{
type: GuideSectionTypes.HTML,
@@ -107,7 +107,7 @@ export const XYChartExample = {
],
demo: (
)
}
diff --git a/src-docs/src/views/xy_chart_line/line.js b/src-docs/src/views/xy_chart_line/line.js
index daa9c6db2df5..f0cbe67ac4f6 100644
--- a/src-docs/src/views/xy_chart_line/line.js
+++ b/src-docs/src/views/xy_chart_line/line.js
@@ -7,6 +7,7 @@ const DATA_A = [
{ x: 1, y: 1 },
{ x: 2, y: 2 },
{ x: 3, y: -1 },
+ { x: 4, y: null },
{ x: 5, y: 2 },
];
From 5a74008b69dafdc86eb4e30364d4562813512cf8 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Thu, 14 Jun 2018 18:13:58 +0200
Subject: [PATCH 15/68] Update yarn.lock file
---
yarn.lock | 47 -----------------------------------------------
1 file changed, 47 deletions(-)
diff --git a/yarn.lock b/yarn.lock
index c66828b72fcc..f74ee29006be 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3051,10 +3051,6 @@ es6-promise@^3.0.2:
version "3.3.1"
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-3.3.1.tgz#a08cdde84ccdbf34d027a1451bc91d4bcd28a613"
-es6-promise@^4.0.3:
- version "4.2.4"
- resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.4.tgz#dc4221c2b16518760bd8c39a52d8f356fc00ed29"
-
es6-set@~0.1.5:
version "0.1.5"
resolved "https://registry.yarnpkg.com/es6-set/-/es6-set-0.1.5.tgz#d2b3ec5d4d800ced818db538d28974db0a73ccb1"
@@ -3880,14 +3876,6 @@ fs-extra@^0.30.0:
path-is-absolute "^1.0.0"
rimraf "^2.2.8"
-fs-extra@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-1.0.0.tgz#cd3ce5f7e7cb6145883fcae3191e9877f8587950"
- dependencies:
- graceful-fs "^4.1.2"
- jsonfile "^2.1.0"
- klaw "^1.0.0"
-
fs-extra@^3.0.1:
version "3.0.1"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-3.0.1.tgz#3794f378c58b342ea7dbbb23095109c4b3b62291"
@@ -4403,13 +4391,6 @@ hash.js@^1.0.0, hash.js@^1.0.3:
inherits "^2.0.3"
minimalistic-assert "^1.0.0"
-hasha@^2.2.0:
- version "2.2.0"
- resolved "https://registry.yarnpkg.com/hasha/-/hasha-2.2.0.tgz#78d7cbfc1e6d66303fe79837365984517b2f6ee1"
- dependencies:
- is-stream "^1.0.1"
- pinkie-promise "^2.0.0"
-
hawk@3.1.3, hawk@~3.1.3:
version "3.1.3"
resolved "https://registry.yarnpkg.com/hawk/-/hawk-3.1.3.tgz#078444bd7c1640b0fe540d2c9b73d59678e8e1c4"
@@ -7386,20 +7367,6 @@ performance-now@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/performance-now/-/performance-now-2.1.0.tgz#6309f4e0e5fa913ec1c69307ae364b4b377c9e7b"
-phantomjs-prebuilt@^2.1.16:
- version "2.1.16"
- resolved "https://registry.yarnpkg.com/phantomjs-prebuilt/-/phantomjs-prebuilt-2.1.16.tgz#efd212a4a3966d3647684ea8ba788549be2aefef"
- dependencies:
- es6-promise "^4.0.3"
- extract-zip "^1.6.5"
- fs-extra "^1.0.0"
- hasha "^2.2.0"
- kew "^0.7.0"
- progress "^1.1.8"
- request "^2.81.0"
- request-progress "^2.0.1"
- which "^1.2.10"
-
pify@^2.0.0, pify@^2.3.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/pify/-/pify-2.3.0.tgz#ed141a6ac043a849ea588498e7dca8b15330e90c"
@@ -7857,10 +7824,6 @@ progress@2.0.0, progress@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f"
-progress@^1.1.8:
- version "1.1.8"
- resolved "https://registry.yarnpkg.com/progress/-/progress-1.1.8.tgz#e260c78f6161cdd9b0e56cc3e0a85de17c7a57be"
-
promise-timeout@1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/promise-timeout/-/promise-timeout-1.3.0.tgz#d1c78dd50a607d5f0a5207410252a3a0914e1014"
@@ -8523,12 +8486,6 @@ replace-ext@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/replace-ext/-/replace-ext-1.0.0.tgz#de63128373fcbf7c3ccfa4de5a480c45a67958eb"
-request-progress@^2.0.1:
- version "2.0.1"
- resolved "https://registry.yarnpkg.com/request-progress/-/request-progress-2.0.1.tgz#5d36bb57961c673aa5b788dbc8141fdf23b44e08"
- dependencies:
- throttleit "^1.0.0"
-
request-promise-core@1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/request-promise-core/-/request-promise-core-1.1.1.tgz#3eee00b2c5aa83239cfb04c5700da36f81cd08b6"
@@ -9771,10 +9728,6 @@ throat@^4.0.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a"
-throttleit@^1.0.0:
- version "1.0.0"
- resolved "https://registry.yarnpkg.com/throttleit/-/throttleit-1.0.0.tgz#9e785836daf46743145a5984b6268d828528ac6c"
-
through2@^2.0.0, through2@^2.0.1:
version "2.0.3"
resolved "https://registry.yarnpkg.com/through2/-/through2-2.0.3.tgz#0004569b37c7c74ba39c43f3ced78d1ad94140be"
From bff1959c3e10abae4002b86ffacdd75b2f35c625 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Fri, 15 Jun 2018 19:27:00 +0200
Subject: [PATCH 16/68] Add first draft of crosshair
Reused as much as possible the existing charts implementation and existing event handling
---
.../src/views/xy_chart/example_dual_axis.js | 9 +-
src/components/index.js | 1 +
.../xy_chart/__snapshots__/area.test.js.snap | 248 ++--------------
.../xy_chart/__snapshots__/chart.test.js.snap | 2 +
.../xy_chart/__snapshots__/line.test.js.snap | 272 ++++--------------
src/components/xy_chart/chart.js | 100 +------
src/components/xy_chart/crosshair.js | 69 +++++
src/components/xy_chart/index.js | 9 +-
.../{utils.js => utils/chart_utils.js} | 5 +-
9 files changed, 169 insertions(+), 546 deletions(-)
create mode 100644 src/components/xy_chart/crosshair.js
rename src/components/xy_chart/{utils.js => utils/chart_utils.js} (88%)
diff --git a/src-docs/src/views/xy_chart/example_dual_axis.js b/src-docs/src/views/xy_chart/example_dual_axis.js
index f2629aab8e2d..b86e8a0db08f 100644
--- a/src-docs/src/views/xy_chart/example_dual_axis.js
+++ b/src-docs/src/views/xy_chart/example_dual_axis.js
@@ -9,9 +9,11 @@ import {
} from '../../../../src/components';
import { VISUALIZATION_COLORS } from '../../../../src/services';
-const DATA_A = [{ x: 0, y: 0 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: 1 }, { x: 5, y: 2 }];
-const DATA_B = [{ x: 0, y: 100 }, { x: 1, y: 200 }, { x: 2, y: 150 }, { x: 3, y: 55 }, { x: 5, y: 95 }];
-const DATA_C = [{ x: 0, y: 30 }, { x: 1, y: 45 }, { x: 2, y: 67 }, { x: 3, y: 22 }, { x: 5, y: 44 }];
+
+
+const DATA_A = [{ x: 'A', y: 0 }, { x: 'B', y: 1 }, { x: 'C', y: 2 }, { x: 'D', y: 1 }, { x: 'E', y: 2 }];
+const DATA_B = [{ x: 'A', y: 100 }, { x: 'B', y: 100 }, { x: 'C', y: 150 }, { x: 'D', y: 55 }, { x: 'E', y: 95 }];
+const DATA_C = [{ x: 'A', y: 30 }, { x: 'B', y: 45 }, { x: 'C', y: 67 }, { x: 'D', y: 22 }, { x: 'E', y: 44 }];
const DATA_A_DOMAIN = [-0.5, 3];
const DATA_B_DOMAIN = [0, 200];
@@ -22,6 +24,7 @@ export default () => (
width={600}
height={200}
xPadding={5}
+ xType="ordinal"
>
@@ -840,7 +740,9 @@ exports[`EuiArea is rendered 1`] = `
truncateLegends={false}
width={600}
xPadding={0}
+ xType="linear"
yPadding={0}
+ yType="linear"
>
diff --git a/src/components/xy_chart/__snapshots__/chart.test.js.snap b/src/components/xy_chart/__snapshots__/chart.test.js.snap
index ecc77af7e55d..c5772b997ecd 100644
--- a/src/components/xy_chart/__snapshots__/chart.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/chart.test.js.snap
@@ -105,6 +105,7 @@ exports[`EuiXYChart passes handler functions 1`] = `
],
]
}
+ xType="linear"
yPadding={0}
yTicks={
Array [
@@ -118,6 +119,7 @@ exports[`EuiXYChart passes handler functions 1`] = `
],
]
}
+ yType="linear"
>
@@ -1828,7 +1740,9 @@ exports[`EuiLine is rendered 1`] = `
truncateLegends={false}
width={600}
xPadding={0}
+ xType="linear"
yPadding={0}
+ yType="linear"
>
diff --git a/src/components/xy_chart/chart.js b/src/components/xy_chart/chart.js
index 6a413dbf6e5f..40d4fd3c9f67 100644
--- a/src/components/xy_chart/chart.js
+++ b/src/components/xy_chart/chart.js
@@ -1,87 +1,27 @@
import React, { PureComponent } from 'react';
-import { XYPlot, makeWidthFlexible, Crosshair, AbstractSeries } from 'react-vis';
+import { XYPlot, makeWidthFlexible, AbstractSeries } from 'react-vis';
import PropTypes from 'prop-types';
-import { getPlotValues } from './utils';
import Highlight from './highlight';
+import { EuiCrosshair } from './crosshair';
import { VISUALIZATION_COLORS } from '../../services';
import StatusText from './status-text';
-const NO_DATA_VALUE = '~~NODATATODISPLAY~~';
-
export class XYChart extends PureComponent {
state = {
- crosshairValues: [],
+ mouseOver: false,
};
- seriesItems = [];
colorIterator = 0;
- lastCrosshairX = 0;
- _xyPlotRef = React.createRef();;
+ _xyPlotRef = React.createRef();
_onMouseLeave = () => {
- this.setState({ crosshairValues: [], lastCrosshairIndex: null });
+ // TODO we need to find a better way to trigger a mouse leave event
+ // for the crosshair
+ this.setState({ mouseOver: false });
}
_onMouseMove = (e) => {
- e.persist();
- this._updateCrosshairValues({
- boundingClientRect: e.currentTarget.getBoundingClientRect(),
- clientX: e.clientX
- });
- }
-
- _updateCrosshairValues = ({ boundingClientRect, clientX }) => {
- // Calculate the range of the X axis
- const chartData = this._xyPlotRef.current.state.data.filter(d => d !== undefined)
- const plotValues = getPlotValues(chartData, this.props.width);
- const xDomain = plotValues.x.domain();
- const maxChartXValue = (xDomain[1] - xDomain[0]) + 1;
-
- const innerChartWidth = this._xyPlotRef.current._getDefaultScaleProps(this._xyPlotRef.current.props).xRange[1]
-
- const mouseX = clientX - boundingClientRect.left;
- const xAxisesBucketWidth = innerChartWidth / maxChartXValue;
- const bucketX = Math.floor(mouseX / xAxisesBucketWidth)
-
- if (bucketX !== this.lastCrosshairX) {
- if(this.props.onCrosshairUpdate) this.props.onCrosshairUpdate(bucketX)
- if(!this.props.crosshairX) {
- this.lastCrosshairX = bucketX;
-
- const crosshairValues = this._getAllSeriesFromDataAtIndex(chartData, bucketX)
-
- this.setState({
- crosshairValues
- });
- }
- }
- }
-
- _getAllSeriesFromDataAtIndex = (chartData, xBucket) => {
- const chartDataForXValue = chartData.map(series => series.filter(seriesData => {
- return seriesData.x === xBucket
- })[0])
-
- if(chartDataForXValue.length === 0) {
- chartDataForXValue.push({ x: xBucket, y: NO_DATA_VALUE })
- }
-
- return chartDataForXValue;
- };
-
- _itemsFormat = (values) => {
- return values.map((v, i) => {
- if (v) {
- if(v.y === NO_DATA_VALUE) {
- return {
- title: 'No Data',
- };
- }
- return {
- value: v.y,
- title: this.seriesItems[i] || 'Other',
- };
- }
- });
+ e.preventDefault();
+ this.setState({ mouseOver: true });
}
_renderChildren = (child, i) => {
@@ -95,8 +35,6 @@ export class XYChart extends PureComponent {
id: `chart-${i}`,
};
- this.seriesItems.push(child.props.name);
-
if (!child.props.color) {
props.color = VISUALIZATION_COLORS[this.colorIterator];
@@ -107,14 +45,6 @@ export class XYChart extends PureComponent {
return React.cloneElement(child, props);
}
- _getCrosshairValues = (crosshairX) => {
- if(!crosshairX) return this.state.crosshairValues
-
- const chartData = this._xyPlotRef.current.state.data.filter(d => d !== undefined)
- return this._getAllSeriesFromDataAtIndex(chartData, crosshairX)
- }
-
-
render() {
const {
width,
@@ -123,7 +53,6 @@ export class XYChart extends PureComponent {
yType,
stackBy,
errorText,
- crosshairX,
showTooltips,
onSelectEnd,
children,
@@ -166,13 +95,8 @@ export class XYChart extends PureComponent {
{React.Children.map(children, this._renderChildren)}
- {showTooltips && (
- null}
- itemsFormat={this._itemsFormat}
- />
+ {showTooltips && this.state.mouseOver && (
+
)}
{onSelectEnd && }
@@ -214,6 +138,8 @@ XYChart.defaultProps = {
showTooltips: true,
yPadding: 0,
xPadding: 0,
+ xType: 'linear',
+ yType: 'linear',
};
export default makeWidthFlexible(XYChart);
diff --git a/src/components/xy_chart/crosshair.js b/src/components/xy_chart/crosshair.js
new file mode 100644
index 000000000000..d548480784ca
--- /dev/null
+++ b/src/components/xy_chart/crosshair.js
@@ -0,0 +1,69 @@
+import React from 'react';
+import { AbstractSeries, Crosshair } from 'react-vis';
+
+export class EuiCrosshair extends AbstractSeries {
+ state = {
+ crosshairValues: [],
+ }
+
+ static get requiresSVG() {
+ return false;
+ }
+
+ static get isCanvas() {
+ return false;
+ }
+
+ onParentMouseMove(event) {
+ this._handleNearestX(event);
+ }
+
+ onParentMouseMove(event) {
+ this._handleNearestX(event);
+ }
+
+ _handleNearestX(event) {
+ const chartData = this.props._allData.filter(d => d)
+ if (chartData.length === 0) {
+ return
+ }
+ const coordinate = super._getXYCoordinateInContainer(event);
+ const xScaleFn = super._getAttributeFunctor('x');
+
+ const crosshairValues = chartData
+ .map(data => {
+ let minDistance = Number.POSITIVE_INFINITY;
+ let value = null;
+ data.forEach((item) => {
+ const currentCoordinate = xScaleFn(item);
+ const newDistance = Math.abs(coordinate.x - currentCoordinate);
+ if (newDistance < minDistance) {
+ minDistance = newDistance;
+ value = item;
+ }
+ });
+ if (!value) {
+ return;
+ }
+ return {
+ ...value,
+ }
+ })
+ .filter(d => d);
+
+ this.setState({
+ crosshairValues,
+ });
+ }
+
+ render() {
+
+ return (
+
+ )
+ }
+}
diff --git a/src/components/xy_chart/index.js b/src/components/xy_chart/index.js
index 95830abc0458..3c3b0bd36420 100644
--- a/src/components/xy_chart/index.js
+++ b/src/components/xy_chart/index.js
@@ -1,7 +1,7 @@
import { asSeries } from './as_series';
import EuiXYChart from './chart';
-import * as utils from './utils';
-import { EuiLine } from './line';
+import * as utils from './utils/chart_utils';
+export { EuiLine } from './line';
import EuiVerticalBarSeries from './vertical_bar_series';
import EuiHorizontalBarSeries from './horizontal_bar_series';
import EuiVerticalRectSeries from './vertical_rect_series';
@@ -9,14 +9,13 @@ import EuiHorizontalRectSeries from './horizontal_rect_series';
import EuiDefaultAxis from './axis/default_axis';
import EuiXAxis from './axis/x_axis';
import EuiYAxis from './axis/y_axis';
-import { EuiArea } from './area';
+export { EuiArea } from './area';
import * as EuiXYChartAxisUtils from './utils/axis_utils';
import * as EuiXYChartTextUtils from './utils/text_utils';
+export { EuiCrosshair } from './crosshair';
export {
EuiXYChart,
- EuiLine,
- EuiArea,
EuiVerticalBarSeries,
EuiHorizontalBarSeries,
EuiVerticalRectSeries,
diff --git a/src/components/xy_chart/utils.js b/src/components/xy_chart/utils/chart_utils.js
similarity index 88%
rename from src/components/xy_chart/utils.js
rename to src/components/xy_chart/utils/chart_utils.js
index e39b95121988..58a5a0f266b2 100644
--- a/src/components/xy_chart/utils.js
+++ b/src/components/xy_chart/utils/chart_utils.js
@@ -37,12 +37,11 @@ export function getPlotValues(series, width) {
const allCoordinates = _.flatten(series);
- const xMin = d3.min(allCoordinates, d => d.x);
- const xMax = d3.max(allCoordinates, d => d.x);
+ const xExtent = d3.extent(allCoordinates, d => d.x);
const yMin = 0;
const yMax = d3.max(allCoordinates, d => d.y);
- const x = getXScale(xMin, xMax, width);
+ const x = getXScale(xExtent[0], xExtent[1], width);
const y = getYScale(yMin, yMax);
const yTickValues = getYTickValues(y.domain()[1]);
const xTickValues = getYTickValues(x.domain()[1]);
From bea0afccbad260ea4679f5b799e815a0a203179f Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Fri, 15 Jun 2018 19:41:47 +0200
Subject: [PATCH 17/68] Refactoring exports removing default exports
---
src/components/xy_chart/area.test.js | 2 +-
src/components/xy_chart/axis/axis.js | 0
src/components/xy_chart/axis/default_axis.js | 10 ++--
.../xy_chart/axis/horizontal_grid.js | 2 +-
src/components/xy_chart/axis/vertical_grid.js | 2 +-
src/components/xy_chart/axis/x_axis.js | 5 +-
src/components/xy_chart/axis/y_axis.js | 6 ++-
src/components/xy_chart/chart.js | 4 +-
src/components/xy_chart/chart.test.js | 2 +-
.../xy_chart/horizontal_bar_series.js | 3 +-
.../xy_chart/horizontal_bar_series.test.js | 4 +-
.../xy_chart/horizontal_rect_series.js | 3 +-
.../xy_chart/horizontal_rect_series.test.js | 4 +-
src/components/xy_chart/index.js | 38 ++++----------
src/components/xy_chart/line.test.js | 2 +-
src/components/xy_chart/utils/axis_utils.js | 14 ++++--
src/components/xy_chart/utils/chart_utils.js | 50 -------------------
src/components/xy_chart/utils/text_utils.js | 6 ++-
.../xy_chart/vertical_bar_series.js | 3 +-
.../xy_chart/vertical_bar_series.test.js | 4 +-
.../xy_chart/vertical_rect_series.js | 2 +-
.../xy_chart/vertical_rect_series.test.js | 4 +-
22 files changed, 57 insertions(+), 113 deletions(-)
delete mode 100644 src/components/xy_chart/axis/axis.js
delete mode 100644 src/components/xy_chart/utils/chart_utils.js
diff --git a/src/components/xy_chart/area.test.js b/src/components/xy_chart/area.test.js
index 0184d8f76b2c..fb545b7d3faf 100644
--- a/src/components/xy_chart/area.test.js
+++ b/src/components/xy_chart/area.test.js
@@ -3,7 +3,7 @@ import { mount, render } from 'enzyme';
import { patchRandom, unpatchRandom } from '../../test/patch_random';
import { requiredProps } from '../../test/required_props';
-import EuiXYChart from './chart';
+import { EuiXYChart } from './chart';
import { EuiArea } from './area';
import { benchmarkFunction } from '../../test/time_execution';
diff --git a/src/components/xy_chart/axis/axis.js b/src/components/xy_chart/axis/axis.js
deleted file mode 100644
index e69de29bb2d1..000000000000
diff --git a/src/components/xy_chart/axis/default_axis.js b/src/components/xy_chart/axis/default_axis.js
index 62323dab1548..0fe69b93cc97 100644
--- a/src/components/xy_chart/axis/default_axis.js
+++ b/src/components/xy_chart/axis/default_axis.js
@@ -1,11 +1,11 @@
import React, { Fragment, PureComponent } from 'react';
import PropTypes from 'prop-types';
-import EuiXAxis from './x_axis';
-import EuiYAxis from './y_axis';
-import EuiHorizontalGrid from './horizontal_grid';
-import EuiVerticalGrid from './vertical_grid';
+import { EuiXAxis } from './x_axis';
+import { EuiYAxis } from './y_axis';
+import { EuiHorizontalGrid } from './horizontal_grid';
+import { EuiVerticalGrid } from './vertical_grid';
-export default class EuiDefaultAxis extends PureComponent {
+export class EuiDefaultAxis extends PureComponent {
_getTickLabels(ticks) {
if (!ticks) return;
diff --git a/src/components/xy_chart/axis/horizontal_grid.js b/src/components/xy_chart/axis/horizontal_grid.js
index e8d7c68b8c4f..4fa5f211a8a9 100644
--- a/src/components/xy_chart/axis/horizontal_grid.js
+++ b/src/components/xy_chart/axis/horizontal_grid.js
@@ -1,7 +1,7 @@
import React, { PureComponent } from 'react';
import { HorizontalGridLines } from 'react-vis';
-export default class EuiHorizontalGrid extends PureComponent {
+export class EuiHorizontalGrid extends PureComponent {
render() {
const style = {
strokeDasharray: '5 5',
diff --git a/src/components/xy_chart/axis/vertical_grid.js b/src/components/xy_chart/axis/vertical_grid.js
index cded870d3d77..b8106b87a0ae 100644
--- a/src/components/xy_chart/axis/vertical_grid.js
+++ b/src/components/xy_chart/axis/vertical_grid.js
@@ -1,7 +1,7 @@
import React, { PureComponent } from 'react';
import { VerticalGridLines } from 'react-vis';
-export default class EuiVerticalGrid extends PureComponent {
+export class EuiVerticalGrid extends PureComponent {
render() {
const style = {
strokeDasharray: '5 5',
diff --git a/src/components/xy_chart/axis/x_axis.js b/src/components/xy_chart/axis/x_axis.js
index 4f3bdb00557b..87eb2fbc911c 100644
--- a/src/components/xy_chart/axis/x_axis.js
+++ b/src/components/xy_chart/axis/x_axis.js
@@ -1,10 +1,11 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { XAxis } from 'react-vis';
-import { ORIENTATION, TITLE_POSITION } from '../utils/axis_utils'
+import { EuiXYChartAxisUtils } from '../utils/axis_utils';
+const { TITLE_POSITION, ORIENTATION } = EuiXYChartAxisUtils;
-export default class EuiXAxis extends PureComponent {
+export class EuiXAxis extends PureComponent {
render() {
const {
title,
diff --git a/src/components/xy_chart/axis/y_axis.js b/src/components/xy_chart/axis/y_axis.js
index 03f69902cbd3..303438d3c302 100644
--- a/src/components/xy_chart/axis/y_axis.js
+++ b/src/components/xy_chart/axis/y_axis.js
@@ -1,9 +1,11 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { YAxis } from 'react-vis';
-import { ORIENTATION, TITLE_POSITION } from '../utils/axis_utils';
+import { EuiXYChartAxisUtils } from '../utils/axis_utils';
-export default class EuiYAxis extends PureComponent {
+const { TITLE_POSITION, ORIENTATION } = EuiXYChartAxisUtils;
+
+export class EuiYAxis extends PureComponent {
render() {
const {
title,
diff --git a/src/components/xy_chart/chart.js b/src/components/xy_chart/chart.js
index 40d4fd3c9f67..68012f120d8b 100644
--- a/src/components/xy_chart/chart.js
+++ b/src/components/xy_chart/chart.js
@@ -6,7 +6,7 @@ import { EuiCrosshair } from './crosshair';
import { VISUALIZATION_COLORS } from '../../services';
import StatusText from './status-text';
-export class XYChart extends PureComponent {
+class XYChart extends PureComponent {
state = {
mouseOver: false,
};
@@ -142,4 +142,4 @@ XYChart.defaultProps = {
yType: 'linear',
};
-export default makeWidthFlexible(XYChart);
+export const EuiXYChart = makeWidthFlexible(XYChart);
diff --git a/src/components/xy_chart/chart.test.js b/src/components/xy_chart/chart.test.js
index d9466c3927b3..d08c9e83461d 100644
--- a/src/components/xy_chart/chart.test.js
+++ b/src/components/xy_chart/chart.test.js
@@ -1,7 +1,7 @@
import React from 'react';
import { mount, render } from 'enzyme';
-import EuiXYChart from './chart';
+import { EuiXYChart } from './chart';
import { requiredProps } from '../../test/required_props';
describe('EuiXYChart', () => {
diff --git a/src/components/xy_chart/horizontal_bar_series.js b/src/components/xy_chart/horizontal_bar_series.js
index f45431f57a81..0c4003815874 100644
--- a/src/components/xy_chart/horizontal_bar_series.js
+++ b/src/components/xy_chart/horizontal_bar_series.js
@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { HorizontalBarSeries } from 'react-vis';
-class EuiHorizontalBarSeries extends HorizontalBarSeries {
+export class EuiHorizontalBarSeries extends HorizontalBarSeries {
render() {
const { name, data, color, onClick, ...rest } = this.props;
@@ -25,7 +25,6 @@ class EuiHorizontalBarSeries extends HorizontalBarSeries {
);
}
}
-export default EuiHorizontalBarSeries;
EuiHorizontalBarSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
diff --git a/src/components/xy_chart/horizontal_bar_series.test.js b/src/components/xy_chart/horizontal_bar_series.test.js
index e82fc8adbb4f..84286eff7621 100644
--- a/src/components/xy_chart/horizontal_bar_series.test.js
+++ b/src/components/xy_chart/horizontal_bar_series.test.js
@@ -3,8 +3,8 @@ import { render, mount } from 'enzyme';
import { patchRandom, unpatchRandom } from '../../test/patch_random';
import { requiredProps } from '../../test/required_props';
-import EuiXYChart from './chart';
-import EuiHorizontalBarSeries from './horizontal_bar_series';
+import { EuiXYChart } from './chart';
+import { EuiHorizontalBarSeries } from './horizontal_bar_series';
beforeEach(patchRandom);
afterEach(unpatchRandom);
diff --git a/src/components/xy_chart/horizontal_rect_series.js b/src/components/xy_chart/horizontal_rect_series.js
index 9ac3b94ceb9e..102f0ee119ed 100644
--- a/src/components/xy_chart/horizontal_rect_series.js
+++ b/src/components/xy_chart/horizontal_rect_series.js
@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { HorizontalRectSeries } from 'react-vis';
-class EuiHorizontalRectSeries extends HorizontalRectSeries {
+export class EuiHorizontalRectSeries extends HorizontalRectSeries {
render() {
const { name, data, color, onClick, ...rest } = this.props;
@@ -25,7 +25,6 @@ class EuiHorizontalRectSeries extends HorizontalRectSeries {
);
}
}
-export default EuiHorizontalRectSeries;
EuiHorizontalRectSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
diff --git a/src/components/xy_chart/horizontal_rect_series.test.js b/src/components/xy_chart/horizontal_rect_series.test.js
index cf67a63fc201..486f839ebea3 100644
--- a/src/components/xy_chart/horizontal_rect_series.test.js
+++ b/src/components/xy_chart/horizontal_rect_series.test.js
@@ -3,8 +3,8 @@ import { render, mount } from 'enzyme';
import { patchRandom, unpatchRandom } from '../../test/patch_random';
import { requiredProps } from '../../test/required_props';
-import EuiXYChart from './chart';
-import EuiHorizontalRectSeries from './horizontal_rect_series';
+import { EuiXYChart } from './chart';
+import { EuiHorizontalRectSeries } from './horizontal_rect_series';
beforeEach(patchRandom);
afterEach(unpatchRandom);
diff --git a/src/components/xy_chart/index.js b/src/components/xy_chart/index.js
index 3c3b0bd36420..b33391942f9c 100644
--- a/src/components/xy_chart/index.js
+++ b/src/components/xy_chart/index.js
@@ -1,30 +1,14 @@
-import { asSeries } from './as_series';
-import EuiXYChart from './chart';
-import * as utils from './utils/chart_utils';
+export { asSeries } from './as_series';
+export { EuiXYChart } from './chart';
export { EuiLine } from './line';
-import EuiVerticalBarSeries from './vertical_bar_series';
-import EuiHorizontalBarSeries from './horizontal_bar_series';
-import EuiVerticalRectSeries from './vertical_rect_series';
-import EuiHorizontalRectSeries from './horizontal_rect_series';
-import EuiDefaultAxis from './axis/default_axis';
-import EuiXAxis from './axis/x_axis';
-import EuiYAxis from './axis/y_axis';
+export { EuiVerticalBarSeries } from './vertical_bar_series';
+export { EuiHorizontalBarSeries } from './horizontal_bar_series';
+export { EuiVerticalRectSeries } from './vertical_rect_series';
+export { EuiHorizontalRectSeries } from './horizontal_rect_series';
+export { EuiDefaultAxis } from './axis/default_axis';
+export { EuiXAxis } from './axis/x_axis';
+export { EuiYAxis } from './axis/y_axis';
export { EuiArea } from './area';
-import * as EuiXYChartAxisUtils from './utils/axis_utils';
-import * as EuiXYChartTextUtils from './utils/text_utils';
+export { EuiXYChartAxisUtils } from './utils/axis_utils';
+export { EuiXYChartTextUtils } from './utils/text_utils';
export { EuiCrosshair } from './crosshair';
-
-export {
- EuiXYChart,
- EuiVerticalBarSeries,
- EuiHorizontalBarSeries,
- EuiVerticalRectSeries,
- EuiHorizontalRectSeries,
- EuiDefaultAxis,
- EuiXAxis,
- EuiYAxis,
- EuiXYChartAxisUtils,
- EuiXYChartTextUtils,
- utils,
- asSeries
-};
diff --git a/src/components/xy_chart/line.test.js b/src/components/xy_chart/line.test.js
index e0fe5275736e..a7536592f494 100644
--- a/src/components/xy_chart/line.test.js
+++ b/src/components/xy_chart/line.test.js
@@ -4,7 +4,7 @@ import { patchRandom, unpatchRandom } from '../../test/patch_random';
import { benchmarkFunction } from '../../test/time_execution';
import { requiredProps } from '../../test/required_props';
-import EuiXYChart from './chart';
+import { EuiXYChart } from './chart';
import { EuiLine } from './line';
beforeEach(patchRandom);
diff --git a/src/components/xy_chart/utils/axis_utils.js b/src/components/xy_chart/utils/axis_utils.js
index d893a8a5752c..3056e7324a3d 100644
--- a/src/components/xy_chart/utils/axis_utils.js
+++ b/src/components/xy_chart/utils/axis_utils.js
@@ -1,15 +1,21 @@
import { AxisUtils } from 'react-vis';
-export const ORIENTATION = AxisUtils.ORIENTATION;
+const ORIENTATION = AxisUtils.ORIENTATION;
-export const TITLE_POSITION = {
+const TITLE_POSITION = {
MIDDLE: 'middle',
START: 'start',
END: 'end',
};
-export const GRID_TYPE = {
+const GRID_TYPE = {
HORIZONTAL: 'horizontal',
VERTICAL: 'vertical',
BOTH: 'both',
-}
+};
+
+export const EuiXYChartAxisUtils = {
+ TITLE_POSITION,
+ GRID_TYPE,
+ ORIENTATION,
+};
diff --git a/src/components/xy_chart/utils/chart_utils.js b/src/components/xy_chart/utils/chart_utils.js
deleted file mode 100644
index 58a5a0f266b2..000000000000
--- a/src/components/xy_chart/utils/chart_utils.js
+++ /dev/null
@@ -1,50 +0,0 @@
-import { scaleLinear } from 'd3-scale';
-import _ from 'lodash';
-import * as d3 from 'd3-array';
-
-const unit = 16;
-const XY_HEIGHT = unit * 16;
-const XY_MARGIN = {
- top: unit,
- left: unit * 5,
- right: unit,
- bottom: unit * 2
-};
-
-const getXScale = _.memoize(
- (xMin, xMax, width) => {
- return scaleLinear()
- .domain([xMin, xMax])
- .range([XY_MARGIN.left, width - XY_MARGIN.right]);
- },
- (...args) => args.join('_')
-);
-
-const getYScale = _.memoize(
- (yMin, yMax) => {
- return scaleLinear()
- .domain([yMin, yMax])
- .range([XY_HEIGHT, 0])
- .nice();
- },
- (...args) => args.join('_')
-);
-
-const getYTickValues = _.memoize(yMaxNice => [0, yMaxNice / 2, yMaxNice]);
-
-export function getPlotValues(series, width) {
- if (series.length === 0) return;
-
- const allCoordinates = _.flatten(series);
-
- const xExtent = d3.extent(allCoordinates, d => d.x);
- const yMin = 0;
- const yMax = d3.max(allCoordinates, d => d.y);
-
- const x = getXScale(xExtent[0], xExtent[1], width);
- const y = getYScale(yMin, yMax);
- const yTickValues = getYTickValues(y.domain()[1]);
- const xTickValues = getYTickValues(x.domain()[1]);
-
- return { x, y, yTickValues, xTickValues };
-}
diff --git a/src/components/xy_chart/utils/text_utils.js b/src/components/xy_chart/utils/text_utils.js
index 4ccfbc31fa67..0d12226983ce 100644
--- a/src/components/xy_chart/utils/text_utils.js
+++ b/src/components/xy_chart/utils/text_utils.js
@@ -7,7 +7,7 @@ import React from 'react'
* @return {Object} Returns an Object to use with dangerouslySetInnerHTML
* with the rendered markdown HTML
*/
-export function tspanTextWrapper(texts) {
+function tspanTextWrapper(texts) {
return (
{
@@ -20,3 +20,7 @@ export function tspanTextWrapper(texts) {
)
}
+
+export const EuiXYChartTextUtils = {
+ tspanTextWrapper,
+}
diff --git a/src/components/xy_chart/vertical_bar_series.js b/src/components/xy_chart/vertical_bar_series.js
index be95df1d46ed..dd00b5008be9 100644
--- a/src/components/xy_chart/vertical_bar_series.js
+++ b/src/components/xy_chart/vertical_bar_series.js
@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { VerticalBarSeries } from 'react-vis';
-class EuiVerticalBarSeries extends VerticalBarSeries {
+export class EuiVerticalBarSeries extends VerticalBarSeries {
render() {
const { name, data, color, onClick, ...rest } = this.props;
@@ -23,7 +23,6 @@ class EuiVerticalBarSeries extends VerticalBarSeries {
);
}
}
-export default EuiVerticalBarSeries;
EuiVerticalBarSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
diff --git a/src/components/xy_chart/vertical_bar_series.test.js b/src/components/xy_chart/vertical_bar_series.test.js
index f837305035af..181ccda6d4a1 100644
--- a/src/components/xy_chart/vertical_bar_series.test.js
+++ b/src/components/xy_chart/vertical_bar_series.test.js
@@ -3,8 +3,8 @@ import { render, mount } from 'enzyme';
import { patchRandom, unpatchRandom } from '../../test/patch_random';
import { requiredProps } from '../../test/required_props';
-import EuiXYChart from './chart';
-import EuiVerticalBarSeries from './vertical_bar_series';
+import { EuiXYChart } from './chart';
+import { EuiVerticalBarSeries } from './vertical_bar_series';
import { benchmarkFunction } from '../../test/time_execution';
beforeEach(patchRandom);
diff --git a/src/components/xy_chart/vertical_rect_series.js b/src/components/xy_chart/vertical_rect_series.js
index 40913d47f280..8b02787dcf04 100644
--- a/src/components/xy_chart/vertical_rect_series.js
+++ b/src/components/xy_chart/vertical_rect_series.js
@@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import { VerticalRectSeries } from 'react-vis';
-export default class EuiVerticalRectSeries extends VerticalRectSeries {
+export class EuiVerticalRectSeries extends VerticalRectSeries {
render() {
const { name, data, color, onClick, ...rest } = this.props;
diff --git a/src/components/xy_chart/vertical_rect_series.test.js b/src/components/xy_chart/vertical_rect_series.test.js
index c4f892fb78f9..9ad2b887cbd8 100644
--- a/src/components/xy_chart/vertical_rect_series.test.js
+++ b/src/components/xy_chart/vertical_rect_series.test.js
@@ -3,8 +3,8 @@ import { render, mount } from 'enzyme';
import { patchRandom, unpatchRandom } from '../../test/patch_random';
import { requiredProps } from '../../test/required_props';
-import EuiXYChart from './chart';
-import EuiVerticalRectSeries from './vertical_rect_series';
+import { EuiXYChart } from './chart';
+import { EuiVerticalRectSeries } from './vertical_rect_series';
import { benchmarkFunction } from '../../test/time_execution';
beforeEach(patchRandom);
From 444ff2dc109087b56a16a94f0cf7fae03dc49fde Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Mon, 18 Jun 2018 18:29:02 +0200
Subject: [PATCH 18/68] Add X chrosshair with fixed histogram and series
behaviours
---
.../src/views/xy_chart/example-crosshair.js | 17 +-
src/components/index.js | 2 +-
.../xy_chart/__snapshots__/area.test.js.snap | 506 +++++++++++++++-
.../xy_chart/__snapshots__/line.test.js.snap | 542 +++++++++++++++++-
src/components/xy_chart/chart.js | 57 +-
src/components/xy_chart/crosshair.js | 69 ---
src/components/xy_chart/crosshair_x.js | 161 ++++++
src/components/xy_chart/index.js | 2 +-
src/components/xy_chart/utils/series_utils.js | 22 +
.../xy_chart/vertical_bar_series.js | 8 +-
.../xy_chart/vertical_rect_series.js | 7 +-
11 files changed, 1259 insertions(+), 134 deletions(-)
delete mode 100644 src/components/xy_chart/crosshair.js
create mode 100644 src/components/xy_chart/crosshair_x.js
create mode 100644 src/components/xy_chart/utils/series_utils.js
diff --git a/src-docs/src/views/xy_chart/example-crosshair.js b/src-docs/src/views/xy_chart/example-crosshair.js
index 3c06b875c533..b67e83199baf 100644
--- a/src-docs/src/views/xy_chart/example-crosshair.js
+++ b/src-docs/src/views/xy_chart/example-crosshair.js
@@ -9,10 +9,11 @@ import {
// eslint-disable-next-line
export class ExampleCrosshair extends React.Component {
state = {
- crosshairX: 0
+ crosshairX: 2,
}
_updateCrosshairLocation = (crosshairX) => {
- this.setState({ crosshairX })
+ console.log('update crosshair x');
+ this.setState({ crosshairX });
}
render() {
return (
@@ -23,7 +24,11 @@ export class ExampleCrosshair extends React.Component {
width={600}
height={200}
>
-
+
@@ -33,7 +38,11 @@ export class ExampleCrosshair extends React.Component {
width={600}
height={200}
>
-
+
diff --git a/src/components/index.js b/src/components/index.js
index 86844eda0c5e..dffacdff03eb 100644
--- a/src/components/index.js
+++ b/src/components/index.js
@@ -315,5 +315,5 @@ export {
EuiDefaultAxis,
EuiXAxis,
EuiYAxis,
- EuiCrosshair,
+ EuiCrosshairX,
} from './xy_chart';
diff --git a/src/components/xy_chart/__snapshots__/area.test.js.snap b/src/components/xy_chart/__snapshots__/area.test.js.snap
index 25d92608c398..3b638920b588 100644
--- a/src/components/xy_chart/__snapshots__/area.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/area.test.js.snap
@@ -31,8 +31,6 @@ exports[`EuiArea all props are rendered 1`] = `
dontCheckIfEmpty={true}
height={200}
margin={2}
- onMouseLeave={[Function]}
- onMouseMove={[Function]}
width={600}
xPadding={0}
xType="linear"
@@ -79,6 +77,7 @@ exports[`EuiArea all props are rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="#ff0000"
@@ -154,7 +153,7 @@ exports[`EuiArea all props are rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -215,6 +214,7 @@ exports[`EuiArea all props are rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="#ff0000"
@@ -291,7 +291,7 @@ exports[`EuiArea all props are rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -357,6 +357,7 @@ exports[`EuiArea all props are rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="#ff0000"
@@ -470,7 +471,7 @@ exports[`EuiArea all props are rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -555,6 +556,7 @@ exports[`EuiArea all props are rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_animation={0.00002}
@@ -631,7 +633,7 @@ exports[`EuiArea all props are rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -706,6 +708,245 @@ exports[`EuiArea all props are rendered 1`] = `
+
+
+
@@ -755,8 +996,6 @@ exports[`EuiArea is rendered 1`] = `
dontCheckIfEmpty={true}
height={200}
margin={2}
- onMouseLeave={[Function]}
- onMouseMove={[Function]}
width={600}
xPadding={0}
xType="linear"
@@ -803,6 +1042,7 @@ exports[`EuiArea is rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="#00B3A4"
@@ -873,7 +1113,7 @@ exports[`EuiArea is rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -934,6 +1174,7 @@ exports[`EuiArea is rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="#00B3A4"
@@ -1005,7 +1246,7 @@ exports[`EuiArea is rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -1071,6 +1312,7 @@ exports[`EuiArea is rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="#00B3A4"
@@ -1179,7 +1421,7 @@ exports[`EuiArea is rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -1264,6 +1506,7 @@ exports[`EuiArea is rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_animation={0.00002}
@@ -1335,7 +1578,7 @@ exports[`EuiArea is rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -1410,6 +1653,245 @@ exports[`EuiArea is rendered 1`] = `
+
+
+
diff --git a/src/components/xy_chart/__snapshots__/line.test.js.snap b/src/components/xy_chart/__snapshots__/line.test.js.snap
index c05b44ebce96..9ee47b20dc54 100644
--- a/src/components/xy_chart/__snapshots__/line.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/line.test.js.snap
@@ -31,8 +31,6 @@ exports[`EuiLine all props are rendered 1`] = `
dontCheckIfEmpty={true}
height={200}
margin={2}
- onMouseLeave={[Function]}
- onMouseMove={[Function]}
width={600}
xPadding={0}
xType="linear"
@@ -79,6 +77,7 @@ exports[`EuiLine all props are rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="#ff0000"
@@ -155,7 +154,7 @@ exports[`EuiLine all props are rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
showLine={true}
showLineMarks={true}
@@ -218,6 +217,7 @@ exports[`EuiLine all props are rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="white"
@@ -291,7 +291,7 @@ exports[`EuiLine all props are rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -358,6 +358,7 @@ exports[`EuiLine all props are rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="white"
@@ -468,7 +469,7 @@ exports[`EuiLine all props are rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -554,6 +555,7 @@ exports[`EuiLine all props are rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_animation={0.00002}
@@ -627,7 +629,7 @@ exports[`EuiLine all props are rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -715,6 +717,7 @@ exports[`EuiLine all props are rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="#ff0000"
@@ -788,7 +791,7 @@ exports[`EuiLine all props are rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -855,6 +858,7 @@ exports[`EuiLine all props are rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="#ff0000"
@@ -965,7 +969,7 @@ exports[`EuiLine all props are rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -1051,6 +1055,7 @@ exports[`EuiLine all props are rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_animation={0.00004}
@@ -1124,7 +1129,7 @@ exports[`EuiLine all props are rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -1212,6 +1217,7 @@ exports[`EuiLine all props are rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="#ff0000"
@@ -1284,7 +1290,7 @@ exports[`EuiLine all props are rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
size={13}
sizeDomain={Array []}
@@ -1347,6 +1353,7 @@ exports[`EuiLine all props are rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="#ff0000"
@@ -1456,7 +1463,7 @@ exports[`EuiLine all props are rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
size={13}
sizeDomain={Array []}
@@ -1538,6 +1545,7 @@ exports[`EuiLine all props are rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_animation={0.00006}
@@ -1610,7 +1618,7 @@ exports[`EuiLine all props are rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
size={13}
sizeDomain={Array []}
@@ -1706,6 +1714,245 @@ exports[`EuiLine all props are rendered 1`] = `
+
+
+
@@ -1755,8 +2002,6 @@ exports[`EuiLine is rendered 1`] = `
dontCheckIfEmpty={true}
height={200}
margin={2}
- onMouseLeave={[Function]}
- onMouseMove={[Function]}
width={600}
xPadding={0}
xType="linear"
@@ -1803,6 +2048,7 @@ exports[`EuiLine is rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="#00B3A4"
@@ -1875,7 +2121,7 @@ exports[`EuiLine is rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
showLine={true}
showLineMarks={true}
@@ -1938,6 +2184,7 @@ exports[`EuiLine is rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="white"
@@ -2009,7 +2256,7 @@ exports[`EuiLine is rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -2076,6 +2323,7 @@ exports[`EuiLine is rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="white"
@@ -2184,7 +2432,7 @@ exports[`EuiLine is rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -2270,6 +2518,7 @@ exports[`EuiLine is rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_animation={0.00002}
@@ -2341,7 +2590,7 @@ exports[`EuiLine is rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -2429,6 +2678,7 @@ exports[`EuiLine is rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="#00B3A4"
@@ -2501,7 +2751,7 @@ exports[`EuiLine is rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -2568,6 +2818,7 @@ exports[`EuiLine is rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="#00B3A4"
@@ -2677,7 +2928,7 @@ exports[`EuiLine is rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -2763,6 +3014,7 @@ exports[`EuiLine is rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_animation={0.00004}
@@ -2835,7 +3087,7 @@ exports[`EuiLine is rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
sizeDomain={Array []}
sizeRange={
@@ -2923,6 +3175,7 @@ exports[`EuiLine is rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="#00B3A4"
@@ -2993,7 +3246,7 @@ exports[`EuiLine is rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
size={5}
sizeDomain={Array []}
@@ -3056,6 +3309,7 @@ exports[`EuiLine is rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_colorValue="#00B3A4"
@@ -3163,7 +3417,7 @@ exports[`EuiLine is rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
size={5}
sizeDomain={Array []}
@@ -3245,6 +3499,7 @@ exports[`EuiLine is rendered 1`] = `
"y": 15,
},
],
+ undefined,
]
}
_animation={0.00006}
@@ -3315,7 +3570,7 @@ exports[`EuiLine is rendered 1`] = `
opacityType="literal"
radiusDomain={Array []}
sameTypeIndex={0}
- sameTypeTotal={1}
+ sameTypeTotal={2}
seriesIndex={0}
size={5}
sizeDomain={Array []}
@@ -3411,6 +3666,245 @@ exports[`EuiLine is rendered 1`] = `
+
+
+
diff --git a/src/components/xy_chart/chart.js b/src/components/xy_chart/chart.js
index 68012f120d8b..cbb45dc403e4 100644
--- a/src/components/xy_chart/chart.js
+++ b/src/components/xy_chart/chart.js
@@ -1,10 +1,35 @@
import React, { PureComponent } from 'react';
import { XYPlot, makeWidthFlexible, AbstractSeries } from 'react-vis';
+
import PropTypes from 'prop-types';
import Highlight from './highlight';
-import { EuiCrosshair } from './crosshair';
+import { EuiCrosshairX } from './crosshair_x';
import { VISUALIZATION_COLORS } from '../../services';
import StatusText from './status-text';
+import { getSeriesChildren } from './utils/series_utils';
+
+class XYExtendedPlot extends XYPlot {
+ /**
+ * Trigger onMouseLeave handler if it was passed in props.
+ * @param {Event} event Native event.
+ * @private
+ */
+ _mouseLeaveHandler(event) {
+ const { onMouseLeave, children } = this.props;
+ console.log('parent mouse leaving')
+ if (onMouseLeave) {
+ super.onMouseLeave(event);
+ }
+ const seriesChildren = getSeriesChildren(children);
+ seriesChildren.forEach((child, index) => {
+ const component = this.refs[`series${index}`];
+ if (component && component.onParentMouseLeave) {
+ component.onParentMouseLeave(event);
+ }
+ });
+ }
+
+}
class XYChart extends PureComponent {
state = {
@@ -13,17 +38,6 @@ class XYChart extends PureComponent {
colorIterator = 0;
_xyPlotRef = React.createRef();
- _onMouseLeave = () => {
- // TODO we need to find a better way to trigger a mouse leave event
- // for the crosshair
- this.setState({ mouseOver: false });
- }
-
- _onMouseMove = (e) => {
- e.preventDefault();
- this.setState({ mouseOver: true });
- }
-
_renderChildren = (child, i) => {
const { prototype } = child.type;
// Avoid applying chart props to non series children
@@ -44,6 +58,11 @@ class XYChart extends PureComponent {
return React.cloneElement(child, props);
}
+ // canShowCrosshair = () => {
+ // const { crosshairX, showTooltips } = this.props;
+ // const { mouseOver } = this.state;
+ // return showTooltips && ( mouseOver || crosshairX !== undefined)
+ // }
render() {
const {
@@ -53,7 +72,6 @@ class XYChart extends PureComponent {
yType,
stackBy,
errorText,
- showTooltips,
onSelectEnd,
children,
xDomain,
@@ -61,6 +79,8 @@ class XYChart extends PureComponent {
yPadding,
xPadding,
animation, // eslint-disable-line no-unused-vars
+ showTooltips,
+ crosshairX,
onCrosshairUpdate, // eslint-disable-line no-unused-vars
truncateLegends, // eslint-disable-line no-unused-vars
...rest
@@ -75,7 +95,7 @@ class XYChart extends PureComponent {
return (
-
+ { showTooltips && (
+
)}
{onSelectEnd && }
-
+
);
}
diff --git a/src/components/xy_chart/crosshair.js b/src/components/xy_chart/crosshair.js
deleted file mode 100644
index d548480784ca..000000000000
--- a/src/components/xy_chart/crosshair.js
+++ /dev/null
@@ -1,69 +0,0 @@
-import React from 'react';
-import { AbstractSeries, Crosshair } from 'react-vis';
-
-export class EuiCrosshair extends AbstractSeries {
- state = {
- crosshairValues: [],
- }
-
- static get requiresSVG() {
- return false;
- }
-
- static get isCanvas() {
- return false;
- }
-
- onParentMouseMove(event) {
- this._handleNearestX(event);
- }
-
- onParentMouseMove(event) {
- this._handleNearestX(event);
- }
-
- _handleNearestX(event) {
- const chartData = this.props._allData.filter(d => d)
- if (chartData.length === 0) {
- return
- }
- const coordinate = super._getXYCoordinateInContainer(event);
- const xScaleFn = super._getAttributeFunctor('x');
-
- const crosshairValues = chartData
- .map(data => {
- let minDistance = Number.POSITIVE_INFINITY;
- let value = null;
- data.forEach((item) => {
- const currentCoordinate = xScaleFn(item);
- const newDistance = Math.abs(coordinate.x - currentCoordinate);
- if (newDistance < minDistance) {
- minDistance = newDistance;
- value = item;
- }
- });
- if (!value) {
- return;
- }
- return {
- ...value,
- }
- })
- .filter(d => d);
-
- this.setState({
- crosshairValues,
- });
- }
-
- render() {
-
- return (
-
- )
- }
-}
diff --git a/src/components/xy_chart/crosshair_x.js b/src/components/xy_chart/crosshair_x.js
new file mode 100644
index 000000000000..47d4b1f0dfc4
--- /dev/null
+++ b/src/components/xy_chart/crosshair_x.js
@@ -0,0 +1,161 @@
+import React from 'react';
+import { AbstractSeries, Crosshair } from 'react-vis';
+
+export class EuiCrosshairX extends AbstractSeries {
+ state = {
+ crosshairValues: [],
+ }
+
+ static get requiresSVG() {
+ return false;
+ }
+
+ static get isCanvas() {
+ return false;
+ }
+
+ static getDerivedStateFromProps(props) {
+ const { crosshairX, _allData } = props;
+
+ if (crosshairX !== undefined) {
+ return {
+ crosshairValues: EuiCrosshairX._computeDataFromXValue(_allData, crosshairX),
+ };
+ }
+ return null;
+ }
+
+ static _computeDataFromXValue(dataSeries, crosshairX) {
+ const filteredAndFlattenDataByX = dataSeries
+ .filter(series => series) // get only cleaned data series
+ .map(series => {
+ return series
+ .filter(dataPoint => dataPoint.x === crosshairX)
+ .map(dataPoint => ({ ...dataPoint, originalValues: { ...dataPoint } }));
+ })
+ .reduce((acc, val) => acc.concat(val), []);
+ return filteredAndFlattenDataByX;
+ }
+
+ onParentMouseMove(event) {
+ this._handleNearestX(event);
+ }
+
+ onParentMouseLeave() {
+ if (this.props.onCrosshairUpdate) {
+ this.props.onCrosshairUpdate(null);
+ }
+ this.setState({
+ crosshairValues: []
+ })
+ }
+
+ _titleFormat = (dataPoints = []) => {
+ if (dataPoints.length > 0) {
+ const [ firstDataPoint ] = dataPoints
+ const { originalValues } = firstDataPoint
+ const value = (typeof originalValues.x0 === 'number')
+ ? `${originalValues.x0} to ${originalValues.x}`
+ : originalValues.x;
+ return {
+ title: 'X Value',
+ value,
+ }
+ }
+ }
+
+ _itemsFormat = (dataPoints) => {
+ return dataPoints.map((d, i) => {
+ return {
+ title: `series ${i}`, // TODO specify series title or default one
+ value: d.y,
+ };
+ });
+ }
+
+ _handleNearestX(event) {
+ const cleanedDataSeries = this.props._allData.filter(dataSeries => dataSeries);
+ if (cleanedDataSeries.length === 0) {
+ return;
+ }
+ const containerCoordiante = super._getXYCoordinateInContainer(event);
+ this._findNearestXData(cleanedDataSeries, containerCoordiante.x);
+ }
+
+ _findNearestXData(dataSeries, mouseXContainerCoords) {
+ const xScaleFn = super._getAttributeFunctor('x');
+ // keeping a global min distance to filter only elements with the same distance
+ let globalMinDistance = Number.POSITIVE_INFINITY;
+
+ const nearestXData = dataSeries
+ .map(data => {
+ let minDistance = Number.POSITIVE_INFINITY;
+ let value = null;
+ data.forEach((item) => {
+ let itemXCoords;
+ const xCoord = xScaleFn(item);
+ // check the right item coordinate if we use x0 and x value (e.g. on histograms)
+ if (typeof item.x0 === 'number') {
+ // we need to compute the scaled x0 using the xScale attribute functor
+ // we don't have access of the x0 attribute functor
+ const x0Coord = xScaleFn({ x: item.x0 });
+ itemXCoords = (xCoord - x0Coord) / 2 + x0Coord;
+ } else {
+ itemXCoords = xCoord;
+ }
+ const newDistance = Math.abs(mouseXContainerCoords - itemXCoords);
+ if (newDistance < minDistance) {
+ minDistance = newDistance;
+ value = item;
+ }
+ globalMinDistance = Math.min(globalMinDistance, minDistance)
+ });
+
+ if (!value) {
+ return;
+ }
+
+ return {
+ minDistance,
+ value,
+ };
+ })
+ .filter(d => d);
+
+ // filter and map nearest X data per dataseries to get only the nearet onces
+ const crosshairValues = nearestXData
+ .filter(value => value.minDistance === globalMinDistance)
+ .map(value => {
+ // check if we are on histograms and we need to show the right x and y values
+ const d = value.value;
+ const x = typeof d.x0 === 'number'
+ ? (d.x - d.x0) / 2 + d.x0
+ : d.x;
+ const y = typeof d.y0 === 'number'
+ ? (d.y - d.y0)
+ : d.y;
+ return { x, y, originalValues: d };
+ });
+
+ if (this.props.onCrosshairUpdate) {
+ this.props.onCrosshairUpdate(crosshairValues[0].x);
+ }
+
+ this.setState({
+ crosshairValues,
+ });
+ }
+
+ render() {
+ const { crosshairValues } = this.state
+ return (
+
+ )
+ }
+}
diff --git a/src/components/xy_chart/index.js b/src/components/xy_chart/index.js
index b33391942f9c..91ab93a07b38 100644
--- a/src/components/xy_chart/index.js
+++ b/src/components/xy_chart/index.js
@@ -11,4 +11,4 @@ export { EuiYAxis } from './axis/y_axis';
export { EuiArea } from './area';
export { EuiXYChartAxisUtils } from './utils/axis_utils';
export { EuiXYChartTextUtils } from './utils/text_utils';
-export { EuiCrosshair } from './crosshair';
+export { EuiCrosshairX } from './crosshair_x';
diff --git a/src/components/xy_chart/utils/series_utils.js b/src/components/xy_chart/utils/series_utils.js
new file mode 100644
index 000000000000..44c65800ad2a
--- /dev/null
+++ b/src/components/xy_chart/utils/series_utils.js
@@ -0,0 +1,22 @@
+import React from 'react';
+import { AbstractSeries } from 'react-vis';
+
+/**
+ * Check if the component is series or not.
+ * @param {React.Component} child Component.
+ * @returns {boolean} True if the child is series, false otherwise.
+ */
+export function isSeriesChild(child) {
+ const { prototype } = child.type;
+ return prototype instanceof AbstractSeries;
+}
+
+/**
+ * Get all series from the 'children' object of the component.
+ * @param {Object} children Children.
+ * @returns {Array} Array of children.
+ */
+export function getSeriesChildren(children) {
+ return React.Children.toArray(children).filter(child =>
+ child && isSeriesChild(child));
+}
diff --git a/src/components/xy_chart/vertical_bar_series.js b/src/components/xy_chart/vertical_bar_series.js
index dd00b5008be9..f0c5cd78d181 100644
--- a/src/components/xy_chart/vertical_bar_series.js
+++ b/src/components/xy_chart/vertical_bar_series.js
@@ -3,8 +3,10 @@ import PropTypes from 'prop-types';
import { VerticalBarSeries } from 'react-vis';
export class EuiVerticalBarSeries extends VerticalBarSeries {
+
render() {
const { name, data, color, onClick, ...rest } = this.props;
+ const isHighDataVolume = data.length > 80 ? true : false;
return (
80 ? true : false;
return (
@@ -13,10 +14,10 @@ export class EuiVerticalRectSeries extends VerticalRectSeries {
onSeriesClick={onClick}
color={color}
style={{
- strokeWidth: 1,
+ strokeWidth: isHighDataVolume ? 0 : 1,
stroke: 'white',
- rx: 2,
- ry: 2,
+ rx: isHighDataVolume ? 0 : 2,
+ ry: isHighDataVolume ? 0 : 2,
}}
data={data}
{...rest}
From 3c7328543774e4415e65dd9ea851d5a7dc668a3a Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Tue, 19 Jun 2018 12:23:42 +0200
Subject: [PATCH 19/68] Add crosshair Y
---
.../xy_chart_bar/horizontal_bar_series.js | 21 ++-
.../views/xy_chart_bar/rotate_bar_series.js | 71 ++++++++
.../stacked_horizontal_bar_series.js | 2 +
.../horizontal_rect_series.js | 19 +-
.../stacked_horizontal_rect_series.js | 2 +
src/components/index.js | 3 +
.../xy_chart/__snapshots__/area.test.js.snap | 6 +-
.../xy_chart/__snapshots__/chart.test.js.snap | 3 +-
.../xy_chart/__snapshots__/line.test.js.snap | 6 +-
src/components/xy_chart/bar_series.js | 50 +++++
src/components/xy_chart/chart.js | 30 +--
.../xy_chart/{ => crosshairs}/crosshair_x.js | 10 +
.../xy_chart/crosshairs/crosshair_y.js | 172 ++++++++++++++++++
.../crosshairs/react_vis_crosshair_y.js | 170 +++++++++++++++++
src/components/xy_chart/index.js | 5 +-
src/components/xy_chart/utils/chart_utils.js | 9 +
src/components/xy_chart/utils/series_utils.js | 11 ++
17 files changed, 553 insertions(+), 37 deletions(-)
create mode 100644 src-docs/src/views/xy_chart_bar/rotate_bar_series.js
create mode 100644 src/components/xy_chart/bar_series.js
rename src/components/xy_chart/{ => crosshairs}/crosshair_x.js (92%)
create mode 100644 src/components/xy_chart/crosshairs/crosshair_y.js
create mode 100644 src/components/xy_chart/crosshairs/react_vis_crosshair_y.js
create mode 100644 src/components/xy_chart/utils/chart_utils.js
diff --git a/src-docs/src/views/xy_chart_bar/horizontal_bar_series.js b/src-docs/src/views/xy_chart_bar/horizontal_bar_series.js
index 7d37dca18e7b..ef24556e7234 100644
--- a/src-docs/src/views/xy_chart_bar/horizontal_bar_series.js
+++ b/src-docs/src/views/xy_chart_bar/horizontal_bar_series.js
@@ -1,26 +1,27 @@
import React from 'react';
-import { EuiXYChart, EuiHorizontalBarSeries, EuiDefaultAxis } from '../../../../src/components';
+import {
+ EuiXYChart,
+ EuiHorizontalBarSeries,
+ EuiDefaultAxis,
+ EuiXYChartUtils,
+} from '../../../../src/components';
const data = [
{ x: 3, y: 'A' },
{ x: 1, y: 'B' },
{ x: 5, y: 'C' },
{ x: 2, y: 'D' },
- { x: 1, y: 'E' }
-]
+ { x: 1, y: 'E' },
+];
export default () => (
-
-
+
+
);
diff --git a/src-docs/src/views/xy_chart_bar/rotate_bar_series.js b/src-docs/src/views/xy_chart_bar/rotate_bar_series.js
new file mode 100644
index 000000000000..2aa6416d59e8
--- /dev/null
+++ b/src-docs/src/views/xy_chart_bar/rotate_bar_series.js
@@ -0,0 +1,71 @@
+import React, { Component } from 'react';
+
+import {
+ EuiSwitch,
+ EuiXYChart,
+ EuiBarSeries,
+ EuiSpacer,
+ EuiDefaultAxis,
+} from '../../../../src/components';
+
+const horizontalData = [
+ { x: 3, y: 'A' },
+ { x: 1, y: 'B' },
+ { x: 5, y: 'C' },
+ { x: 2, y: 'D' },
+ { x: 1, y: 'E' }
+]
+const verticalData = [
+ { x: 'A', y: 3 },
+ { x: 'B', y: 1 },
+ { x: 'C', y: 5 },
+ { x: 'D', y: 2 },
+ { x: 'E', y: 1 },
+]
+
+export default class extends Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ isHorizontal: false,
+ };
+ }
+
+ onChange = e => {
+ this.setState({
+ isHorizontal: e.target.checked,
+ });
+ };
+
+ render() {
+ const { isHorizontal } = this.state
+ return (
+
+
+
+
+
+
+
+
+
+
+ )
+ }
+}
diff --git a/src-docs/src/views/xy_chart_bar/stacked_horizontal_bar_series.js b/src-docs/src/views/xy_chart_bar/stacked_horizontal_bar_series.js
index 3044417f4a1a..bd24a0fe3025 100644
--- a/src-docs/src/views/xy_chart_bar/stacked_horizontal_bar_series.js
+++ b/src-docs/src/views/xy_chart_bar/stacked_horizontal_bar_series.js
@@ -5,6 +5,7 @@ import {
EuiXYChart,
EuiHorizontalBarSeries,
EuiDefaultAxis,
+ EuiXYChartUtils,
} from '../../../../src/components';
const dataA = [
@@ -51,6 +52,7 @@ export default class extends Component {
diff --git a/src-docs/src/views/xy_chart_histogram/horizontal_rect_series.js b/src-docs/src/views/xy_chart_histogram/horizontal_rect_series.js
index 322a4f542476..2ee5f7afac8a 100644
--- a/src-docs/src/views/xy_chart_histogram/horizontal_rect_series.js
+++ b/src-docs/src/views/xy_chart_histogram/horizontal_rect_series.js
@@ -1,6 +1,11 @@
import React from 'react';
-import { EuiXYChart, EuiHorizontalRectSeries, EuiDefaultAxis } from '../../../../src/components';
+import {
+ EuiXYChart,
+ EuiHorizontalRectSeries,
+ EuiDefaultAxis,
+ EuiXYChartUtils,
+} from '../../../../src/components';
const data = [
{ x: 3, y: 0, y0: 1 },
@@ -8,18 +13,14 @@ const data = [
{ x: 5, y: 2, y0: 3 },
{ x: 2, y: 3, y0: 4 },
{ x: 1, y: 4, y0: 5 },
-]
+];
export default () => (
-
-
+
+
);
diff --git a/src-docs/src/views/xy_chart_histogram/stacked_horizontal_rect_series.js b/src-docs/src/views/xy_chart_histogram/stacked_horizontal_rect_series.js
index 05d5f36972bf..8f55bc4ae264 100644
--- a/src-docs/src/views/xy_chart_histogram/stacked_horizontal_rect_series.js
+++ b/src-docs/src/views/xy_chart_histogram/stacked_horizontal_rect_series.js
@@ -4,6 +4,7 @@ import {
EuiXYChart,
EuiHorizontalRectSeries,
EuiDefaultAxis,
+ EuiXYChartUtils,
} from '../../../../src/components';
const dataA = [
@@ -27,6 +28,7 @@ export default () => (
width={600}
height={200}
stackBy="x"
+ crosshairOrientation={EuiXYChartUtils.ORIENTATION.HORIZONTAL}
>
+ );
+ }
+}
+
+EuiBarSeries.propTypes = {
+ /** The name used to define the data in tooltips and ledgends */
+ name: PropTypes.string.isRequired,
+ isHorizontal: PropTypes.bool,
+ /** Array<{x: number, y: string|number}> */
+ data: PropTypes.arrayOf(PropTypes.shape({
+ x: PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.number
+ ]),
+ y: PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.number
+ ]),
+ })).isRequired,
+ /** Without a color set, a random EUI color palette color will be chosen */
+ color: PropTypes.string,
+ onClick: PropTypes.func
+};
+
+EuiBarSeries.defaultProps = {
+ isHorizontal: false,
+};
diff --git a/src/components/xy_chart/chart.js b/src/components/xy_chart/chart.js
index cbb45dc403e4..024cf6d69422 100644
--- a/src/components/xy_chart/chart.js
+++ b/src/components/xy_chart/chart.js
@@ -3,10 +3,12 @@ import { XYPlot, makeWidthFlexible, AbstractSeries } from 'react-vis';
import PropTypes from 'prop-types';
import Highlight from './highlight';
-import { EuiCrosshairX } from './crosshair_x';
+import { EuiCrosshairX } from './crosshairs/crosshair_x';
+import { EuiCrosshairY } from './crosshairs/crosshair_y';
import { VISUALIZATION_COLORS } from '../../services';
import StatusText from './status-text';
import { getSeriesChildren } from './utils/series_utils';
+import { EuiXYChartUtils } from './utils/chart_utils';
class XYExtendedPlot extends XYPlot {
/**
@@ -59,9 +61,9 @@ class XYChart extends PureComponent {
return React.cloneElement(child, props);
}
// canShowCrosshair = () => {
- // const { crosshairX, showTooltips } = this.props;
+ // const { crosshairValues, showCrosshair } = this.props;
// const { mouseOver } = this.state;
- // return showTooltips && ( mouseOver || crosshairX !== undefined)
+ // return showCrosshair && ( mouseOver || crosshairValues !== undefined)
// }
render() {
@@ -79,8 +81,9 @@ class XYChart extends PureComponent {
yPadding,
xPadding,
animation, // eslint-disable-line no-unused-vars
- showTooltips,
- crosshairX,
+ showCrosshair,
+ crosshairOrientation,
+ crosshairValues,
onCrosshairUpdate, // eslint-disable-line no-unused-vars
truncateLegends, // eslint-disable-line no-unused-vars
...rest
@@ -92,7 +95,9 @@ class XYChart extends PureComponent {
}
this.colorIterator = 0;
-
+ const Crosshair = crosshairOrientation === EuiXYChartUtils.ORIENTATION.HORIZONTAL
+ ? EuiCrosshairY
+ : EuiCrosshairX
return (
)}
@@ -145,9 +150,9 @@ XYChart.propTypes = {
// showAxis: PropTypes.bool,
xAxisLocation: PropTypes.string,
yAxisLocation: PropTypes.string,
- showTooltips: PropTypes.bool,
+ showCrosshair: PropTypes.bool,
errorText: PropTypes.string,
- crosshairX: PropTypes.number,
+ crosshairValues: PropTypes.number,
onCrosshairUpdate: PropTypes.func,
xDomain: PropTypes.array,
yDomain: PropTypes.array,
@@ -158,7 +163,8 @@ XYChart.propTypes = {
XYChart.defaultProps = {
truncateLegends: false,
// showAxis: true,
- showTooltips: true,
+ showCrosshair: true,
+ crosshairOrientation: EuiXYChartUtils.ORIENTATION.VERTICAL,
yPadding: 0,
xPadding: 0,
xType: 'linear',
diff --git a/src/components/xy_chart/crosshair_x.js b/src/components/xy_chart/crosshairs/crosshair_x.js
similarity index 92%
rename from src/components/xy_chart/crosshair_x.js
rename to src/components/xy_chart/crosshairs/crosshair_x.js
index 47d4b1f0dfc4..9780fa102f8d 100644
--- a/src/components/xy_chart/crosshair_x.js
+++ b/src/components/xy_chart/crosshairs/crosshair_x.js
@@ -1,6 +1,9 @@
import React from 'react';
import { AbstractSeries, Crosshair } from 'react-vis';
+/**
+ * The Crosshair used by the XYChart as main tooltip mechanism along X axis.
+ */
export class EuiCrosshairX extends AbstractSeries {
state = {
crosshairValues: [],
@@ -82,6 +85,13 @@ export class EuiCrosshairX extends AbstractSeries {
this._findNearestXData(cleanedDataSeries, containerCoordiante.x);
}
+ /**
+ * _findNearestXData - Find the nearest set of data in all existing series.
+ *
+ * @param {type} dataSeries an array of dataseries
+ * @param {type} mouseXContainerCoords the x coordinate of the mouse on the chart container
+ * @protected
+ */
_findNearestXData(dataSeries, mouseXContainerCoords) {
const xScaleFn = super._getAttributeFunctor('x');
// keeping a global min distance to filter only elements with the same distance
diff --git a/src/components/xy_chart/crosshairs/crosshair_y.js b/src/components/xy_chart/crosshairs/crosshair_y.js
new file mode 100644
index 000000000000..5da006d3dc04
--- /dev/null
+++ b/src/components/xy_chart/crosshairs/crosshair_y.js
@@ -0,0 +1,172 @@
+import React from 'react';
+import { AbstractSeries } from 'react-vis';
+import { CrosshairY } from './react_vis_crosshair_y';
+
+/**
+ * The Crosshair used by the XYChart as main tooltip mechanism along X axis.
+ */
+export class EuiCrosshairY extends AbstractSeries {
+ state = {
+ crosshairValues: [],
+ }
+
+ static get requiresSVG() {
+ return false;
+ }
+
+ static get isCanvas() {
+ return false;
+ }
+
+ static getDerivedStateFromProps(props) {
+ const { crosshairY, _allData } = props;
+
+ if (crosshairY !== undefined) {
+ return {
+ crosshairValues: EuiCrosshairY._computeDataFromYValue(_allData, crosshairY),
+ };
+ }
+ return null;
+ }
+
+ static _computeDataFromYValue(dataSeries, crosshairY) {
+ const filteredAndFlattenDataByY = dataSeries
+ .filter(series => series) // get only cleaned data series
+ .map(series => {
+ return series
+ .filter(dataPoint => dataPoint.y === crosshairY)
+ .map(dataPoint => ({ ...dataPoint, originalValues: { ...dataPoint } }));
+ })
+ .reduce((acc, val) => acc.concat(val), []);
+ return filteredAndFlattenDataByY;
+ }
+
+ onParentMouseMove(event) {
+ this._handleNearestY(event);
+ }
+
+ onParentMouseLeave() {
+ if (this.props.onCrosshairUpdate) {
+ this.props.onCrosshairUpdate(null);
+ }
+ this.setState({
+ crosshairValues: []
+ })
+ }
+
+ _titleFormat = (dataPoints = []) => {
+ if (dataPoints.length > 0) {
+ const [ firstDataPoint ] = dataPoints
+ const { originalValues } = firstDataPoint
+ const value = (typeof originalValues.y0 === 'number')
+ ? `${originalValues.y0} to ${originalValues.y}`
+ : originalValues.y;
+ return {
+ title: 'Y Value',
+ value,
+ }
+ }
+ }
+
+ _itemsFormat = (dataPoints) => {
+ return dataPoints.map((d, i) => {
+ return {
+ title: `series ${i}`, // TODO specify series title or default one
+ value: d.x,
+ };
+ });
+ }
+
+ _handleNearestY(event) {
+ const cleanedDataSeries = this.props._allData.filter(dataSeries => dataSeries);
+ if (cleanedDataSeries.length === 0) {
+ return;
+ }
+ const containerCoordiante = super._getXYCoordinateInContainer(event);
+ this._findNearestYData(cleanedDataSeries, containerCoordiante.y);
+ }
+
+ /**
+ * _findNearestYData - Find the nearest set of data in all existing series.
+ *
+ * @param {type} dataSeries an array of dataseries
+ * @param {type} mouseYContainerCoords the y coordinate of the mouse on the chart container
+ * @protected
+ */
+ _findNearestYData(dataSeries, mouseYContainerCoords) {
+ const yScaleFn = super._getAttributeFunctor('y');
+ // keeping a global min distance to filter only elements with the same distance
+ let globalMinDistance = Number.POSITIVE_INFINITY;
+
+ const nearestYData = dataSeries
+ .map(data => {
+ let minDistance = Number.POSITIVE_INFINITY;
+ let value = null;
+ data.forEach((item) => {
+ let itemYCoords;
+ const yCoord = yScaleFn(item);
+ // check the right item coordinate if we use x0 and x value (e.g. on histograms)
+ if (typeof item.y0 === 'number') {
+ // we need to compute the scaled y0 using the xScale attribute functor
+ // we don't have access of the y0 attribute functor
+ const y0Coord = yScaleFn({ x: item.y0 });
+ itemYCoords = (yCoord - y0Coord) / 2 + y0Coord;
+ } else {
+ itemYCoords = yCoord;
+ }
+ const newDistance = Math.abs(mouseYContainerCoords - itemYCoords);
+ if (newDistance < minDistance) {
+ minDistance = newDistance;
+ value = item;
+ }
+ globalMinDistance = Math.min(globalMinDistance, minDistance)
+ });
+
+ if (!value) {
+ return;
+ }
+
+ return {
+ minDistance,
+ value,
+ };
+ })
+ .filter(d => d);
+
+ // filter and map nearest X data per dataseries to get only the nearet onces
+ const crosshairValues = nearestYData
+ .filter(value => value.minDistance === globalMinDistance)
+ .map(value => {
+ // check if we are on histograms and we need to show the right x and y values
+ const d = value.value;
+ const y = typeof d.y0 === 'number'
+ ? (d.y - d.y0) / 2 + d.y0
+ : d.y;
+ const x = typeof d.x0 === 'number'
+ ? (d.x - d.x0)
+ : d.x;
+ return { x, y, originalValues: d };
+ });
+
+ if (this.props.onCrosshairUpdate) {
+ this.props.onCrosshairUpdate(crosshairValues[0].y);
+ }
+
+ this.setState({
+ crosshairValues,
+ });
+ }
+
+ render() {
+ const { crosshairValues } = this.state
+ return (
+
+ )
+ }
+}
diff --git a/src/components/xy_chart/crosshairs/react_vis_crosshair_y.js b/src/components/xy_chart/crosshairs/react_vis_crosshair_y.js
new file mode 100644
index 000000000000..f2c3f913a4d5
--- /dev/null
+++ b/src/components/xy_chart/crosshairs/react_vis_crosshair_y.js
@@ -0,0 +1,170 @@
+// TODO this is a more or less a copy and paste of crosshair y
+// we need to specify the license (if we need to use the uber one)
+// we need to find a better name
+
+import React, { PureComponent } from 'react';
+
+import PropTypes from 'prop-types';
+
+import { ScaleUtils } from 'react-vis';
+
+/**
+ * Format title by detault.
+ * @param {Array} values List of values.
+ * @returns {*} Formatted value or undefined.
+ */
+function defaultTitleFormat(values) {
+ const value = getFirstNonEmptyValue(values);
+ if (value) {
+ return {
+ title: 'x',
+ value: value.x
+ };
+ }
+}
+
+/**
+ * Format items by default.
+ * @param {Array} values Array of values.
+ * @returns {*} Formatted list of items.
+ */
+function defaultItemsFormat(values) {
+ return values.map((v, i) => {
+ if (v) {
+ return { value: v.y, title: i };
+ }
+ });
+}
+
+/**
+ * Get the first non-empty item from an array.
+ * @param {Array} values Array of values.
+ * @returns {*} First non-empty value or undefined.
+ */
+function getFirstNonEmptyValue(values) {
+ return (values || []).find(v => Boolean(v));
+}
+
+export class CrosshairY extends PureComponent {
+
+ static get propTypes() {
+ return {
+ className: PropTypes.string,
+ values: PropTypes.array,
+ series: PropTypes.object,
+ innerWidth: PropTypes.number,
+ innerHeight: PropTypes.number,
+ marginLeft: PropTypes.number,
+ marginTop: PropTypes.number,
+ orientation: PropTypes.oneOf(['left', 'right']),
+ itemsFormat: PropTypes.func,
+ titleFormat: PropTypes.func,
+ style: PropTypes.shape({
+ line: PropTypes.object,
+ title: PropTypes.object,
+ box: PropTypes.object
+ })
+ };
+ }
+
+ static get defaultProps() {
+ return {
+ titleFormat: defaultTitleFormat,
+ itemsFormat: defaultItemsFormat,
+ style: {
+ line: {},
+ title: {},
+ box: {}
+ }
+ };
+ }
+
+ /**
+ * Render crosshair title.
+ * @returns {*} Container with the crosshair title.
+ * @private
+ */
+ _renderCrosshairTitle() {
+ const { values, titleFormat, style } = this.props;
+ const titleItem = titleFormat(values);
+ if (!titleItem) {
+ return null;
+ }
+ return (
+
+ {titleItem.title}
+ {': '}
+ {titleItem.value}
+
+ );
+ }
+
+ /**
+ * Render crosshair items (title + value for each series).
+ * @returns {*} Array of React classes with the crosshair values.
+ * @private
+ */
+ _renderCrosshairItems() {
+ const { values, itemsFormat } = this.props;
+ const items = itemsFormat(values);
+ if (!items) {
+ return null;
+ }
+ return items.filter(i => i).map(function renderValue(item, i) {
+ return (
+
+ {item.title}
+ {': '}
+ {item.value}
+
+ );
+ });
+ }
+
+ render() {
+ const {
+ children,
+ className,
+ values,
+ marginTop,
+ marginLeft,
+ innerWidth,
+ style } = this.props;
+ const value = getFirstNonEmptyValue(values);
+ if (!value) {
+ return null;
+ }
+ const y = ScaleUtils.getAttributeFunctor(this.props, 'y');
+ const innerTop = y(value);
+
+ const left = marginLeft;
+ const top = marginTop + innerTop;
+ const innerClassName = `rv-crosshair__inner rv-crosshair__inner--left`;
+ return (
+
+
+
+
+
+ {children ?
+ children :
+
+
+ {this._renderCrosshairTitle()}
+ {this._renderCrosshairItems()}
+
+
+ }
+
+
+ );
+ }
+}
+
+CrosshairY.displayName = 'CrosshairY';
diff --git a/src/components/xy_chart/index.js b/src/components/xy_chart/index.js
index 91ab93a07b38..6cdafcff6531 100644
--- a/src/components/xy_chart/index.js
+++ b/src/components/xy_chart/index.js
@@ -1,6 +1,7 @@
export { asSeries } from './as_series';
export { EuiXYChart } from './chart';
export { EuiLine } from './line';
+export { EuiBarSeries } from './bar_series';
export { EuiVerticalBarSeries } from './vertical_bar_series';
export { EuiHorizontalBarSeries } from './horizontal_bar_series';
export { EuiVerticalRectSeries } from './vertical_rect_series';
@@ -9,6 +10,8 @@ export { EuiDefaultAxis } from './axis/default_axis';
export { EuiXAxis } from './axis/x_axis';
export { EuiYAxis } from './axis/y_axis';
export { EuiArea } from './area';
+export { EuiXYChartUtils } from './utils/chart_utils';
export { EuiXYChartAxisUtils } from './utils/axis_utils';
export { EuiXYChartTextUtils } from './utils/text_utils';
-export { EuiCrosshairX } from './crosshair_x';
+export { EuiCrosshairX } from './crosshairs/crosshair_x';
+export { EuiCrosshairY } from './crosshairs/crosshair_y';
diff --git a/src/components/xy_chart/utils/chart_utils.js b/src/components/xy_chart/utils/chart_utils.js
new file mode 100644
index 000000000000..c867d5634f66
--- /dev/null
+++ b/src/components/xy_chart/utils/chart_utils.js
@@ -0,0 +1,9 @@
+const ORIENTATION = {
+ HORIZONTAL: 'horizontal',
+ VERTICAL: 'vertical',
+ BOTH: 'both',
+};
+
+export const EuiXYChartUtils = {
+ ORIENTATION,
+}
diff --git a/src/components/xy_chart/utils/series_utils.js b/src/components/xy_chart/utils/series_utils.js
index 44c65800ad2a..aacc1438bf8f 100644
--- a/src/components/xy_chart/utils/series_utils.js
+++ b/src/components/xy_chart/utils/series_utils.js
@@ -20,3 +20,14 @@ export function getSeriesChildren(children) {
return React.Children.toArray(children).filter(child =>
child && isSeriesChild(child));
}
+
+export function rotateDataSeries(data) {
+ return data.map(d => {
+ return {
+ x: d.y,
+ y: d.x,
+ x0: d.y0,
+ y0: d.x0,
+ }
+ })
+}
From 4f2b44f074a1b0388c3a0332eef2c95d0ffaae41 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Tue, 19 Jun 2018 12:58:14 +0200
Subject: [PATCH 20/68] Fix examples and updated the XYChart API
---
.../{examples.js => example-complex.js} | 4 --
.../src/views/xy_chart/example-crosshair.js | 14 +++---
.../src/views/xy_chart/xy_chart_example.js | 6 +--
.../xy_chart/__snapshots__/area.test.js.snap | 26 +++++------
.../xy_chart/__snapshots__/line.test.js.snap | 26 +++++------
src/components/xy_chart/chart.js | 41 ++++++++----------
.../xy_chart/crosshairs/crosshair_x.js | 43 ++++++++++++-------
7 files changed, 84 insertions(+), 76 deletions(-)
rename src-docs/src/views/xy_chart/{examples.js => example-complex.js} (89%)
diff --git a/src-docs/src/views/xy_chart/examples.js b/src-docs/src/views/xy_chart/example-complex.js
similarity index 89%
rename from src-docs/src/views/xy_chart/examples.js
rename to src-docs/src/views/xy_chart/example-complex.js
index 6782db326584..d8c275dd14d7 100644
--- a/src-docs/src/views/xy_chart/examples.js
+++ b/src-docs/src/views/xy_chart/example-complex.js
@@ -9,8 +9,6 @@ import {
} from '../../../../src/components';
export default () => {
- const yTicks = [[0, 'zero'], [1, 'one']];
- const xTicks = [[0, '0'], [5, '5'], [10, '10'], [15, '15'], [20, '20']];
const barData = [];
for (let i = 0; i < 10; i++) {
@@ -31,8 +29,6 @@ export default () => {
}}
width={600}
height={200}
- xTicks={xTicks}
- yTicks={yTicks}
>
{
- console.log('update crosshair x');
- this.setState({ crosshairX });
+ _updateCrosshairLocation = (crosshairValue) => {
+ this.setState({ crosshairValue });
}
render() {
return (
@@ -31,10 +31,10 @@ export class ExampleCrosshair extends React.Component {
/>
-
+
diff --git a/src-docs/src/views/xy_chart/xy_chart_example.js b/src-docs/src/views/xy_chart/xy_chart_example.js
index 7bc253275e7c..62adeb6216ed 100644
--- a/src-docs/src/views/xy_chart/xy_chart_example.js
+++ b/src-docs/src/views/xy_chart/xy_chart_example.js
@@ -1,7 +1,7 @@
import React from 'react';
import { GuideSectionTypes } from '../../components';
import { EuiCode } from '../../../../src/components';
-import ChartExampleCode from './examples';
+import ComplexChartExampleCode from './example-complex';
import EmptyExampleCode from './example-empty';
import MultiAxisChartExampleCode from './example_dual_axis';
import { ExampleCrosshair } from './example-crosshair';
@@ -23,7 +23,7 @@ export const XYChartExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./examples')
+ code: require('!!raw-loader!./example-complex')
},
{
type: GuideSectionTypes.HTML,
@@ -32,7 +32,7 @@ export const XYChartExample = {
],
demo: (
-
+
)
},
diff --git a/src/components/xy_chart/__snapshots__/area.test.js.snap b/src/components/xy_chart/__snapshots__/area.test.js.snap
index 0f38a7df5ae2..d878fcd1b85a 100644
--- a/src/components/xy_chart/__snapshots__/area.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/area.test.js.snap
@@ -731,7 +731,6 @@ exports[`EuiArea all props are rendered 1`] = `
_opacityValue={1}
angleDomain={Array []}
animation={true}
- className=""
clusters={
Set {
undefined,
@@ -789,7 +788,6 @@ exports[`EuiArea all props are rendered 1`] = `
10,
]
}
- stack={false}
strokeDomain={Array []}
strokeRange={
Array [
@@ -797,7 +795,6 @@ exports[`EuiArea all props are rendered 1`] = `
"#FF9833",
]
}
- style={Object {}}
xDomain={
Array [
0,
@@ -849,7 +846,6 @@ exports[`EuiArea all props are rendered 1`] = `
_opacityValue={1}
angleDomain={Array []}
animation={true}
- className=""
clusters={
Set {
undefined,
@@ -907,7 +903,6 @@ exports[`EuiArea all props are rendered 1`] = `
10,
]
}
- stack={false}
strokeDomain={Array []}
strokeRange={
Array [
@@ -915,7 +910,13 @@ exports[`EuiArea all props are rendered 1`] = `
"#FF9833",
]
}
- style={Object {}}
+ style={
+ Object {
+ "line": Object {
+ "background": "rgb(218, 218, 218)",
+ },
+ }
+ }
titleFormat={[Function]}
values={Array []}
xDomain={
@@ -1677,7 +1678,6 @@ exports[`EuiArea is rendered 1`] = `
_opacityValue={1}
angleDomain={Array []}
animation={true}
- className=""
clusters={
Set {
undefined,
@@ -1735,7 +1735,6 @@ exports[`EuiArea is rendered 1`] = `
10,
]
}
- stack={false}
strokeDomain={Array []}
strokeRange={
Array [
@@ -1743,7 +1742,6 @@ exports[`EuiArea is rendered 1`] = `
"#FF9833",
]
}
- style={Object {}}
xDomain={
Array [
0,
@@ -1795,7 +1793,6 @@ exports[`EuiArea is rendered 1`] = `
_opacityValue={1}
angleDomain={Array []}
animation={true}
- className=""
clusters={
Set {
undefined,
@@ -1853,7 +1850,6 @@ exports[`EuiArea is rendered 1`] = `
10,
]
}
- stack={false}
strokeDomain={Array []}
strokeRange={
Array [
@@ -1861,7 +1857,13 @@ exports[`EuiArea is rendered 1`] = `
"#FF9833",
]
}
- style={Object {}}
+ style={
+ Object {
+ "line": Object {
+ "background": "rgb(218, 218, 218)",
+ },
+ }
+ }
titleFormat={[Function]}
values={Array []}
xDomain={
diff --git a/src/components/xy_chart/__snapshots__/line.test.js.snap b/src/components/xy_chart/__snapshots__/line.test.js.snap
index 56e9e33d78c2..68cf86073b33 100644
--- a/src/components/xy_chart/__snapshots__/line.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/line.test.js.snap
@@ -1737,7 +1737,6 @@ exports[`EuiLine all props are rendered 1`] = `
_opacityValue={1}
angleDomain={Array []}
animation={true}
- className=""
clusters={
Set {
undefined,
@@ -1795,7 +1794,6 @@ exports[`EuiLine all props are rendered 1`] = `
10,
]
}
- stack={false}
strokeDomain={Array []}
strokeRange={
Array [
@@ -1803,7 +1801,6 @@ exports[`EuiLine all props are rendered 1`] = `
"#FF9833",
]
}
- style={Object {}}
xDomain={
Array [
0,
@@ -1855,7 +1852,6 @@ exports[`EuiLine all props are rendered 1`] = `
_opacityValue={1}
angleDomain={Array []}
animation={true}
- className=""
clusters={
Set {
undefined,
@@ -1913,7 +1909,6 @@ exports[`EuiLine all props are rendered 1`] = `
10,
]
}
- stack={false}
strokeDomain={Array []}
strokeRange={
Array [
@@ -1921,7 +1916,13 @@ exports[`EuiLine all props are rendered 1`] = `
"#FF9833",
]
}
- style={Object {}}
+ style={
+ Object {
+ "line": Object {
+ "background": "rgb(218, 218, 218)",
+ },
+ }
+ }
titleFormat={[Function]}
values={Array []}
xDomain={
@@ -3690,7 +3691,6 @@ exports[`EuiLine is rendered 1`] = `
_opacityValue={1}
angleDomain={Array []}
animation={true}
- className=""
clusters={
Set {
undefined,
@@ -3748,7 +3748,6 @@ exports[`EuiLine is rendered 1`] = `
10,
]
}
- stack={false}
strokeDomain={Array []}
strokeRange={
Array [
@@ -3756,7 +3755,6 @@ exports[`EuiLine is rendered 1`] = `
"#FF9833",
]
}
- style={Object {}}
xDomain={
Array [
0,
@@ -3808,7 +3806,6 @@ exports[`EuiLine is rendered 1`] = `
_opacityValue={1}
angleDomain={Array []}
animation={true}
- className=""
clusters={
Set {
undefined,
@@ -3866,7 +3863,6 @@ exports[`EuiLine is rendered 1`] = `
10,
]
}
- stack={false}
strokeDomain={Array []}
strokeRange={
Array [
@@ -3874,7 +3870,13 @@ exports[`EuiLine is rendered 1`] = `
"#FF9833",
]
}
- style={Object {}}
+ style={
+ Object {
+ "line": Object {
+ "background": "rgb(218, 218, 218)",
+ },
+ }
+ }
titleFormat={[Function]}
values={Array []}
xDomain={
diff --git a/src/components/xy_chart/chart.js b/src/components/xy_chart/chart.js
index 024cf6d69422..8fc726b7c3ae 100644
--- a/src/components/xy_chart/chart.js
+++ b/src/components/xy_chart/chart.js
@@ -61,9 +61,9 @@ class XYChart extends PureComponent {
return React.cloneElement(child, props);
}
// canShowCrosshair = () => {
- // const { crosshairValues, showCrosshair } = this.props;
+ // const { crosshairValue, showCrosshair } = this.props;
// const { mouseOver } = this.state;
- // return showCrosshair && ( mouseOver || crosshairValues !== undefined)
+ // return showCrosshair && ( mouseOver || crosshairValue !== undefined)
// }
render() {
@@ -83,7 +83,7 @@ class XYChart extends PureComponent {
animation, // eslint-disable-line no-unused-vars
showCrosshair,
crosshairOrientation,
- crosshairValues,
+ crosshairValue,
onCrosshairUpdate, // eslint-disable-line no-unused-vars
truncateLegends, // eslint-disable-line no-unused-vars
...rest
@@ -122,7 +122,7 @@ class XYChart extends PureComponent {
{ showCrosshair && (
)}
@@ -140,35 +140,32 @@ XYChart.propTypes = {
stackBy: PropTypes.string,
xType: PropTypes.string,
yType: PropTypes.string,
+ xDomain: PropTypes.array,
+ yDomain: PropTypes.array,
+ xPadding: PropTypes.number,
+ yPadding: PropTypes.number,
onHover: PropTypes.func,
- onMouseLeave: PropTypes.func,
onSelectEnd: PropTypes.func,
- hoverIndex: PropTypes.number,
- xTicks: PropTypes.array,
- yTicks: PropTypes.array, // [[0, "zero"], [1.2, "one mark"], [2.4, "two marks"]]
truncateLegends: PropTypes.bool,
- // showAxis: PropTypes.bool,
- xAxisLocation: PropTypes.string,
- yAxisLocation: PropTypes.string,
- showCrosshair: PropTypes.bool,
errorText: PropTypes.string,
- crosshairValues: PropTypes.number,
+ showCrosshair: PropTypes.bool,
+ crosshairOrientation: PropTypes.string,
+ crosshairValue: PropTypes.oneOfType([
+ PropTypes.string,
+ PropTypes.number
+ ]),
onCrosshairUpdate: PropTypes.func,
- xDomain: PropTypes.array,
- yDomain: PropTypes.array,
- xPadding: PropTypes.number,
- yPadding: PropTypes.number,
};
XYChart.defaultProps = {
+ xType: 'linear',
+ yType: 'linear',
+ yPadding: 0,
+ xPadding: 0,
truncateLegends: false,
- // showAxis: true,
showCrosshair: true,
crosshairOrientation: EuiXYChartUtils.ORIENTATION.VERTICAL,
- yPadding: 0,
- xPadding: 0,
- xType: 'linear',
- yType: 'linear',
+
};
export const EuiXYChart = makeWidthFlexible(XYChart);
diff --git a/src/components/xy_chart/crosshairs/crosshair_x.js b/src/components/xy_chart/crosshairs/crosshair_x.js
index 9780fa102f8d..839bed5a7022 100644
--- a/src/components/xy_chart/crosshairs/crosshair_x.js
+++ b/src/components/xy_chart/crosshairs/crosshair_x.js
@@ -1,4 +1,5 @@
import React from 'react';
+import PropTypes from 'prop-types';
import { AbstractSeries, Crosshair } from 'react-vis';
/**
@@ -6,7 +7,7 @@ import { AbstractSeries, Crosshair } from 'react-vis';
*/
export class EuiCrosshairX extends AbstractSeries {
state = {
- crosshairValues: [],
+ values: [],
}
static get requiresSVG() {
@@ -18,11 +19,11 @@ export class EuiCrosshairX extends AbstractSeries {
}
static getDerivedStateFromProps(props) {
- const { crosshairX, _allData } = props;
+ const { crosshairValue, _allData } = props;
- if (crosshairX !== undefined) {
+ if (crosshairValue !== undefined) {
return {
- crosshairValues: EuiCrosshairX._computeDataFromXValue(_allData, crosshairX),
+ values: EuiCrosshairX._computeDataFromXValue(_allData, crosshairValue),
};
}
return null;
@@ -31,10 +32,10 @@ export class EuiCrosshairX extends AbstractSeries {
static _computeDataFromXValue(dataSeries, crosshairX) {
const filteredAndFlattenDataByX = dataSeries
.filter(series => series) // get only cleaned data series
- .map(series => {
+ .map((series, seriesIndex) => {
return series
.filter(dataPoint => dataPoint.x === crosshairX)
- .map(dataPoint => ({ ...dataPoint, originalValues: { ...dataPoint } }));
+ .map(dataPoint => ({ ...dataPoint, originalValues: { ...dataPoint }, seriesIndex }));
})
.reduce((acc, val) => acc.concat(val), []);
return filteredAndFlattenDataByX;
@@ -49,7 +50,7 @@ export class EuiCrosshairX extends AbstractSeries {
this.props.onCrosshairUpdate(null);
}
this.setState({
- crosshairValues: []
+ values: []
})
}
@@ -68,9 +69,9 @@ export class EuiCrosshairX extends AbstractSeries {
}
_itemsFormat = (dataPoints) => {
- return dataPoints.map((d, i) => {
+ return dataPoints.map(d => {
return {
- title: `series ${i}`, // TODO specify series title or default one
+ title: `series ${d.seriesIndex}`, // TODO specify series title or default one
value: d.y,
};
});
@@ -98,7 +99,7 @@ export class EuiCrosshairX extends AbstractSeries {
let globalMinDistance = Number.POSITIVE_INFINITY;
const nearestXData = dataSeries
- .map(data => {
+ .map((data, seriesIndex) => {
let minDistance = Number.POSITIVE_INFINITY;
let value = null;
data.forEach((item) => {
@@ -128,12 +129,13 @@ export class EuiCrosshairX extends AbstractSeries {
return {
minDistance,
value,
+ seriesIndex,
};
})
.filter(d => d);
// filter and map nearest X data per dataseries to get only the nearet onces
- const crosshairValues = nearestXData
+ const values = nearestXData
.filter(value => value.minDistance === globalMinDistance)
.map(value => {
// check if we are on histograms and we need to show the right x and y values
@@ -144,23 +146,23 @@ export class EuiCrosshairX extends AbstractSeries {
const y = typeof d.y0 === 'number'
? (d.y - d.y0)
: d.y;
- return { x, y, originalValues: d };
+ return { x, y, originalValues: d, seriesIndex: value.seriesIndex };
});
if (this.props.onCrosshairUpdate) {
- this.props.onCrosshairUpdate(crosshairValues[0].x);
+ this.props.onCrosshairUpdate(values[0].x);
}
this.setState({
- crosshairValues,
+ values,
});
}
render() {
- const { crosshairValues } = this.state
+ const { values } = this.state
return (
Date: Tue, 19 Jun 2018 13:00:54 +0200
Subject: [PATCH 21/68] Removed console.log
---
src/components/xy_chart/chart.js | 1 -
1 file changed, 1 deletion(-)
diff --git a/src/components/xy_chart/chart.js b/src/components/xy_chart/chart.js
index 8fc726b7c3ae..5124ffd46ba0 100644
--- a/src/components/xy_chart/chart.js
+++ b/src/components/xy_chart/chart.js
@@ -18,7 +18,6 @@ class XYExtendedPlot extends XYPlot {
*/
_mouseLeaveHandler(event) {
const { onMouseLeave, children } = this.props;
- console.log('parent mouse leaving')
if (onMouseLeave) {
super.onMouseLeave(event);
}
From eb0cf2461c43ff1e755350ee78fca5a67dfd10c1 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Tue, 19 Jun 2018 14:15:17 +0200
Subject: [PATCH 22/68] Add showDefaultAxis prop on XYChart. Formatted examples
---
.../src/views/xy_chart/example-auto-axis.js | 18 +-
.../src/views/xy_chart/example-complex.js | 2 -
.../src/views/xy_chart/example-crosshair.js | 15 +-
src-docs/src/views/xy_chart/example-empty.js | 7 +-
.../src/views/xy_chart/example_dual_axis.js | 1 +
.../src/views/xy_chart/xy_chart_example.js | 50 +-
src-docs/src/views/xy_chart_area/area.js | 21 +-
.../src/views/xy_chart_area/area_example.js | 44 +-
.../src/views/xy_chart_area/curved_area.js | 50 +-
.../src/views/xy_chart_area/stacked_area.js | 25 +-
.../src/views/xy_chart_axis/simple_axis.js | 2 +-
.../views/xy_chart_axis/xy_axis_example.js | 16 +-
.../src/views/xy_chart_bar/bar_example.js | 73 +-
.../xy_chart_bar/horizontal_bar_series.js | 10 +-
.../views/xy_chart_bar/rotate_bar_series.js | 44 +-
.../stacked_horizontal_bar_series.js | 29 +-
.../stacked_vertical_bar_series.js | 54 +-
.../views/xy_chart_bar/vertical_bar_series.js | 20 +-
.../xy_chart_histogram/histogram_example.js | 68 +-
.../horizontal_rect_series.js | 14 +-
.../stacked_horizontal_rect_series.js | 24 +-
.../stacked_vertical_rect_series.js | 23 +-
.../vertical_rect_series.js | 19 +-
.../src/views/xy_chart_line/curved_line.js | 35 +-
.../views/xy_chart_line/custom_domain_line.js | 28 +-
.../views/xy_chart_line/custom_style_line.js | 48 +-
src-docs/src/views/xy_chart_line/line.js | 14 +-
.../src/views/xy_chart_line/line_example.js | 80 +-
.../src/views/xy_chart_line/multi_line.js | 35 +-
.../xy_chart/__snapshots__/area.test.js.snap | 6550 ++++++++++++--
.../xy_chart/__snapshots__/chart.test.js.snap | 3 +-
.../horizontal_bar_series.test.js.snap | 1017 +++
.../horizontal_rect_series.test.js.snap | 1101 +++
.../xy_chart/__snapshots__/line.test.js.snap | 7608 ++++++++++++++---
.../vertical_bar_series.test.js.snap | 1173 +++
.../vertical_rect_series.test.js.snap | 1213 +++
src/components/xy_chart/axis/default_axis.js | 15 +-
src/components/xy_chart/chart.js | 16 +-
src/components/xy_chart/utils/text_utils.js | 4 +-
39 files changed, 17210 insertions(+), 2359 deletions(-)
diff --git a/src-docs/src/views/xy_chart/example-auto-axis.js b/src-docs/src/views/xy_chart/example-auto-axis.js
index 57454e04c430..e0568c4f7db1 100644
--- a/src-docs/src/views/xy_chart/example-auto-axis.js
+++ b/src-docs/src/views/xy_chart/example-auto-axis.js
@@ -1,17 +1,13 @@
import React from 'react';
-import {
- EuiXYChart,
- EuiVerticalBarSeries,
- EuiDefaultAxis,
-} from '../../../../src/components';
+import { EuiXYChart, EuiVerticalBarSeries } from '../../../../src/components';
export default () => (
-
-
-
+
+
);
diff --git a/src-docs/src/views/xy_chart/example-complex.js b/src-docs/src/views/xy_chart/example-complex.js
index d8c275dd14d7..a2cc88f04ca0 100644
--- a/src-docs/src/views/xy_chart/example-complex.js
+++ b/src-docs/src/views/xy_chart/example-complex.js
@@ -5,7 +5,6 @@ import {
EuiVerticalBarSeries,
EuiArea,
EuiLine,
- EuiDefaultAxis,
} from '../../../../src/components';
export default () => {
@@ -60,7 +59,6 @@ export default () => {
data={[{ x: 0, y: 0 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: 1 }, { x: 5, y: 2 }]}
color={'#db1374'}
/>
-
);
};
diff --git a/src-docs/src/views/xy_chart/example-crosshair.js b/src-docs/src/views/xy_chart/example-crosshair.js
index ac5b51d49e67..a55605d8682d 100644
--- a/src-docs/src/views/xy_chart/example-crosshair.js
+++ b/src-docs/src/views/xy_chart/example-crosshair.js
@@ -1,20 +1,15 @@
import React from 'react';
-import {
- EuiSpacer,
- EuiXYChart,
- EuiVerticalBarSeries,
- EuiDefaultAxis,
-} from '../../../../src/components';
+import { EuiSpacer, EuiXYChart, EuiVerticalBarSeries } from '../../../../src/components';
// eslint-disable-next-line
export class ExampleCrosshair extends React.Component {
state = {
crosshairValue: 2,
- }
- _updateCrosshairLocation = (crosshairValue) => {
+ };
+ _updateCrosshairLocation = crosshairValue => {
this.setState({ crosshairValue });
- }
+ };
render() {
return (
@@ -29,7 +24,6 @@ export class ExampleCrosshair extends React.Component {
data={[{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: 1 }, { x: 5, y: 2 }]}
color={'#db1374'}
/>
-
-
);
diff --git a/src-docs/src/views/xy_chart/example-empty.js b/src-docs/src/views/xy_chart/example-empty.js
index d27394be5936..b3258caed09f 100644
--- a/src-docs/src/views/xy_chart/example-empty.js
+++ b/src-docs/src/views/xy_chart/example-empty.js
@@ -2,9 +2,4 @@ import React from 'react';
import { EuiXYChart } from '../../../../src/components';
-export default () => (
-
-);
+export default () => ;
diff --git a/src-docs/src/views/xy_chart/example_dual_axis.js b/src-docs/src/views/xy_chart/example_dual_axis.js
index b86e8a0db08f..f9191e2e5102 100644
--- a/src-docs/src/views/xy_chart/example_dual_axis.js
+++ b/src-docs/src/views/xy_chart/example_dual_axis.js
@@ -25,6 +25,7 @@ export default () => (
height={200}
xPadding={5}
xType="ordinal"
+ showDefaultAxis={false}
>
- Use EuiXYChart to display line, bar, area, and stream charts. Note that charts are composed with{' '}
- EuiLine , EuiArea , EuiBar , and EuiStream being child
- components.
+ Use EuiXYChart to display line, bar, area, and stream charts. Note
+ that charts are composed with EuiLine , EuiArea ,{' '}
+ EuiBar , and EuiStream being child components.
),
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./example-complex')
+ code: require('!!raw-loader!./example-complex'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
{
title: 'Empty Chart',
text: (
-
- When no data is provided to EuiXYChart, an empty state is displayed
-
+
When no data is provided to EuiXYChart, an empty state is displayed
),
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./example-empty')
+ code: require('!!raw-loader!./example-empty'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
{
title: 'Keep cross-hair in sync',
@@ -73,43 +71,41 @@ export const XYChartExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./example-empty')
+ code: require('!!raw-loader!./example-empty'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
{
title: 'Multi Axis',
text: (
-
- If just displaying values is enough, then you can let the chart auto label axis
-
+
If just displaying values is enough, then you can let the chart auto label axis
),
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./example_dual_axis')
+ code: require('!!raw-loader!./example_dual_axis'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
- }
- ]
+ ),
+ },
+ ],
};
diff --git a/src-docs/src/views/xy_chart_area/area.js b/src-docs/src/views/xy_chart_area/area.js
index e551d93b8157..de5b750bb838 100644
--- a/src-docs/src/views/xy_chart_area/area.js
+++ b/src-docs/src/views/xy_chart_area/area.js
@@ -1,24 +1,11 @@
import React from 'react';
-import { EuiXYChart, EuiArea, EuiDefaultAxis } from '../../../../src/components';
+import { EuiXYChart, EuiArea } from '../../../../src/components';
-const DATA_A = [
- { x: 0, y: 1 },
- { x: 1, y: 1 },
- { x: 2, y: 2 },
- { x: 3, y: 1 },
- { x: 5, y: 2 },
-];
+const DATA_A = [{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: 1 }, { x: 5, y: 2 }];
export default () => (
-
-
-
+
+
);
diff --git a/src-docs/src/views/xy_chart_area/area_example.js b/src-docs/src/views/xy_chart_area/area_example.js
index e640416a5b42..1bde2257b721 100644
--- a/src-docs/src/views/xy_chart_area/area_example.js
+++ b/src-docs/src/views/xy_chart_area/area_example.js
@@ -4,11 +4,7 @@ import AreaSeriesExample from './area';
import StackedAreaSeriesExample from './stacked_area';
import CurvedAreaExample from './curved_area';
-import {
- EuiCode,
- EuiArea,
- EuiLink,
-} from '../../../../src/components';
+import { EuiCode, EuiArea, EuiLink } from '../../../../src/components';
export const XYChartAreaExample = {
title: 'Area chart',
@@ -26,26 +22,26 @@ export const XYChartAreaExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./area')
+ code: require('!!raw-loader!./area'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
{
title: 'Stacked Area Series',
text: (
- Use multiple EuiArea to display stacked area charts
- specifying the stackBy:y prop on the EuiXYChart
+ Use multiple EuiArea to display stacked area charts specifying the{' '}
+ stackBy:y prop on the EuiXYChart
to enable stacking.
@@ -54,26 +50,28 @@ export const XYChartAreaExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./stacked_area')
+ code: require('!!raw-loader!./stacked_area'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
{
title: 'Curved Area Series',
text: (
- Use the curve prop to change the curve representation.
- Visit d3-shape#curves
+ Use the curve prop to change the curve representation. Visit{' '}
+
+ d3-shape#curves
+
for available values (the bundle curve does not work with area chart).
@@ -82,18 +80,18 @@ export const XYChartAreaExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./curved_area')
+ code: require('!!raw-loader!./curved_area'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
- }
- ]
+ ),
+ },
+ ],
};
diff --git a/src-docs/src/views/xy_chart_area/curved_area.js b/src-docs/src/views/xy_chart_area/curved_area.js
index 7cdc14676ef0..6e23cc1576b1 100644
--- a/src-docs/src/views/xy_chart_area/curved_area.js
+++ b/src-docs/src/views/xy_chart_area/curved_area.js
@@ -7,22 +7,10 @@ import {
EuiSpacer,
EuiXYChart,
EuiArea,
- EuiDefaultAxis } from '../../../../src/components';
+} from '../../../../src/components';
-const DATA_A = [
- { x: 0, y: 1 },
- { x: 1, y: 1 },
- { x: 2, y: 2 },
- { x: 3, y: -1 },
- { x: 5, y: 2 },
-];
-const DATA_B = [
- { x: 0, y: 3 },
- { x: 1, y: 2 },
- { x: 2, y: 4 },
- { x: 3, y: 1 },
- { x: 5, y: 3 },
-];
+const DATA_A = [{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: -1 }, { x: 5, y: 2 }];
+const DATA_B = [{ x: 0, y: 3 }, { x: 1, y: 2 }, { x: 2, y: 4 }, { x: 3, y: 1 }, { x: 5, y: 3 }];
export default class extends Component {
constructor(props) {
@@ -56,38 +44,18 @@ export default class extends Component {
return (
-
-
+
+
-
-
-
-
-
+
+
+
- )
+ );
}
}
diff --git a/src-docs/src/views/xy_chart_area/stacked_area.js b/src-docs/src/views/xy_chart_area/stacked_area.js
index 89d1ff17777a..e2f1a6137c85 100644
--- a/src-docs/src/views/xy_chart_area/stacked_area.js
+++ b/src-docs/src/views/xy_chart_area/stacked_area.js
@@ -1,31 +1,14 @@
import React from 'react';
-import { EuiXYChart, EuiArea, EuiDefaultAxis } from '../../../../src/components';
+import { EuiXYChart, EuiArea } from '../../../../src/components';
-const dataA = [
- { x: 0, y: 3, },
- { x: 1, y: 2, },
- { x: 2, y: 1, },
- { x: 3, y: 2, },
- { x: 4, y: 3, },
-];
+const dataA = [{ x: 0, y: 3 }, { x: 1, y: 2 }, { x: 2, y: 1 }, { x: 3, y: 2 }, { x: 4, y: 3 }];
-const dataB = [
- { x: 0, y: 1 },
- { x: 1, y: 1 },
- { x: 2, y: 4 },
- { x: 3, y: 1 },
- { x: 4, y: 1 },
-];
+const dataB = [{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 4 }, { x: 3, y: 1 }, { x: 4, y: 1 }];
export default () => (
-
+
-
);
diff --git a/src-docs/src/views/xy_chart_axis/simple_axis.js b/src-docs/src/views/xy_chart_axis/simple_axis.js
index ab9613ce0375..5858b2f1d678 100644
--- a/src-docs/src/views/xy_chart_axis/simple_axis.js
+++ b/src-docs/src/views/xy_chart_axis/simple_axis.js
@@ -16,7 +16,7 @@ function xAxisTickFormatter(value) {
}
export default () => (
-
+
- EuiYAxis and EuiXAxis can be used
- instead of the EuiDefaultAxis to allow higher
- axis customization. See the JS example to check the available properties.
+ EuiYAxis and EuiXAxis can be used instead of the{' '}
+ EuiDefaultAxis to allow higher axis customization. See the JS example
+ to check the available properties.
),
@@ -21,18 +21,18 @@ export const XYChartAxisExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./simple_axis')
+ code: require('!!raw-loader!./simple_axis'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
- ]
+ ],
};
diff --git a/src-docs/src/views/xy_chart_bar/bar_example.js b/src-docs/src/views/xy_chart_bar/bar_example.js
index 57e03563c162..9116a9a8c37f 100644
--- a/src-docs/src/views/xy_chart_bar/bar_example.js
+++ b/src-docs/src/views/xy_chart_bar/bar_example.js
@@ -5,11 +5,7 @@ import HorizontalBarSeriesExample from './horizontal_bar_series';
import StackedVerticalBarSeriesExample from './stacked_vertical_bar_series';
import StackedHorizontalBarSeriesExample from './stacked_horizontal_bar_series';
-import {
- EuiCode,
- EuiVerticalBarSeries,
- EuiHorizontalBarSeries,
-} from '../../../../src/components';
+import { EuiCode, EuiVerticalBarSeries, EuiHorizontalBarSeries } from '../../../../src/components';
export const XYChartBarExample = {
title: 'Bar chart',
@@ -19,8 +15,8 @@ export const XYChartBarExample = {
text: (
- Use EuiXYChart with EuiVerticalBarSeries for displaying
- vertical bar charts.
+ Use EuiXYChart with EuiVerticalBarSeries for
+ displaying vertical bar charts.
Specify EuiXYChart prop xType="ordinal"
@@ -36,35 +32,36 @@ export const XYChartBarExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./vertical_bar_series')
+ code: require('!!raw-loader!./vertical_bar_series'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
{
title: 'Stacked Vertical Bar Chart',
text: (
- Use EuiXYChart with EuiVerticalBarSeries for displaying
- vertical stacked bar charts.
- Specify EuiXYChart props like the following:
+ Use EuiXYChart with EuiVerticalBarSeries for
+ displaying vertical stacked bar charts. Specify EuiXYChart props like
+ the following:
xType="ordinal" because we are creating a Bar Chart
- stackBy="y" to stack bars one above the other.
- If stackBy is not specified, bars are clustered together depending on the X value
+ stackBy="y" to stack bars one above the other. If{' '}
+ stackBy is not specified, bars are clustered together depending on
+ the X value
@@ -73,32 +70,33 @@ export const XYChartBarExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./stacked_vertical_bar_series')
+ code: require('!!raw-loader!./stacked_vertical_bar_series'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
{
title: 'Horizontal Bar Chart',
text: (
- Use EuiXYChart with EuiHorizontalBarSeries for displaying
- horizontal bar charts.
+ Use EuiXYChart with EuiHorizontalBarSeries for
+ displaying horizontal bar charts.
Specify EuiXYChart prop yType="ordinal"
because we are creating a Bar Chart.
-
The X-Axis can be configured with linear ,log ,
+
+ The X-Axis can be configured with linear ,log ,
time , time-utc .
@@ -107,35 +105,36 @@ export const XYChartBarExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./horizontal_bar_series')
+ code: require('!!raw-loader!./horizontal_bar_series'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
{
title: 'Stacked Horizontal Bar Chart',
text: (
- Use EuiXYChart with EuiHorizontalBarSeries for displaying
- horizontal stacked bar charts.
- Specify EuiXYChart props like the following:
+ Use EuiXYChart with EuiHorizontalBarSeries for
+ displaying horizontal stacked bar charts. Specify EuiXYChart props
+ like the following:
yType="ordinal" because we are creating a Bar Chart
- stackBy="x" to stack bars one above the other.
- If stackBy is not specified, bars are clustered together depending on the Y value
+ stackBy="x" to stack bars one above the other. If{' '}
+ stackBy is not specified, bars are clustered together depending on
+ the Y value
@@ -144,18 +143,18 @@ export const XYChartBarExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./stacked_horizontal_bar_series')
+ code: require('!!raw-loader!./stacked_horizontal_bar_series'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
- ]
+ ],
};
diff --git a/src-docs/src/views/xy_chart_bar/horizontal_bar_series.js b/src-docs/src/views/xy_chart_bar/horizontal_bar_series.js
index ef24556e7234..31256c30c0a9 100644
--- a/src-docs/src/views/xy_chart_bar/horizontal_bar_series.js
+++ b/src-docs/src/views/xy_chart_bar/horizontal_bar_series.js
@@ -1,11 +1,6 @@
import React from 'react';
-import {
- EuiXYChart,
- EuiHorizontalBarSeries,
- EuiDefaultAxis,
- EuiXYChartUtils,
-} from '../../../../src/components';
+import { EuiXYChart, EuiHorizontalBarSeries, EuiXYChartUtils } from '../../../../src/components';
const data = [
{ x: 3, y: 'A' },
@@ -19,9 +14,8 @@ export default () => (
width={600}
height={200}
yType="ordinal"
- crosshairOrientation={EuiXYChartUtils.ORIENTATION.HORIZONTAL}
+ orientation={EuiXYChartUtils.ORIENTATION.HORIZONTAL}
>
-
);
diff --git a/src-docs/src/views/xy_chart_bar/rotate_bar_series.js b/src-docs/src/views/xy_chart_bar/rotate_bar_series.js
index 2aa6416d59e8..5c20e9e8e1c7 100644
--- a/src-docs/src/views/xy_chart_bar/rotate_bar_series.js
+++ b/src-docs/src/views/xy_chart_bar/rotate_bar_series.js
@@ -1,27 +1,6 @@
import React, { Component } from 'react';
-import {
- EuiSwitch,
- EuiXYChart,
- EuiBarSeries,
- EuiSpacer,
- EuiDefaultAxis,
-} from '../../../../src/components';
-
-const horizontalData = [
- { x: 3, y: 'A' },
- { x: 1, y: 'B' },
- { x: 5, y: 'C' },
- { x: 2, y: 'D' },
- { x: 1, y: 'E' }
-]
-const verticalData = [
- { x: 'A', y: 3 },
- { x: 'B', y: 1 },
- { x: 'C', y: 5 },
- { x: 'D', y: 2 },
- { x: 'E', y: 1 },
-]
+import { EuiSwitch, EuiXYChart, EuiSpacer } from '../../../../src/components';
export default class extends Component {
constructor(props) {
@@ -39,33 +18,28 @@ export default class extends Component {
};
render() {
- const { isHorizontal } = this.state
+ const { isHorizontal } = this.state;
return (
-
+
-
-
+
+ /> */}
-
- )
+ );
}
}
diff --git a/src-docs/src/views/xy_chart_bar/stacked_horizontal_bar_series.js b/src-docs/src/views/xy_chart_bar/stacked_horizontal_bar_series.js
index bd24a0fe3025..25e70c4fbb72 100644
--- a/src-docs/src/views/xy_chart_bar/stacked_horizontal_bar_series.js
+++ b/src-docs/src/views/xy_chart_bar/stacked_horizontal_bar_series.js
@@ -4,7 +4,6 @@ import {
EuiButton,
EuiXYChart,
EuiHorizontalBarSeries,
- EuiDefaultAxis,
EuiXYChartUtils,
} from '../../../../src/components';
@@ -36,40 +35,26 @@ export default class extends Component {
this.setState({
stacked: !this.state.stacked,
});
- }
+ };
render() {
- const { stacked } = this.state
+ const { stacked } = this.state;
return (
-
+
Toggle stacked
-
-
-
+
+
-
- )
+ );
}
}
diff --git a/src-docs/src/views/xy_chart_bar/stacked_vertical_bar_series.js b/src-docs/src/views/xy_chart_bar/stacked_vertical_bar_series.js
index 9743d82c4fa9..7797fe2d8e6f 100644
--- a/src-docs/src/views/xy_chart_bar/stacked_vertical_bar_series.js
+++ b/src-docs/src/views/xy_chart_bar/stacked_vertical_bar_series.js
@@ -1,27 +1,10 @@
import React, { Component } from 'react';
-import {
- EuiButton,
- EuiXYChart,
- EuiVerticalBarSeries,
- EuiDefaultAxis,
-} from '../../../../src/components';
+import { EuiButton, EuiXYChart, EuiVerticalBarSeries } from '../../../../src/components';
-const dataA = [
- { x: 0, y: 5 },
- { x: 1, y: 4 },
- { x: 2, y: 3 },
- { x: 3, y: 2 },
- { x: 4, y: 1 },
-];
+const dataA = [{ x: 0, y: 5 }, { x: 1, y: 4 }, { x: 2, y: 3 }, { x: 3, y: 2 }, { x: 4, y: 1 }];
-const dataB = [
- { x: 0, y: 1 },
- { x: 1, y: 2 },
- { x: 2, y: 3 },
- { x: 3, y: 4 },
- { x: 4, y: 5 },
-];
+const dataB = [{ x: 0, y: 1 }, { x: 1, y: 2 }, { x: 2, y: 3 }, { x: 3, y: 4 }, { x: 4, y: 5 }];
export default class extends Component {
constructor(props) {
@@ -36,37 +19,20 @@ export default class extends Component {
this.setState({
stacked: !this.state.stacked,
});
- }
+ };
render() {
- const { stacked } = this.state
+ const { stacked } = this.state;
return (
-
+
Toggle stacked
-
-
-
-
+
+
+
-
- )
+ );
}
}
diff --git a/src-docs/src/views/xy_chart_bar/vertical_bar_series.js b/src-docs/src/views/xy_chart_bar/vertical_bar_series.js
index 6365ed608247..c45fe68c35d1 100644
--- a/src-docs/src/views/xy_chart_bar/vertical_bar_series.js
+++ b/src-docs/src/views/xy_chart_bar/vertical_bar_series.js
@@ -1,10 +1,6 @@
import React from 'react';
-import {
- EuiXYChart,
- EuiVerticalBarSeries,
- EuiDefaultAxis,
-} from '../../../../src/components';
+import { EuiXYChart, EuiVerticalBarSeries } from '../../../../src/components';
const data = [
{ x: 'A', y: 3 },
@@ -12,18 +8,10 @@ const data = [
{ x: 'C', y: 5 },
{ x: 'D', y: 2 },
{ x: 'E', y: 1 },
-]
+];
export default () => (
-
-
-
+
+
);
diff --git a/src-docs/src/views/xy_chart_histogram/histogram_example.js b/src-docs/src/views/xy_chart_histogram/histogram_example.js
index f50c52b47483..6c91717724b5 100644
--- a/src-docs/src/views/xy_chart_histogram/histogram_example.js
+++ b/src-docs/src/views/xy_chart_histogram/histogram_example.js
@@ -19,11 +19,10 @@ export const XYChartHistogramExample = {
text: (
- Use EuiXYChart with EuiVerticalRectSeries for displaying
- vertical histograms.
- The Y-Axis needs can be configured with linear ,log ,
- time , time-utc .
- The same for X-Axis.
+ Use EuiXYChart with EuiVerticalRectSeries for
+ displaying vertical histograms. The Y-Axis needs can be configured with{' '}
+ linear ,log ,
+ time , time-utc . The same for X-Axis.
),
@@ -31,28 +30,30 @@ export const XYChartHistogramExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./vertical_rect_series')
+ code: require('!!raw-loader!./vertical_rect_series'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
{
title: 'Stacked Vertical Histogram',
text: (
- Use EuiXYChart with EuiVerticalRectSeries for displaying
- stacked vedrtical histograms.
+ Use EuiXYChart with EuiVerticalRectSeries for
+ displaying stacked vedrtical histograms.
+
+
+ Specify stackBy="x" to stack bars together.
-
Specify stackBy="x" to stack bars together.
Note: Is not possible to "cluster" bars by the same X value.
),
@@ -60,29 +61,28 @@ export const XYChartHistogramExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./stacked_vertical_rect_series')
+ code: require('!!raw-loader!./stacked_vertical_rect_series'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
{
title: 'Horizontal Histogram',
text: (
- Use EuiXYChart with EuiHorizontalRectSeries for displaying
- horizontal histograms.
- The Y-Axis needs can be configured as linear ,log ,
- time , time-utc .
- The same for X-Axis.
+ Use EuiXYChart with EuiHorizontalRectSeries for
+ displaying horizontal histograms. The Y-Axis needs can be configured as{' '}
+ linear ,log ,
+ time , time-utc . The same for X-Axis.
),
@@ -90,28 +90,30 @@ export const XYChartHistogramExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./vertical_rect_series')
+ code: require('!!raw-loader!./vertical_rect_series'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
{
title: 'Stacked Horizontal Histogram',
text: (
- Use EuiXYChart with EuiHorizontalRectSeries to display
- stacked horizontal histograms.
+ Use EuiXYChart with EuiHorizontalRectSeries to
+ display stacked horizontal histograms.
+
+
+ Specify stackBy="x" to stack bars together.
-
Specify stackBy="x" to stack bars together.
Note: Is not possible to "cluster" bars by the same Y value.
),
@@ -119,18 +121,18 @@ export const XYChartHistogramExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./stacked_horizontal_rect_series')
+ code: require('!!raw-loader!./stacked_horizontal_rect_series'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
- ]
+ ],
};
diff --git a/src-docs/src/views/xy_chart_histogram/horizontal_rect_series.js b/src-docs/src/views/xy_chart_histogram/horizontal_rect_series.js
index 2ee5f7afac8a..fdf369a76813 100644
--- a/src-docs/src/views/xy_chart_histogram/horizontal_rect_series.js
+++ b/src-docs/src/views/xy_chart_histogram/horizontal_rect_series.js
@@ -1,11 +1,6 @@
import React from 'react';
-import {
- EuiXYChart,
- EuiHorizontalRectSeries,
- EuiDefaultAxis,
- EuiXYChartUtils,
-} from '../../../../src/components';
+import { EuiXYChart, EuiHorizontalRectSeries, EuiXYChartUtils } from '../../../../src/components';
const data = [
{ x: 3, y: 0, y0: 1 },
@@ -15,12 +10,7 @@ const data = [
{ x: 1, y: 4, y0: 5 },
];
export default () => (
-
+
-
);
diff --git a/src-docs/src/views/xy_chart_histogram/stacked_horizontal_rect_series.js b/src-docs/src/views/xy_chart_histogram/stacked_horizontal_rect_series.js
index 8f55bc4ae264..bfef45b59aac 100644
--- a/src-docs/src/views/xy_chart_histogram/stacked_horizontal_rect_series.js
+++ b/src-docs/src/views/xy_chart_histogram/stacked_horizontal_rect_series.js
@@ -1,11 +1,6 @@
import React from 'react';
-import {
- EuiXYChart,
- EuiHorizontalRectSeries,
- EuiDefaultAxis,
- EuiXYChartUtils,
-} from '../../../../src/components';
+import { EuiXYChart, EuiHorizontalRectSeries, EuiXYChartUtils } from '../../../../src/components';
const dataA = [
{ y: 0, y0: 1, x: 1 },
@@ -28,20 +23,9 @@ export default () => (
width={600}
height={200}
stackBy="x"
- crosshairOrientation={EuiXYChartUtils.ORIENTATION.HORIZONTAL}
+ orientation={EuiXYChartUtils.ORIENTATION.HORIZONTAL}
>
-
-
-
+
+
);
diff --git a/src-docs/src/views/xy_chart_histogram/stacked_vertical_rect_series.js b/src-docs/src/views/xy_chart_histogram/stacked_vertical_rect_series.js
index da9cd516a0a3..0a00b250dd62 100644
--- a/src-docs/src/views/xy_chart_histogram/stacked_vertical_rect_series.js
+++ b/src-docs/src/views/xy_chart_histogram/stacked_vertical_rect_series.js
@@ -1,10 +1,6 @@
import React from 'react';
-import {
- EuiXYChart,
- EuiVerticalRectSeries,
- EuiDefaultAxis,
-} from '../../../../src/components';
+import { EuiXYChart, EuiVerticalRectSeries } from '../../../../src/components';
const dataA = [
{ x0: 0, x: 1, y: 1 },
@@ -23,19 +19,8 @@ const dataB = [
];
export default () => (
-
-
-
-
+
+
+
);
diff --git a/src-docs/src/views/xy_chart_histogram/vertical_rect_series.js b/src-docs/src/views/xy_chart_histogram/vertical_rect_series.js
index 6c6772ce8fe6..96f04dbe95c3 100644
--- a/src-docs/src/views/xy_chart_histogram/vertical_rect_series.js
+++ b/src-docs/src/views/xy_chart_histogram/vertical_rect_series.js
@@ -1,10 +1,6 @@
import React from 'react';
-import {
- EuiXYChart,
- EuiVerticalRectSeries,
- EuiDefaultAxis,
-} from '../../../../src/components';
+import { EuiXYChart, EuiVerticalRectSeries } from '../../../../src/components';
const data = [
{ x0: 0, x: 1, y: 1 },
@@ -12,17 +8,10 @@ const data = [
{ x0: 2, x: 3, y: 2 },
{ x0: 3, x: 4, y: 0.5 },
{ x0: 4, x: 5, y: 5 },
-]
+];
export default () => (
-
-
-
+
+
);
diff --git a/src-docs/src/views/xy_chart_line/curved_line.js b/src-docs/src/views/xy_chart_line/curved_line.js
index 44aa6f25bad2..b69602a9e7e6 100644
--- a/src-docs/src/views/xy_chart_line/curved_line.js
+++ b/src-docs/src/views/xy_chart_line/curved_line.js
@@ -7,15 +7,9 @@ import {
EuiSpacer,
EuiXYChart,
EuiLine,
- EuiDefaultAxis } from '../../../../src/components';
+} from '../../../../src/components';
-const DATA_A = [
- { x: 0, y: 1 },
- { x: 1, y: 1 },
- { x: 2, y: 2 },
- { x: 3, y: -1 },
- { x: 5, y: 2 },
-];
+const DATA_A = [{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: -1 }, { x: 5, y: 2 }];
export default class extends Component {
constructor(props) {
@@ -50,32 +44,17 @@ export default class extends Component {
return (
-
-
+
+
-
-
-
-
+
+
- )
+ );
}
}
diff --git a/src-docs/src/views/xy_chart_line/custom_domain_line.js b/src-docs/src/views/xy_chart_line/custom_domain_line.js
index bf5bbfc84694..4aaf42f80aad 100644
--- a/src-docs/src/views/xy_chart_line/custom_domain_line.js
+++ b/src-docs/src/views/xy_chart_line/custom_domain_line.js
@@ -1,30 +1,14 @@
import React from 'react';
-import { EuiXYChart, EuiLine, EuiDefaultAxis } from '../../../../src/components';
+import { EuiXYChart, EuiLine } from '../../../../src/components';
-const X_DOMAIN = [ -1, 6 ];
-const Y_DOMAIN = [ 0, 3 ];
+const X_DOMAIN = [-1, 6];
+const Y_DOMAIN = [0, 3];
-const DATA_A = [
- { x: 0, y: 1 },
- { x: 1, y: 1 },
- { x: 2, y: 2 },
- { x: 3, y: 1 },
- { x: 5, y: 2 },
-];
+const DATA_A = [{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: 1 }, { x: 5, y: 2 }];
export default () => (
-
-
-
-
+
+
);
diff --git a/src-docs/src/views/xy_chart_line/custom_style_line.js b/src-docs/src/views/xy_chart_line/custom_style_line.js
index f6a97df3ae0a..ea8aeed8ec8e 100644
--- a/src-docs/src/views/xy_chart_line/custom_style_line.js
+++ b/src-docs/src/views/xy_chart_line/custom_style_line.js
@@ -7,20 +7,12 @@ import {
EuiSpacer,
EuiXYChart,
EuiLine,
- EuiDefaultAxis,
EuiCheckboxGroup,
} from '../../../../src/components';
import makeId from '../../../../src/components/form/form_row/make_id';
-
-const DATA_A = [
- { x: 0, y: 1 },
- { x: 1, y: 1 },
- { x: 2, y: 2 },
- { x: 3, y: -1 },
- { x: 5, y: 2 },
-];
+const DATA_A = [{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: -1 }, { x: 5, y: 2 }];
export default class extends Component {
constructor(props) {
@@ -44,12 +36,15 @@ export default class extends Component {
showLineMarks: true,
},
};
- };
+ }
onLinePropsChange = optionId => {
- const newLinePropsIdToSelectedMap = ({ ...this.state.linePropsIdToSelectedMap, ...{
- [optionId]: !this.state.linePropsIdToSelectedMap[optionId],
- } });
+ const newLinePropsIdToSelectedMap = {
+ ...this.state.linePropsIdToSelectedMap,
+ ...{
+ [optionId]: !this.state.linePropsIdToSelectedMap[optionId],
+ },
+ };
this.setState({
linePropsIdToSelectedMap: newLinePropsIdToSelectedMap,
@@ -69,13 +64,15 @@ export default class extends Component {
};
render() {
- const { linePropsIdToSelectedMap: { showLine, showLineMarks }, lineSize, lineMarkSize } = this.state
+ const {
+ linePropsIdToSelectedMap: { showLine, showLineMarks },
+ lineSize,
+ lineMarkSize,
+ } = this.state;
return (
-
+
-
+
-
+
-
-
+
-
- )
+ );
}
}
diff --git a/src-docs/src/views/xy_chart_line/line.js b/src-docs/src/views/xy_chart_line/line.js
index f0cbe67ac4f6..61a15ced087b 100644
--- a/src-docs/src/views/xy_chart_line/line.js
+++ b/src-docs/src/views/xy_chart_line/line.js
@@ -1,6 +1,6 @@
import React from 'react';
-import { EuiXYChart, EuiLine, EuiDefaultAxis } from '../../../../src/components';
+import { EuiXYChart, EuiLine } from '../../../../src/components';
const DATA_A = [
{ x: 0, y: 1 },
@@ -12,15 +12,7 @@ const DATA_A = [
];
export default () => (
-
-
-
-
+
+
);
diff --git a/src-docs/src/views/xy_chart_line/line_example.js b/src-docs/src/views/xy_chart_line/line_example.js
index e1ed683a57eb..349d05ef5733 100644
--- a/src-docs/src/views/xy_chart_line/line_example.js
+++ b/src-docs/src/views/xy_chart_line/line_example.js
@@ -5,11 +5,7 @@ import CustomDomainLineChartExample from './custom_domain_line';
import MultiLineChartExample from './multi_line';
import CurvedLineChartExample from './curved_line';
import CustomStyleLineChartExample from './custom_style_line';
-import {
- EuiCode,
- EuiLine,
- EuiLink,
-} from '../../../../src/components';
+import { EuiCode, EuiLine, EuiLink } from '../../../../src/components';
export const XYChartLineExample = {
title: 'Line chart',
@@ -19,8 +15,8 @@ export const XYChartLineExample = {
text: (
- Use EuiLine to display line charts. The chart domain
- will cover the whole extent and doesn't add any padding.
+ Use EuiLine to display line charts. The chart domain will cover the
+ whole extent and doesn't add any padding.
),
@@ -28,27 +24,27 @@ export const XYChartLineExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./line')
+ code: require('!!raw-loader!./line'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
{
title: 'Custom domain line chart',
text: (
- Use EuiLine to display line charts.
- Specify xDomain and/or yDomain
- props to use custom domains.
+ Use EuiLine to display line charts. Specify{' '}
+ xDomain and/or yDomain
+ props to use custom domains.
),
@@ -56,18 +52,18 @@ export const XYChartLineExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./custom_domain_line')
+ code: require('!!raw-loader!./custom_domain_line'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
{
title: 'Multi Line chart',
@@ -82,26 +78,28 @@ export const XYChartLineExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./multi_line')
+ code: require('!!raw-loader!./multi_line'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
{
title: 'Curved Line chart',
text: (
- Use the curve prop to change the curve representation.
- Visit d3-shape#curves
+ Use the curve prop to change the curve representation. Visit{' '}
+
+ d3-shape#curves
+
for all possible values.
@@ -110,18 +108,18 @@ export const XYChartLineExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./curved_line')
+ code: require('!!raw-loader!./curved_line'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
{
title: 'Custom style Line chart',
@@ -129,10 +127,18 @@ export const XYChartLineExample = {
Use the following props to change the style of the Line Chart
- lineSize to change the size/width of the line.
- lineMarkSize to change the size/radius of marks.
- showLine to show/hide the line.
- showLineMarks to show/hide the line marks.
+
+ lineSize to change the size/width of the line.
+
+
+ lineMarkSize to change the size/radius of marks.
+
+
+ showLine to show/hide the line.
+
+
+ showLineMarks to show/hide the line marks.
+
),
@@ -140,18 +146,18 @@ export const XYChartLineExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./custom_style_line')
+ code: require('!!raw-loader!./custom_style_line'),
},
{
type: GuideSectionTypes.HTML,
- code: 'This component can only be used from React'
- }
+ code: 'This component can only be used from React',
+ },
],
demo: (
- )
+ ),
},
- ]
+ ],
};
diff --git a/src-docs/src/views/xy_chart_line/multi_line.js b/src-docs/src/views/xy_chart_line/multi_line.js
index baf3dfe6cc4f..9aae57102a4e 100644
--- a/src-docs/src/views/xy_chart_line/multi_line.js
+++ b/src-docs/src/views/xy_chart_line/multi_line.js
@@ -1,36 +1,13 @@
import React from 'react';
-import { EuiXYChart, EuiLine, EuiDefaultAxis } from '../../../../src/components';
+import { EuiXYChart, EuiLine } from '../../../../src/components';
-const DATA_A = [
- { x: 0, y: 1 },
- { x: 1, y: 1 },
- { x: 2, y: 2 },
- { x: 3, y: -1 },
- { x: 5, y: 2 },
-];
-const DATA_B = [
- { x: 0, y: 3 },
- { x: 1, y: 4 },
- { x: 2, y: 1 },
- { x: 3, y: 2 },
- { x: 5, y: 5 },
-];
+const DATA_A = [{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: -1 }, { x: 5, y: 2 }];
+const DATA_B = [{ x: 0, y: 3 }, { x: 1, y: 4 }, { x: 2, y: 1 }, { x: 3, y: 2 }, { x: 5, y: 5 }];
export default () => (
-
-
-
-
-
+
+
+
);
diff --git a/src/components/xy_chart/__snapshots__/area.test.js.snap b/src/components/xy_chart/__snapshots__/area.test.js.snap
index d878fcd1b85a..f9d44d9fbd79 100644
--- a/src/components/xy_chart/__snapshots__/area.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/area.test.js.snap
@@ -15,9 +15,10 @@ exports[`EuiArea all props are rendered 1`] = `
>
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`EuiArea is rendered 1`] = `
-
-
-
-
-
-
-
-
+
-
-
+
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`EuiArea is rendered 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
-
-
-
-
-
-
-
+ _animation={0.00008}
+ angleDomain={Array []}
+ animation={null}
+ attr="y"
+ attrAxis="x"
+ className=""
+ colorDomain={Array []}
+ colorRange={
+ Array [
+ "#EF5D28",
+ "#FF9833",
+ ]
+ }
+ data={null}
+ fillDomain={Array []}
+ fillRange={
+ Array [
+ "#EF5D28",
+ "#FF9833",
+ ]
+ }
+ getAngle={[Function]}
+ getAngle0={[Function]}
+ getColor={[Function]}
+ getColor0={[Function]}
+ getFill={[Function]}
+ getFill0={[Function]}
+ getOpacity={[Function]}
+ getOpacity0={[Function]}
+ getRadius={[Function]}
+ getRadius0={[Function]}
+ getSize={[Function]}
+ getSize0={[Function]}
+ getStroke={[Function]}
+ getStroke0={[Function]}
+ getX={[Function]}
+ getX0={[Function]}
+ getY={[Function]}
+ getY0={[Function]}
+ innerHeight={196}
+ innerWidth={596}
+ marginBottom={2}
+ marginLeft={2}
+ marginRight={2}
+ marginTop={2}
+ on0={false}
+ opacityDomain={Array []}
+ opacityType="literal"
+ orientation="left"
+ position="middle"
+ radiusDomain={Array []}
+ sizeDomain={Array []}
+ sizeRange={
+ Array [
+ 1,
+ 10,
+ ]
+ }
+ strokeDomain={Array []}
+ strokeRange={
+ Array [
+ "#EF5D28",
+ "#FF9833",
+ ]
+ }
+ style={Object {}}
+ tickPadding={8}
+ tickSize={0}
+ xDomain={
+ Array [
+ 0,
+ 1,
+ ]
+ }
+ xPadding={0}
+ xRange={
+ Array [
+ 0,
+ 596,
+ ]
+ }
+ xType="linear"
+ yDomain={
+ Array [
+ 5,
+ 15,
+ ]
+ }
+ yPadding={0}
+ yRange={
+ Array [
+ 196,
+ 0,
+ ]
+ }
+ yType="linear"
+ >
+
+
+
+
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 5
+
+
+
+
+
+ 10
+
+
+
+
+
+ 15
+
+
+
+
+
+ 20
+
+
+
+
@@ -80,6 +479,405 @@ exports[`EuiHorizontalBarSeries is rendered 1`] = `
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 5
+
+
+
+
+
+ 10
+
+
+
+
+
+ 15
+
+
+
+
+
+ 20
+
+
+
+
@@ -142,6 +940,225 @@ exports[`EuiHorizontalBarSeries renders stacked bar chart 1`] = `
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 1
+
+
+
+
+
+
+
+
+
+
+ 2
+
+
+
+
+
+ 4
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
diff --git a/src/components/xy_chart/__snapshots__/horizontal_rect_series.test.js.snap b/src/components/xy_chart/__snapshots__/horizontal_rect_series.test.js.snap
index ba079e6fbb4d..a52f81e2697d 100644
--- a/src/components/xy_chart/__snapshots__/horizontal_rect_series.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/horizontal_rect_series.test.js.snap
@@ -35,6 +35,405 @@ exports[`EuiHorizontalRectSeries all props are rendered 1`] = `
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
@@ -80,6 +479,405 @@ exports[`EuiHorizontalRectSeries is rendered 1`] = `
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
@@ -142,6 +940,309 @@ exports[`EuiHorizontalRectSeries renders stacked bar chart 1`] = `
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 1
+
+
+
+
+
+
+
+
+
+
+ 3
+
+
+
+
+
+ 4
+
+
+
+
+
+ 5
+
+
+
+
+
+ 6
+
+
+
+
+
+ 7
+
+
+
+
+
+ 8
+
+
+
+
+
+ 9
+
+
+
+
+
+ 10
+
+
+
+
diff --git a/src/components/xy_chart/__snapshots__/line.test.js.snap b/src/components/xy_chart/__snapshots__/line.test.js.snap
index 68cf86073b33..8212d4553088 100644
--- a/src/components/xy_chart/__snapshots__/line.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/line.test.js.snap
@@ -15,9 +15,10 @@ exports[`EuiLine all props are rendered 1`] = `
>
-
-
-
-
-
-
-
-
-
-
-`;
-
-exports[`EuiLine is rendered 1`] = `
-
-
-
-
-
-
-
-
+
-
-
+
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+`;
+
+exports[`EuiLine is rendered 1`] = `
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
+
+
+
+
-
-
-
-
-
-
-
-
+ data={null}
+ fillDomain={Array []}
+ fillRange={
+ Array [
+ "#EF5D28",
+ "#FF9833",
+ ]
+ }
+ getAngle={[Function]}
+ getAngle0={[Function]}
+ getColor={[Function]}
+ getColor0={[Function]}
+ getFill={[Function]}
+ getFill0={[Function]}
+ getOpacity={[Function]}
+ getOpacity0={[Function]}
+ getRadius={[Function]}
+ getRadius0={[Function]}
+ getSize={[Function]}
+ getSize0={[Function]}
+ getStroke={[Function]}
+ getStroke0={[Function]}
+ getX={[Function]}
+ getX0={[Function]}
+ getY={[Function]}
+ getY0={[Function]}
+ height={196}
+ innerHeight={196}
+ innerWidth={596}
+ left={0}
+ marginBottom={2}
+ marginLeft={2}
+ marginRight={2}
+ marginTop={2}
+ on0={false}
+ opacityDomain={Array []}
+ opacityType="literal"
+ orientation="left"
+ position="middle"
+ radiusDomain={Array []}
+ sizeDomain={Array []}
+ sizeRange={
+ Array [
+ 1,
+ 10,
+ ]
+ }
+ strokeDomain={Array []}
+ strokeRange={
+ Array [
+ "#EF5D28",
+ "#FF9833",
+ ]
+ }
+ style={Object {}}
+ tickPadding={8}
+ tickSize={0}
+ tickTotal={5}
+ top={2}
+ width={2}
+ xDomain={
+ Array [
+ 0,
+ 1,
+ ]
+ }
+ xPadding={0}
+ xRange={
+ Array [
+ 0,
+ 596,
+ ]
+ }
+ xType="linear"
+ yDomain={
+ Array [
+ 5,
+ 15,
+ ]
+ }
+ yPadding={0}
+ yRange={
+ Array [
+ 196,
+ 0,
+ ]
+ }
+ yType="linear"
+ >
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -0.4
+
+
+
+
+
+ -0.2
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 1.0
+
+
+
+
+
+ 1.2
+
+
+
+
+
+ 1.4
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 2
+
+
+
+
+
+ 4
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
@@ -76,6 +539,469 @@ exports[`EuiVerticalBarSeries is rendered 1`] = `
y="0"
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ -0.4
+
+
+
+
+
+ -0.2
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 1.0
+
+
+
+
+
+ 1.2
+
+
+
+
+
+ 1.4
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 2
+
+
+
+
+
+ 4
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
@@ -134,6 +1060,253 @@ exports[`EuiVerticalBarSeries renders stacked bar chart 1`] = `
y="0"
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 1
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 2
+
+
+
+
+
+ 4
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
diff --git a/src/components/xy_chart/__snapshots__/vertical_rect_series.test.js.snap b/src/components/xy_chart/__snapshots__/vertical_rect_series.test.js.snap
index f01a36c35a93..9c866d415e28 100644
--- a/src/components/xy_chart/__snapshots__/vertical_rect_series.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/vertical_rect_series.test.js.snap
@@ -35,6 +35,489 @@ exports[`EuiVerticalRectSeries all props are rendered 1`] = `
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 2
+
+
+
+
+
+ 4
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
@@ -80,6 +563,489 @@ exports[`EuiVerticalRectSeries is rendered 1`] = `
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 2
+
+
+
+
+
+ 4
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
@@ -142,6 +1108,253 @@ exports[`EuiVerticalRectSeries renders stacked vertical histogram 1`] = `
/>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 1
+
+
+
+
+
+
+
+
+
+
+ 0
+
+
+
+
+
+ 2
+
+
+
+
+
+ 4
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
diff --git a/src/components/xy_chart/axis/default_axis.js b/src/components/xy_chart/axis/default_axis.js
index 0fe69b93cc97..32658f164995 100644
--- a/src/components/xy_chart/axis/default_axis.js
+++ b/src/components/xy_chart/axis/default_axis.js
@@ -4,7 +4,7 @@ import { EuiXAxis } from './x_axis';
import { EuiYAxis } from './y_axis';
import { EuiHorizontalGrid } from './horizontal_grid';
import { EuiVerticalGrid } from './vertical_grid';
-
+import { EuiXYChartUtils } from '../utils/chart_utils';
export class EuiDefaultAxis extends PureComponent {
_getTickLabels(ticks) {
if (!ticks) return;
@@ -25,11 +25,14 @@ export class EuiDefaultAxis extends PureComponent {
}
render() {
- const { showGridLines, isHorizontal, ...rest } = this.props;
+ const { showGridLines, orientation, ...rest } = this.props;
+
return (
- {showGridLines && !isHorizontal && }
- {showGridLines && isHorizontal && }
+ {showGridLines &&
+ orientation === EuiXYChartUtils.ORIENTATION.VERTICAL && }
+ {showGridLines &&
+ orientation === EuiXYChartUtils.ORIENTATION.HORIZONTAL && }
@@ -39,14 +42,14 @@ export class EuiDefaultAxis extends PureComponent {
}
EuiDefaultAxis.propTypes = {
- isHorizontal: PropTypes.bool,
+ orientation: PropTypes.string,
showGridLines: PropTypes.bool,
yOn0: PropTypes.bool,
xOn0: PropTypes.bool,
};
EuiDefaultAxis.defaultProps = {
- isHorizontal: false,
+ orientation: false,
showGridLines: true,
};
diff --git a/src/components/xy_chart/chart.js b/src/components/xy_chart/chart.js
index 5124ffd46ba0..1e33fbcba9d8 100644
--- a/src/components/xy_chart/chart.js
+++ b/src/components/xy_chart/chart.js
@@ -3,6 +3,7 @@ import { XYPlot, makeWidthFlexible, AbstractSeries } from 'react-vis';
import PropTypes from 'prop-types';
import Highlight from './highlight';
+import { EuiDefaultAxis } from './axis/default_axis';
import { EuiCrosshairX } from './crosshairs/crosshair_x';
import { EuiCrosshairY } from './crosshairs/crosshair_y';
import { VISUALIZATION_COLORS } from '../../services';
@@ -80,8 +81,9 @@ class XYChart extends PureComponent {
yPadding,
xPadding,
animation, // eslint-disable-line no-unused-vars
+ showDefaultAxis,
showCrosshair,
- crosshairOrientation,
+ orientation,
crosshairValue,
onCrosshairUpdate, // eslint-disable-line no-unused-vars
truncateLegends, // eslint-disable-line no-unused-vars
@@ -94,7 +96,7 @@ class XYChart extends PureComponent {
}
this.colorIterator = 0;
- const Crosshair = crosshairOrientation === EuiXYChartUtils.ORIENTATION.HORIZONTAL
+ const Crosshair = orientation === EuiXYChartUtils.ORIENTATION.HORIZONTAL
? EuiCrosshairY
: EuiCrosshairX
return (
@@ -118,7 +120,9 @@ class XYChart extends PureComponent {
>
{React.Children.map(children, this._renderChildren)}
-
+ {
+ showDefaultAxis &&
+ }
{ showCrosshair && (
{
- texts.map((piece) => {
+ texts.map((piece, i) => {
return (
- {piece}
+ {piece}
)
})
}
From ec3862c40929d765b3c8bedf68f101c1c1dc8076 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Tue, 19 Jun 2018 18:26:37 +0200
Subject: [PATCH 23/68] Add two example of time series
---
.../xy_chart_histogram/histogram_example.js | 57 +++++++++++++++++++
.../time_histogram_series.js | 50 ++++++++++++++++
.../views/xy_chart_histogram/time_series.js | 50 ++++++++++++++++
3 files changed, 157 insertions(+)
create mode 100644 src-docs/src/views/xy_chart_histogram/time_histogram_series.js
create mode 100644 src-docs/src/views/xy_chart_histogram/time_series.js
diff --git a/src-docs/src/views/xy_chart_histogram/histogram_example.js b/src-docs/src/views/xy_chart_histogram/histogram_example.js
index 6c91717724b5..2f5458da0e49 100644
--- a/src-docs/src/views/xy_chart_histogram/histogram_example.js
+++ b/src-docs/src/views/xy_chart_histogram/histogram_example.js
@@ -4,6 +4,8 @@ import VerticalRectSeriesExample from './vertical_rect_series';
import StackedVerticalRectSeriesExample from './stacked_vertical_rect_series';
import HorizontalRectSeriesExample from './horizontal_rect_series';
import StackedHorizontalRectSeriesExample from './stacked_horizontal_rect_series';
+import TimeSeriesExample from './time_series';
+import TimeHistogramSeriesExample from './time_histogram_series';
import {
EuiCode,
@@ -134,5 +136,60 @@ export const XYChartHistogramExample = {
),
},
+ {
+ title: 'Time Series',
+ text: (
+
+
+ Use EuiXYChart with EuiVerticalBarSeries
+ with the
+ xType='time' .
+
+
+ ),
+ props: { EuiVerticalRectSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./time_series'),
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React',
+ },
+ ],
+ demo: (
+
+
+
+ ),
+ },
+ {
+ title: 'Time Series Histogram version',
+ text: (
+
+
+ Use EuiXYChart with EuiVerticalRectSeries
+ with the xType='time' and a moderate number of elements.
+
+
+ ),
+ props: { EuiVerticalRectSeries },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./time_histogram_series'),
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React',
+ },
+ ],
+ demo: (
+
+
+
+ ),
+ },
],
};
diff --git a/src-docs/src/views/xy_chart_histogram/time_histogram_series.js b/src-docs/src/views/xy_chart_histogram/time_histogram_series.js
new file mode 100644
index 000000000000..c1f3b73959af
--- /dev/null
+++ b/src-docs/src/views/xy_chart_histogram/time_histogram_series.js
@@ -0,0 +1,50 @@
+import React, { Component, Fragment } from 'react';
+
+import { EuiButton, EuiSpacer, EuiXYChart, EuiVerticalRectSeries } from '../../../../src/components';
+
+const timestamp = Date.now();
+const ONE_HOUR = 3600000;
+
+function randomizeData(size = 24, max = 15) {
+ return new Array(size)
+ .fill(0)
+ .map( (d,i) => ({ x0: ONE_HOUR * i, x: ONE_HOUR * (i + 1), y: Math.floor(Math.random() * max) }))
+ .map(el => ({
+ x0: el.x0 + timestamp,
+ x: el.x + timestamp,
+ y: el.y }));
+}
+function buildData(series) {
+ const max = Math.ceil(Math.random() * 100000000);
+ return new Array(series)
+ .fill(0)
+ .map(() => randomizeData(100, max))
+}
+export default class Example extends Component {
+ state = {
+ series: 4,
+ data: buildData(4)
+ }
+ handleRandomize = () => {
+ this.setState({
+ data: buildData(this.state.series),
+ });
+ }
+ render() {
+ const { data } = this.state;
+ return (
+
+
+ Randomize data
+
+
+
+
+ { data.map((d, i) => ( ))}
+
+
+ );
+ }
+}
diff --git a/src-docs/src/views/xy_chart_histogram/time_series.js b/src-docs/src/views/xy_chart_histogram/time_series.js
new file mode 100644
index 000000000000..408780119853
--- /dev/null
+++ b/src-docs/src/views/xy_chart_histogram/time_series.js
@@ -0,0 +1,50 @@
+import React, { Component, Fragment } from 'react';
+
+import { EuiButton, EuiSpacer, EuiXYChart, EuiLine, EuiVerticalBarSeries } from '../../../../src/components';
+
+const timestamp = Date.now();
+const ONE_HOUR = 3600000;
+
+function randomizeData(size = 24, max = 15) {
+ return new Array(size)
+ .fill(0)
+ .map( (d,i) => ({ x0: ONE_HOUR * i, x: ONE_HOUR * (i + 1), y: Math.floor(Math.random() * max) }))
+ .map(el => ({
+ x: el.x + timestamp,
+ y: el.y }));
+}
+function buildData(series) {
+ const max = Math.ceil(Math.random() * 100000);
+ return new Array(series)
+ .fill(0)
+ .map(() => randomizeData(10, max))
+}
+export default class Example extends Component {
+ state = {
+ series: 4,
+ data: buildData(4)
+ }
+ handleRandomize = () => {
+ this.setState({
+ data: buildData(this.state.series),
+ });
+ }
+ render() {
+ const { data } = this.state;
+ return (
+
+
+ Randomize data
+
+
+
+
+ { data.map((d, i) => ( ))}
+ { data.map((d, i) => ( ))}
+
+
+ );
+ }
+}
From 05091960259a2d9c734cf5185fae6a666b14856f Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Wed, 20 Jun 2018 11:26:36 +0200
Subject: [PATCH 24/68] House-cleaning
---
src-docs/src/routes.js | 24 +++++++------
.../{example-complex.js => complex.js} | 8 ++---
...example-crosshair.js => crosshair_sync.js} | 0
.../xy_chart/{example-empty.js => empty.js} | 0
.../src/views/xy_chart/example-auto-axis.js | 13 -------
.../{example_dual_axis.js => multi_axis.js} | 8 ++---
.../src/views/xy_chart/xy_chart_example.js | 18 +++++-----
src-docs/src/views/xy_chart_area/area.js | 4 +--
.../src/views/xy_chart_area/area_example.js | 12 +++----
.../src/views/xy_chart_area/curved_area.js | 6 ++--
.../src/views/xy_chart_area/stacked_area.js | 6 ++--
.../src/views/xy_chart_axis/simple_axis.js | 4 +--
.../views/xy_chart_histogram/time_series.js | 4 +--
.../src/views/xy_chart_line/curved_line.js | 4 +--
.../views/xy_chart_line/custom_domain_line.js | 4 +--
.../views/xy_chart_line/custom_style_line.js | 4 +--
src-docs/src/views/xy_chart_line/line.js | 4 +--
.../src/views/xy_chart_line/line_example.js | 18 +++++-----
.../src/views/xy_chart_line/multi_line.js | 6 ++--
src/components/index.js | 4 +--
.../xy_chart/__snapshots__/title.test.js.snap | 11 ------
...art.test.js.snap => xy_chart.test.js.snap} | 0
src/components/xy_chart/axis/index.js | 5 +++
src/components/xy_chart/crosshairs/index.js | 2 ++
src/components/xy_chart/index.js | 30 +++++++---------
.../__snapshots__/area_series.test.js.snap} | 4 +--
.../horizontal_bar_series.test.js.snap | 0
.../horizontal_rect_series.test.js.snap | 0
.../__snapshots__/line_series.test.js.snap} | 4 +--
.../vertical_bar_series.test.js.snap | 0
.../vertical_rect_series.test.js.snap | 0
.../{area.js => series/area_series.js} | 6 ++--
.../area_series.test.js} | 20 +++++------
.../xy_chart/{ => series}/as_series.js | 0
.../xy_chart/{ => series}/bar_series.js | 0
.../{ => series}/horizontal_bar_series.js | 0
.../horizontal_bar_series.test.js | 6 ++--
.../{ => series}/horizontal_rect_series.js | 0
.../horizontal_rect_series.test.js | 6 ++--
src/components/xy_chart/series/index.js | 7 ++++
.../{line.js => series/line_series.js} | 6 ++--
.../line_series.test.js} | 20 +++++------
.../{ => series}/vertical_bar_series.js | 0
.../{ => series}/vertical_bar_series.test.js | 8 ++---
.../{ => series}/vertical_rect_series.js | 0
.../{ => series}/vertical_rect_series.test.js | 8 ++---
src/components/xy_chart/title.js | 34 -------------------
src/components/xy_chart/title.test.js | 18 ----------
src/components/xy_chart/utils/index.js | 3 ++
.../xy_chart/{chart.js => xy_chart.js} | 0
.../{chart.test.js => xy_chart.test.js} | 2 +-
51 files changed, 145 insertions(+), 206 deletions(-)
rename src-docs/src/views/xy_chart/{example-complex.js => complex.js} (94%)
rename src-docs/src/views/xy_chart/{example-crosshair.js => crosshair_sync.js} (100%)
rename src-docs/src/views/xy_chart/{example-empty.js => empty.js} (100%)
delete mode 100644 src-docs/src/views/xy_chart/example-auto-axis.js
rename src-docs/src/views/xy_chart/{example_dual_axis.js => multi_axis.js} (95%)
delete mode 100644 src/components/xy_chart/__snapshots__/title.test.js.snap
rename src/components/xy_chart/__snapshots__/{chart.test.js.snap => xy_chart.test.js.snap} (100%)
create mode 100644 src/components/xy_chart/axis/index.js
create mode 100644 src/components/xy_chart/crosshairs/index.js
rename src/components/xy_chart/{__snapshots__/area.test.js.snap => series/__snapshots__/area_series.test.js.snap} (99%)
rename src/components/xy_chart/{ => series}/__snapshots__/horizontal_bar_series.test.js.snap (100%)
rename src/components/xy_chart/{ => series}/__snapshots__/horizontal_rect_series.test.js.snap (100%)
rename src/components/xy_chart/{__snapshots__/line.test.js.snap => series/__snapshots__/line_series.test.js.snap} (99%)
rename src/components/xy_chart/{ => series}/__snapshots__/vertical_bar_series.test.js.snap (100%)
rename src/components/xy_chart/{ => series}/__snapshots__/vertical_rect_series.test.js.snap (100%)
rename src/components/xy_chart/{area.js => series/area_series.js} (90%)
rename src/components/xy_chart/{area.test.js => series/area_series.test.js} (83%)
rename src/components/xy_chart/{ => series}/as_series.js (100%)
rename src/components/xy_chart/{ => series}/bar_series.js (100%)
rename src/components/xy_chart/{ => series}/horizontal_bar_series.js (100%)
rename src/components/xy_chart/{ => series}/horizontal_bar_series.test.js (92%)
rename src/components/xy_chart/{ => series}/horizontal_rect_series.js (100%)
rename src/components/xy_chart/{ => series}/horizontal_rect_series.test.js (92%)
create mode 100644 src/components/xy_chart/series/index.js
rename src/components/xy_chart/{line.js => series/line_series.js} (95%)
rename src/components/xy_chart/{line.test.js => series/line_series.test.js} (84%)
rename src/components/xy_chart/{ => series}/vertical_bar_series.js (100%)
rename src/components/xy_chart/{ => series}/vertical_bar_series.test.js (94%)
rename src/components/xy_chart/{ => series}/vertical_rect_series.js (100%)
rename src/components/xy_chart/{ => series}/vertical_rect_series.test.js (94%)
delete mode 100644 src/components/xy_chart/title.js
delete mode 100644 src/components/xy_chart/title.test.js
create mode 100644 src/components/xy_chart/utils/index.js
rename src/components/xy_chart/{chart.js => xy_chart.js} (100%)
rename src/components/xy_chart/{chart.test.js => xy_chart.test.js} (95%)
diff --git a/src-docs/src/routes.js b/src-docs/src/routes.js
index ccf312924607..986c99fcf3fc 100644
--- a/src-docs/src/routes.js
+++ b/src-docs/src/routes.js
@@ -338,16 +338,6 @@ const navigation = [{
ToastExample,
ToolTipExample,
].map(example => createExample(example)),
-}, {
- name: 'Charts',
- items: [
- XYChartExample,
- XYChartAxisExample,
- XYChartLineExample,
- XYChartAreaExample,
- XYChartBarExample,
- XYChartHistogramExample,
- ].map(example => createExample(example)),
}, {
name: 'Forms',
items: [
@@ -362,7 +352,19 @@ const navigation = [{
FilterGroupExample,
SearchBarExample,
].map(example => createExample(example)),
-}, {
+},
+{
+ name: 'XY Charts',
+ items: [
+ XYChartExample,
+ XYChartAxisExample,
+ XYChartLineExample,
+ XYChartAreaExample,
+ XYChartBarExample,
+ XYChartHistogramExample,
+ ].map(example => createExample(example)),
+},
+{
name: 'Utilities',
items: [
AccessibilityExample,
diff --git a/src-docs/src/views/xy_chart/example-complex.js b/src-docs/src/views/xy_chart/complex.js
similarity index 94%
rename from src-docs/src/views/xy_chart/example-complex.js
rename to src-docs/src/views/xy_chart/complex.js
index a2cc88f04ca0..508a02bcf6a5 100644
--- a/src-docs/src/views/xy_chart/example-complex.js
+++ b/src-docs/src/views/xy_chart/complex.js
@@ -3,8 +3,8 @@ import React from 'react';
import {
EuiXYChart,
EuiVerticalBarSeries,
- EuiArea,
- EuiLine,
+ EuiAreaSeries,
+ EuiLineSeries,
} from '../../../../src/components';
export default () => {
@@ -29,7 +29,7 @@ export default () => {
width={600}
height={200}
>
- {
alert('clicked!');
@@ -54,7 +54,7 @@ export default () => {
data={data}
/>
))}
- (
-
-
-
-);
diff --git a/src-docs/src/views/xy_chart/example_dual_axis.js b/src-docs/src/views/xy_chart/multi_axis.js
similarity index 95%
rename from src-docs/src/views/xy_chart/example_dual_axis.js
rename to src-docs/src/views/xy_chart/multi_axis.js
index f9191e2e5102..e8bdb688cd8b 100644
--- a/src-docs/src/views/xy_chart/example_dual_axis.js
+++ b/src-docs/src/views/xy_chart/multi_axis.js
@@ -2,7 +2,7 @@ import React from 'react';
import {
EuiXYChart,
- EuiLine,
+ EuiLineSeries,
EuiXAxis,
EuiYAxis,
EuiXYChartAxisUtils,
@@ -27,17 +27,17 @@ export default () => (
xType="ordinal"
showDefaultAxis={false}
>
-
-
-
Use EuiXYChart to display line, bar, area, and stream charts. Note
- that charts are composed with EuiLine , EuiArea ,{' '}
+ that charts are composed with EuiLineSeries , EuiAreaSeries ,{' '}
EuiBar , and EuiStream being child components.
@@ -23,7 +23,7 @@ export const XYChartExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./example-complex'),
+ code: require('!!raw-loader!./complex'),
},
{
type: GuideSectionTypes.HTML,
@@ -46,7 +46,7 @@ export const XYChartExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./example-empty'),
+ code: require('!!raw-loader!./empty'),
},
{
type: GuideSectionTypes.HTML,
@@ -71,7 +71,7 @@ export const XYChartExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./example-empty'),
+ code: require('!!raw-loader!./crosshair_sync'),
},
{
type: GuideSectionTypes.HTML,
@@ -94,7 +94,7 @@ export const XYChartExample = {
source: [
{
type: GuideSectionTypes.JS,
- code: require('!!raw-loader!./example_dual_axis'),
+ code: require('!!raw-loader!./multi_axis'),
},
{
type: GuideSectionTypes.HTML,
diff --git a/src-docs/src/views/xy_chart_area/area.js b/src-docs/src/views/xy_chart_area/area.js
index de5b750bb838..2296360091d5 100644
--- a/src-docs/src/views/xy_chart_area/area.js
+++ b/src-docs/src/views/xy_chart_area/area.js
@@ -1,11 +1,11 @@
import React from 'react';
-import { EuiXYChart, EuiArea } from '../../../../src/components';
+import { EuiXYChart, EuiAreaSeries } from '../../../../src/components';
const DATA_A = [{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: 1 }, { x: 5, y: 2 }];
export default () => (
-
+
);
diff --git a/src-docs/src/views/xy_chart_area/area_example.js b/src-docs/src/views/xy_chart_area/area_example.js
index 1bde2257b721..9239d0204a2b 100644
--- a/src-docs/src/views/xy_chart_area/area_example.js
+++ b/src-docs/src/views/xy_chart_area/area_example.js
@@ -4,7 +4,7 @@ import AreaSeriesExample from './area';
import StackedAreaSeriesExample from './stacked_area';
import CurvedAreaExample from './curved_area';
-import { EuiCode, EuiArea, EuiLink } from '../../../../src/components';
+import { EuiCode, EuiAreaSeries, EuiLink } from '../../../../src/components';
export const XYChartAreaExample = {
title: 'Area chart',
@@ -14,11 +14,11 @@ export const XYChartAreaExample = {
text: (
- Use EuiArea to display area charts.
+ Use EuiAreaSeries to display area charts.
),
- props: { EuiArea },
+ props: { EuiAreaSeries },
source: [
{
type: GuideSectionTypes.JS,
@@ -40,13 +40,13 @@ export const XYChartAreaExample = {
text: (
- Use multiple EuiArea to display stacked area charts specifying the{' '}
+ Use multiple EuiAreaSeries to display stacked area charts specifying the{' '}
stackBy:y prop on the EuiXYChart
to enable stacking.
),
- props: { EuiArea },
+ props: { EuiAreaSeries },
source: [
{
type: GuideSectionTypes.JS,
@@ -76,7 +76,7 @@ export const XYChartAreaExample = {
),
- props: { EuiArea },
+ props: { EuiAreaSeries },
source: [
{
type: GuideSectionTypes.JS,
diff --git a/src-docs/src/views/xy_chart_area/curved_area.js b/src-docs/src/views/xy_chart_area/curved_area.js
index 6e23cc1576b1..dd6d439dd2d6 100644
--- a/src-docs/src/views/xy_chart_area/curved_area.js
+++ b/src-docs/src/views/xy_chart_area/curved_area.js
@@ -6,7 +6,7 @@ import {
EuiSelect,
EuiSpacer,
EuiXYChart,
- EuiArea,
+ EuiAreaSeries,
} from '../../../../src/components';
const DATA_A = [{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: -1 }, { x: 5, y: 2 }];
@@ -52,8 +52,8 @@ export default class extends Component {
-
-
+
+
);
diff --git a/src-docs/src/views/xy_chart_area/stacked_area.js b/src-docs/src/views/xy_chart_area/stacked_area.js
index e2f1a6137c85..51286d6ca676 100644
--- a/src-docs/src/views/xy_chart_area/stacked_area.js
+++ b/src-docs/src/views/xy_chart_area/stacked_area.js
@@ -1,6 +1,6 @@
import React from 'react';
-import { EuiXYChart, EuiArea } from '../../../../src/components';
+import { EuiXYChart, EuiAreaSeries } from '../../../../src/components';
const dataA = [{ x: 0, y: 3 }, { x: 1, y: 2 }, { x: 2, y: 1 }, { x: 3, y: 2 }, { x: 4, y: 3 }];
@@ -8,7 +8,7 @@ const dataB = [{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 4 }, { x: 3, y: 1 }, {
export default () => (
-
-
+
+
);
diff --git a/src-docs/src/views/xy_chart_axis/simple_axis.js b/src-docs/src/views/xy_chart_axis/simple_axis.js
index 5858b2f1d678..13d0bb90d3c8 100644
--- a/src-docs/src/views/xy_chart_axis/simple_axis.js
+++ b/src-docs/src/views/xy_chart_axis/simple_axis.js
@@ -1,7 +1,7 @@
import React from 'react';
import {
- EuiLine,
+ EuiLineSeries,
EuiXAxis,
EuiYAxis,
EuiXYChart,
@@ -17,7 +17,7 @@ function xAxisTickFormatter(value) {
export default () => (
-
+
{ data.map((d, i) => ( ))}
- { data.map((d, i) => ( ))}
+ { data.map((d, i) => ( ))}
);
diff --git a/src-docs/src/views/xy_chart_line/curved_line.js b/src-docs/src/views/xy_chart_line/curved_line.js
index b69602a9e7e6..07dc833a1107 100644
--- a/src-docs/src/views/xy_chart_line/curved_line.js
+++ b/src-docs/src/views/xy_chart_line/curved_line.js
@@ -6,7 +6,7 @@ import {
EuiSelect,
EuiSpacer,
EuiXYChart,
- EuiLine,
+ EuiLineSeries,
} from '../../../../src/components';
const DATA_A = [{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: -1 }, { x: 5, y: 2 }];
@@ -52,7 +52,7 @@ export default class extends Component {
-
+
);
diff --git a/src-docs/src/views/xy_chart_line/custom_domain_line.js b/src-docs/src/views/xy_chart_line/custom_domain_line.js
index 4aaf42f80aad..157203bd138e 100644
--- a/src-docs/src/views/xy_chart_line/custom_domain_line.js
+++ b/src-docs/src/views/xy_chart_line/custom_domain_line.js
@@ -1,6 +1,6 @@
import React from 'react';
-import { EuiXYChart, EuiLine } from '../../../../src/components';
+import { EuiXYChart, EuiLineSeries } from '../../../../src/components';
const X_DOMAIN = [-1, 6];
const Y_DOMAIN = [0, 3];
@@ -9,6 +9,6 @@ const DATA_A = [{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: 1 },
export default () => (
-
+
);
diff --git a/src-docs/src/views/xy_chart_line/custom_style_line.js b/src-docs/src/views/xy_chart_line/custom_style_line.js
index ea8aeed8ec8e..f2cb866649f9 100644
--- a/src-docs/src/views/xy_chart_line/custom_style_line.js
+++ b/src-docs/src/views/xy_chart_line/custom_style_line.js
@@ -6,7 +6,7 @@ import {
EuiRange,
EuiSpacer,
EuiXYChart,
- EuiLine,
+ EuiLineSeries,
EuiCheckboxGroup,
} from '../../../../src/components';
@@ -100,7 +100,7 @@ export default class extends Component {
- (
-
+
);
diff --git a/src-docs/src/views/xy_chart_line/line_example.js b/src-docs/src/views/xy_chart_line/line_example.js
index 349d05ef5733..2eb461624412 100644
--- a/src-docs/src/views/xy_chart_line/line_example.js
+++ b/src-docs/src/views/xy_chart_line/line_example.js
@@ -5,7 +5,7 @@ import CustomDomainLineChartExample from './custom_domain_line';
import MultiLineChartExample from './multi_line';
import CurvedLineChartExample from './curved_line';
import CustomStyleLineChartExample from './custom_style_line';
-import { EuiCode, EuiLine, EuiLink } from '../../../../src/components';
+import { EuiCode, EuiLineSeries, EuiLink } from '../../../../src/components';
export const XYChartLineExample = {
title: 'Line chart',
@@ -15,12 +15,12 @@ export const XYChartLineExample = {
text: (
- Use EuiLine to display line charts. The chart domain will cover the
+ Use EuiLineSeries to display line charts. The chart domain will cover the
whole extent and doesn't add any padding.
),
- props: { EuiLine },
+ props: { EuiLineSeries },
source: [
{
type: GuideSectionTypes.JS,
@@ -42,13 +42,13 @@ export const XYChartLineExample = {
text: (
- Use EuiLine to display line charts. Specify{' '}
+ Use EuiLineSeries to display line charts. Specify{' '}
xDomain and/or yDomain
props to use custom domains.
),
- props: { EuiLine },
+ props: { EuiLineSeries },
source: [
{
type: GuideSectionTypes.JS,
@@ -70,11 +70,11 @@ export const XYChartLineExample = {
text: (
- Use multiple EuiLine to display a milti-line chart.
+ Use multiple EuiLineSeries to display a milti-line chart.
),
- props: { EuiLine },
+ props: { EuiLineSeries },
source: [
{
type: GuideSectionTypes.JS,
@@ -104,7 +104,7 @@ export const XYChartLineExample = {
),
- props: { EuiLine },
+ props: { EuiLineSeries },
source: [
{
type: GuideSectionTypes.JS,
@@ -142,7 +142,7 @@ export const XYChartLineExample = {
),
- props: { EuiLine },
+ props: { EuiLineSeries },
source: [
{
type: GuideSectionTypes.JS,
diff --git a/src-docs/src/views/xy_chart_line/multi_line.js b/src-docs/src/views/xy_chart_line/multi_line.js
index 9aae57102a4e..ba918494afb5 100644
--- a/src-docs/src/views/xy_chart_line/multi_line.js
+++ b/src-docs/src/views/xy_chart_line/multi_line.js
@@ -1,13 +1,13 @@
import React from 'react';
-import { EuiXYChart, EuiLine } from '../../../../src/components';
+import { EuiXYChart, EuiLineSeries } from '../../../../src/components';
const DATA_A = [{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: -1 }, { x: 5, y: 2 }];
const DATA_B = [{ x: 0, y: 3 }, { x: 1, y: 4 }, { x: 2, y: 1 }, { x: 3, y: 2 }, { x: 5, y: 5 }];
export default () => (
-
-
+
+
);
diff --git a/src/components/index.js b/src/components/index.js
index 7c8cd274f543..cb5d86f1dbea 100644
--- a/src/components/index.js
+++ b/src/components/index.js
@@ -307,8 +307,8 @@ export {
EuiXYChartUtils,
EuiXYChartAxisUtils,
EuiXYChartTextUtils,
- EuiLine,
- EuiArea,
+ EuiLineSeries,
+ EuiAreaSeries,
EuiBarSeries,
EuiVerticalBarSeries,
EuiHorizontalBarSeries,
diff --git a/src/components/xy_chart/__snapshots__/title.test.js.snap b/src/components/xy_chart/__snapshots__/title.test.js.snap
deleted file mode 100644
index 5d502f32bce9..000000000000
--- a/src/components/xy_chart/__snapshots__/title.test.js.snap
+++ /dev/null
@@ -1,11 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`EuiTitle is rendered 1`] = `
-
- Title
-
-`;
diff --git a/src/components/xy_chart/__snapshots__/chart.test.js.snap b/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
similarity index 100%
rename from src/components/xy_chart/__snapshots__/chart.test.js.snap
rename to src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
diff --git a/src/components/xy_chart/axis/index.js b/src/components/xy_chart/axis/index.js
new file mode 100644
index 000000000000..ea6034fb57d7
--- /dev/null
+++ b/src/components/xy_chart/axis/index.js
@@ -0,0 +1,5 @@
+export { EuiDefaultAxis } from './default_axis';
+export { EuiXAxis } from './x_axis';
+export { EuiYAxis } from './y_axis';
+export { EuiHorizontalGrid } from './horizontal_grid';
+export { EuiVerticalGrid } from './vertical_grid';
diff --git a/src/components/xy_chart/crosshairs/index.js b/src/components/xy_chart/crosshairs/index.js
new file mode 100644
index 000000000000..7eb5f347a4c1
--- /dev/null
+++ b/src/components/xy_chart/crosshairs/index.js
@@ -0,0 +1,2 @@
+export { EuiCrosshairX } from './crosshair_x';
+export { EuiCrosshairY } from './crosshair_y';
diff --git a/src/components/xy_chart/index.js b/src/components/xy_chart/index.js
index 6cdafcff6531..2a105961fc2a 100644
--- a/src/components/xy_chart/index.js
+++ b/src/components/xy_chart/index.js
@@ -1,17 +1,13 @@
-export { asSeries } from './as_series';
-export { EuiXYChart } from './chart';
-export { EuiLine } from './line';
-export { EuiBarSeries } from './bar_series';
-export { EuiVerticalBarSeries } from './vertical_bar_series';
-export { EuiHorizontalBarSeries } from './horizontal_bar_series';
-export { EuiVerticalRectSeries } from './vertical_rect_series';
-export { EuiHorizontalRectSeries } from './horizontal_rect_series';
-export { EuiDefaultAxis } from './axis/default_axis';
-export { EuiXAxis } from './axis/x_axis';
-export { EuiYAxis } from './axis/y_axis';
-export { EuiArea } from './area';
-export { EuiXYChartUtils } from './utils/chart_utils';
-export { EuiXYChartAxisUtils } from './utils/axis_utils';
-export { EuiXYChartTextUtils } from './utils/text_utils';
-export { EuiCrosshairX } from './crosshairs/crosshair_x';
-export { EuiCrosshairY } from './crosshairs/crosshair_y';
+export { EuiXYChart } from './xy_chart';
+
+// XY chart data series
+export * from './series';
+
+// XY chart axis components
+export * from './axis';
+
+// XY chart utility classes
+export * from './utils';
+
+// XY chart crosshairs
+export * from './crosshairs';
diff --git a/src/components/xy_chart/__snapshots__/area.test.js.snap b/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap
similarity index 99%
rename from src/components/xy_chart/__snapshots__/area.test.js.snap
rename to src/components/xy_chart/series/__snapshots__/area_series.test.js.snap
index f9d44d9fbd79..bb8af741c099 100644
--- a/src/components/xy_chart/__snapshots__/area.test.js.snap
+++ b/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`EuiArea all props are rendered 1`] = `
+exports[`EuiAreaSeries all props are rendered 1`] = `
`;
-exports[`EuiArea is rendered 1`] = `
+exports[`EuiAreaSeries is rendered 1`] = `
`;
-exports[`EuiLine is rendered 1`] = `
+exports[`EuiLineSeries is rendered 1`] = `
*/
@@ -43,6 +43,6 @@ EuiArea.propTypes = {
onMarkClick: PropTypes.func
}
-EuiArea.defaultProps = {
+EuiAreaSeries.defaultProps = {
curve: 'linear',
};
diff --git a/src/components/xy_chart/area.test.js b/src/components/xy_chart/series/area_series.test.js
similarity index 83%
rename from src/components/xy_chart/area.test.js
rename to src/components/xy_chart/series/area_series.test.js
index fb545b7d3faf..18d93992bed5 100644
--- a/src/components/xy_chart/area.test.js
+++ b/src/components/xy_chart/series/area_series.test.js
@@ -1,20 +1,20 @@
import React from 'react';
import { mount, render } from 'enzyme';
-import { patchRandom, unpatchRandom } from '../../test/patch_random';
-import { requiredProps } from '../../test/required_props';
+import { patchRandom, unpatchRandom } from '../../../test/patch_random';
+import { requiredProps } from '../../../test/required_props';
-import { EuiXYChart } from './chart';
-import { EuiArea } from './area';
-import { benchmarkFunction } from '../../test/time_execution';
+import { EuiXYChart } from '../xy_chart';
+import { EuiAreaSeries } from './area_series';
+import { benchmarkFunction } from '../../../test/time_execution';
beforeEach(patchRandom);
afterEach(unpatchRandom);
-describe('EuiArea', () => {
+describe('EuiAreaSeries', () => {
test('is rendered', () => {
const component = mount(
-
@@ -27,7 +27,7 @@ describe('EuiArea', () => {
test('all props are rendered', () => {
const component = mount(
- {
function renderChart() {
render(
-
+
)
}
@@ -99,7 +99,7 @@ describe('EuiArea', () => {
render(
{linesData.map((data, index) => (
-
+
))}
)
diff --git a/src/components/xy_chart/as_series.js b/src/components/xy_chart/series/as_series.js
similarity index 100%
rename from src/components/xy_chart/as_series.js
rename to src/components/xy_chart/series/as_series.js
diff --git a/src/components/xy_chart/bar_series.js b/src/components/xy_chart/series/bar_series.js
similarity index 100%
rename from src/components/xy_chart/bar_series.js
rename to src/components/xy_chart/series/bar_series.js
diff --git a/src/components/xy_chart/horizontal_bar_series.js b/src/components/xy_chart/series/horizontal_bar_series.js
similarity index 100%
rename from src/components/xy_chart/horizontal_bar_series.js
rename to src/components/xy_chart/series/horizontal_bar_series.js
diff --git a/src/components/xy_chart/horizontal_bar_series.test.js b/src/components/xy_chart/series/horizontal_bar_series.test.js
similarity index 92%
rename from src/components/xy_chart/horizontal_bar_series.test.js
rename to src/components/xy_chart/series/horizontal_bar_series.test.js
index 84286eff7621..1869b5ea1c5e 100644
--- a/src/components/xy_chart/horizontal_bar_series.test.js
+++ b/src/components/xy_chart/series/horizontal_bar_series.test.js
@@ -1,9 +1,9 @@
import React from 'react';
import { render, mount } from 'enzyme';
-import { patchRandom, unpatchRandom } from '../../test/patch_random';
-import { requiredProps } from '../../test/required_props';
+import { patchRandom, unpatchRandom } from '../../../test/patch_random';
+import { requiredProps } from '../../../test/required_props';
-import { EuiXYChart } from './chart';
+import { EuiXYChart } from '../xy_chart';
import { EuiHorizontalBarSeries } from './horizontal_bar_series';
beforeEach(patchRandom);
diff --git a/src/components/xy_chart/horizontal_rect_series.js b/src/components/xy_chart/series/horizontal_rect_series.js
similarity index 100%
rename from src/components/xy_chart/horizontal_rect_series.js
rename to src/components/xy_chart/series/horizontal_rect_series.js
diff --git a/src/components/xy_chart/horizontal_rect_series.test.js b/src/components/xy_chart/series/horizontal_rect_series.test.js
similarity index 92%
rename from src/components/xy_chart/horizontal_rect_series.test.js
rename to src/components/xy_chart/series/horizontal_rect_series.test.js
index 486f839ebea3..1538d5aefb5c 100644
--- a/src/components/xy_chart/horizontal_rect_series.test.js
+++ b/src/components/xy_chart/series/horizontal_rect_series.test.js
@@ -1,9 +1,9 @@
import React from 'react';
import { render, mount } from 'enzyme';
-import { patchRandom, unpatchRandom } from '../../test/patch_random';
-import { requiredProps } from '../../test/required_props';
+import { patchRandom, unpatchRandom } from '../../../test/patch_random';
+import { requiredProps } from '../../../test/required_props';
-import { EuiXYChart } from './chart';
+import { EuiXYChart } from '../xy_chart';
import { EuiHorizontalRectSeries } from './horizontal_rect_series';
beforeEach(patchRandom);
diff --git a/src/components/xy_chart/series/index.js b/src/components/xy_chart/series/index.js
new file mode 100644
index 000000000000..410dd7fae86c
--- /dev/null
+++ b/src/components/xy_chart/series/index.js
@@ -0,0 +1,7 @@
+export { EuiLineSeries } from './line_series';
+export { EuiAreaSeries } from './area_series';
+export { EuiBarSeries } from './bar_series';
+export { EuiVerticalBarSeries } from './vertical_bar_series';
+export { EuiHorizontalBarSeries } from './horizontal_bar_series';
+export { EuiVerticalRectSeries } from './vertical_rect_series';
+export { EuiHorizontalRectSeries } from './horizontal_rect_series';
diff --git a/src/components/xy_chart/line.js b/src/components/xy_chart/series/line_series.js
similarity index 95%
rename from src/components/xy_chart/line.js
rename to src/components/xy_chart/series/line_series.js
index af4ff49e2dfb..5fab14dceeec 100644
--- a/src/components/xy_chart/line.js
+++ b/src/components/xy_chart/series/line_series.js
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
import { LineSeries, MarkSeries, AbstractSeries } from 'react-vis';
-export class EuiLine extends AbstractSeries {
+export class EuiLineSeries extends AbstractSeries {
render() {
const {
data,
@@ -68,7 +68,7 @@ export class EuiLine extends AbstractSeries {
}
}
-EuiLine.propTypes = {
+EuiLineSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
name: PropTypes.string.isRequired,
/** Array<{x: string|number, y: string|number}> */
@@ -94,7 +94,7 @@ EuiLine.propTypes = {
onMarkClick: PropTypes.func
};
-EuiLine.defaultProps = {
+EuiLineSeries.defaultProps = {
curve: 'linear',
showLine: true,
showLineMarks: true,
diff --git a/src/components/xy_chart/line.test.js b/src/components/xy_chart/series/line_series.test.js
similarity index 84%
rename from src/components/xy_chart/line.test.js
rename to src/components/xy_chart/series/line_series.test.js
index a7536592f494..9eb7863ef0aa 100644
--- a/src/components/xy_chart/line.test.js
+++ b/src/components/xy_chart/series/line_series.test.js
@@ -1,20 +1,20 @@
import React from 'react';
import { mount, render } from 'enzyme';
-import { patchRandom, unpatchRandom } from '../../test/patch_random';
-import { benchmarkFunction } from '../../test/time_execution';
-import { requiredProps } from '../../test/required_props';
+import { patchRandom, unpatchRandom } from '../../../test/patch_random';
+import { benchmarkFunction } from '../../../test/time_execution';
+import { requiredProps } from '../../../test/required_props';
-import { EuiXYChart } from './chart';
-import { EuiLine } from './line';
+import { EuiXYChart } from '../xy_chart';
+import { EuiLineSeries } from './line_series';
beforeEach(patchRandom);
afterEach(unpatchRandom);
-describe('EuiLine', () => {
+describe('EuiLineSeries', () => {
test('is rendered', () => {
const component = mount(
-
@@ -27,7 +27,7 @@ describe('EuiLine', () => {
test('all props are rendered', () => {
const component = mount(
- {
function renderChart() {
render(
-
+
)
}
@@ -100,7 +100,7 @@ describe('EuiLine', () => {
render(
{linesData.map((data, index) => (
-
+
))}
)
diff --git a/src/components/xy_chart/vertical_bar_series.js b/src/components/xy_chart/series/vertical_bar_series.js
similarity index 100%
rename from src/components/xy_chart/vertical_bar_series.js
rename to src/components/xy_chart/series/vertical_bar_series.js
diff --git a/src/components/xy_chart/vertical_bar_series.test.js b/src/components/xy_chart/series/vertical_bar_series.test.js
similarity index 94%
rename from src/components/xy_chart/vertical_bar_series.test.js
rename to src/components/xy_chart/series/vertical_bar_series.test.js
index 181ccda6d4a1..4ddbac73e191 100644
--- a/src/components/xy_chart/vertical_bar_series.test.js
+++ b/src/components/xy_chart/series/vertical_bar_series.test.js
@@ -1,11 +1,11 @@
import React from 'react';
import { render, mount } from 'enzyme';
-import { patchRandom, unpatchRandom } from '../../test/patch_random';
-import { requiredProps } from '../../test/required_props';
+import { patchRandom, unpatchRandom } from '../../../test/patch_random';
+import { requiredProps } from '../../../test/required_props';
-import { EuiXYChart } from './chart';
+import { EuiXYChart } from '../xy_chart';
import { EuiVerticalBarSeries } from './vertical_bar_series';
-import { benchmarkFunction } from '../../test/time_execution';
+import { benchmarkFunction } from '../../../test/time_execution';
beforeEach(patchRandom);
afterEach(unpatchRandom);
diff --git a/src/components/xy_chart/vertical_rect_series.js b/src/components/xy_chart/series/vertical_rect_series.js
similarity index 100%
rename from src/components/xy_chart/vertical_rect_series.js
rename to src/components/xy_chart/series/vertical_rect_series.js
diff --git a/src/components/xy_chart/vertical_rect_series.test.js b/src/components/xy_chart/series/vertical_rect_series.test.js
similarity index 94%
rename from src/components/xy_chart/vertical_rect_series.test.js
rename to src/components/xy_chart/series/vertical_rect_series.test.js
index 9ad2b887cbd8..c44212074a52 100644
--- a/src/components/xy_chart/vertical_rect_series.test.js
+++ b/src/components/xy_chart/series/vertical_rect_series.test.js
@@ -1,11 +1,11 @@
import React from 'react';
import { render, mount } from 'enzyme';
-import { patchRandom, unpatchRandom } from '../../test/patch_random';
-import { requiredProps } from '../../test/required_props';
+import { patchRandom, unpatchRandom } from '../../../test/patch_random';
+import { requiredProps } from '../../../test/required_props';
-import { EuiXYChart } from './chart';
+import { EuiXYChart } from '../xy_chart';
import { EuiVerticalRectSeries } from './vertical_rect_series';
-import { benchmarkFunction } from '../../test/time_execution';
+import { benchmarkFunction } from '../../../test/time_execution';
beforeEach(patchRandom);
afterEach(unpatchRandom);
diff --git a/src/components/xy_chart/title.js b/src/components/xy_chart/title.js
deleted file mode 100644
index e2278a89ce6e..000000000000
--- a/src/components/xy_chart/title.js
+++ /dev/null
@@ -1,34 +0,0 @@
-import {
- cloneElement,
-} from 'react';
-import classNames from 'classnames';
-import PropTypes from 'prop-types';
-
-const titleSizeToClassNameMap = {
- s: 'euiTitle--small',
- l: 'euiTitle--large',
-};
-
-export const TITLE_SIZES = Object.keys(titleSizeToClassNameMap);
-
-export const EuiTitle = ({ size, children, className, ...rest }) => {
-
- const classes = classNames(
- 'euiTitle',
- titleSizeToClassNameMap[size],
- className
- );
-
- const props = {
- className: classes,
- ...rest
- };
-
- return cloneElement(children, props);
-};
-
-EuiTitle.propTypes = {
- children: PropTypes.element.isRequired,
- className: PropTypes.string,
- size: PropTypes.oneOf(TITLE_SIZES),
-};
diff --git a/src/components/xy_chart/title.test.js b/src/components/xy_chart/title.test.js
deleted file mode 100644
index 16b907516f2d..000000000000
--- a/src/components/xy_chart/title.test.js
+++ /dev/null
@@ -1,18 +0,0 @@
-import React from 'react';
-import { render } from 'enzyme';
-import { requiredProps } from '../../test/required_props';
-
-import { EuiTitle } from './title';
-
-describe('EuiTitle', () => {
- test('is rendered', () => {
- const component = render(
-
- Title
-
- );
-
- expect(component)
- .toMatchSnapshot();
- });
-});
diff --git a/src/components/xy_chart/utils/index.js b/src/components/xy_chart/utils/index.js
new file mode 100644
index 000000000000..43f4f75eb290
--- /dev/null
+++ b/src/components/xy_chart/utils/index.js
@@ -0,0 +1,3 @@
+export { EuiXYChartUtils } from './chart_utils';
+export { EuiXYChartAxisUtils } from './axis_utils';
+export { EuiXYChartTextUtils } from './text_utils';
diff --git a/src/components/xy_chart/chart.js b/src/components/xy_chart/xy_chart.js
similarity index 100%
rename from src/components/xy_chart/chart.js
rename to src/components/xy_chart/xy_chart.js
diff --git a/src/components/xy_chart/chart.test.js b/src/components/xy_chart/xy_chart.test.js
similarity index 95%
rename from src/components/xy_chart/chart.test.js
rename to src/components/xy_chart/xy_chart.test.js
index d08c9e83461d..28715c9933be 100644
--- a/src/components/xy_chart/chart.test.js
+++ b/src/components/xy_chart/xy_chart.test.js
@@ -1,7 +1,7 @@
import React from 'react';
import { mount, render } from 'enzyme';
-import { EuiXYChart } from './chart';
+import { EuiXYChart } from './xy_chart';
import { requiredProps } from '../../test/required_props';
describe('EuiXYChart', () => {
From 3340a4341a5649b342f0af57150e3ed4c534d0c6 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Wed, 20 Jun 2018 11:39:22 +0200
Subject: [PATCH 25/68] Refactoring exporting for utils
---
src/components/xy_chart/axis/default_axis.js | 6 +++---
src/components/xy_chart/axis/x_axis.js | 4 +---
src/components/xy_chart/axis/y_axis.js | 4 +---
src/components/xy_chart/utils/axis_utils.js | 12 +++---------
src/components/xy_chart/utils/chart_utils.js | 7 +------
src/components/xy_chart/utils/index.js | 6 +++---
src/components/xy_chart/utils/text_utils.js | 6 +-----
src/components/xy_chart/xy_chart.js | 6 +++---
8 files changed, 16 insertions(+), 35 deletions(-)
diff --git a/src/components/xy_chart/axis/default_axis.js b/src/components/xy_chart/axis/default_axis.js
index 32658f164995..e241092c2e9f 100644
--- a/src/components/xy_chart/axis/default_axis.js
+++ b/src/components/xy_chart/axis/default_axis.js
@@ -4,7 +4,7 @@ import { EuiXAxis } from './x_axis';
import { EuiYAxis } from './y_axis';
import { EuiHorizontalGrid } from './horizontal_grid';
import { EuiVerticalGrid } from './vertical_grid';
-import { EuiXYChartUtils } from '../utils/chart_utils';
+import { ORIENTATION } from '../utils/chart_utils';
export class EuiDefaultAxis extends PureComponent {
_getTickLabels(ticks) {
if (!ticks) return;
@@ -30,9 +30,9 @@ export class EuiDefaultAxis extends PureComponent {
return (
{showGridLines &&
- orientation === EuiXYChartUtils.ORIENTATION.VERTICAL && }
+ orientation === ORIENTATION.VERTICAL && }
{showGridLines &&
- orientation === EuiXYChartUtils.ORIENTATION.HORIZONTAL && }
+ orientation === ORIENTATION.HORIZONTAL && }
diff --git a/src/components/xy_chart/axis/x_axis.js b/src/components/xy_chart/axis/x_axis.js
index 87eb2fbc911c..5debb8524048 100644
--- a/src/components/xy_chart/axis/x_axis.js
+++ b/src/components/xy_chart/axis/x_axis.js
@@ -1,9 +1,7 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { XAxis } from 'react-vis';
-import { EuiXYChartAxisUtils } from '../utils/axis_utils';
-
-const { TITLE_POSITION, ORIENTATION } = EuiXYChartAxisUtils;
+import { TITLE_POSITION, ORIENTATION } from '../utils/axis_utils';
export class EuiXAxis extends PureComponent {
render() {
diff --git a/src/components/xy_chart/axis/y_axis.js b/src/components/xy_chart/axis/y_axis.js
index 303438d3c302..0571f5d670bd 100644
--- a/src/components/xy_chart/axis/y_axis.js
+++ b/src/components/xy_chart/axis/y_axis.js
@@ -1,9 +1,7 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { YAxis } from 'react-vis';
-import { EuiXYChartAxisUtils } from '../utils/axis_utils';
-
-const { TITLE_POSITION, ORIENTATION } = EuiXYChartAxisUtils;
+import { TITLE_POSITION, ORIENTATION } from '../utils/axis_utils';
export class EuiYAxis extends PureComponent {
render() {
diff --git a/src/components/xy_chart/utils/axis_utils.js b/src/components/xy_chart/utils/axis_utils.js
index 3056e7324a3d..d2c7ae161e31 100644
--- a/src/components/xy_chart/utils/axis_utils.js
+++ b/src/components/xy_chart/utils/axis_utils.js
@@ -1,21 +1,15 @@
import { AxisUtils } from 'react-vis';
-const ORIENTATION = AxisUtils.ORIENTATION;
+export const ORIENTATION = AxisUtils.ORIENTATION;
-const TITLE_POSITION = {
+export const TITLE_POSITION = {
MIDDLE: 'middle',
START: 'start',
END: 'end',
};
-const GRID_TYPE = {
+export const GRID_TYPE = {
HORIZONTAL: 'horizontal',
VERTICAL: 'vertical',
BOTH: 'both',
};
-
-export const EuiXYChartAxisUtils = {
- TITLE_POSITION,
- GRID_TYPE,
- ORIENTATION,
-};
diff --git a/src/components/xy_chart/utils/chart_utils.js b/src/components/xy_chart/utils/chart_utils.js
index c867d5634f66..137b722dcfa5 100644
--- a/src/components/xy_chart/utils/chart_utils.js
+++ b/src/components/xy_chart/utils/chart_utils.js
@@ -1,9 +1,4 @@
-const ORIENTATION = {
+export const ORIENTATION = {
HORIZONTAL: 'horizontal',
VERTICAL: 'vertical',
- BOTH: 'both',
};
-
-export const EuiXYChartUtils = {
- ORIENTATION,
-}
diff --git a/src/components/xy_chart/utils/index.js b/src/components/xy_chart/utils/index.js
index 43f4f75eb290..c595eb93aba0 100644
--- a/src/components/xy_chart/utils/index.js
+++ b/src/components/xy_chart/utils/index.js
@@ -1,3 +1,3 @@
-export { EuiXYChartUtils } from './chart_utils';
-export { EuiXYChartAxisUtils } from './axis_utils';
-export { EuiXYChartTextUtils } from './text_utils';
+export * as EuiXYChartUtils from './chart_utils';
+export * as EuiXYChartAxisUtils from './axis_utils';
+export * as EuiXYChartTextUtils from './text_utils';
diff --git a/src/components/xy_chart/utils/text_utils.js b/src/components/xy_chart/utils/text_utils.js
index 669b468cea00..0d354a2d01f3 100644
--- a/src/components/xy_chart/utils/text_utils.js
+++ b/src/components/xy_chart/utils/text_utils.js
@@ -7,7 +7,7 @@ import React from 'react'
* @return {Object} Returns an Object to use with dangerouslySetInnerHTML
* with the rendered markdown HTML
*/
-function tspanTextWrapper(texts) {
+export function tspanTextWrapper(texts) {
return (
{
@@ -20,7 +20,3 @@ function tspanTextWrapper(texts) {
)
}
-
-export const EuiXYChartTextUtils = {
- tspanTextWrapper,
-}
diff --git a/src/components/xy_chart/xy_chart.js b/src/components/xy_chart/xy_chart.js
index 1e33fbcba9d8..a368e24142b1 100644
--- a/src/components/xy_chart/xy_chart.js
+++ b/src/components/xy_chart/xy_chart.js
@@ -9,7 +9,7 @@ import { EuiCrosshairY } from './crosshairs/crosshair_y';
import { VISUALIZATION_COLORS } from '../../services';
import StatusText from './status-text';
import { getSeriesChildren } from './utils/series_utils';
-import { EuiXYChartUtils } from './utils/chart_utils';
+import { ORIENTATION } from './utils/chart_utils';
class XYExtendedPlot extends XYPlot {
/**
@@ -96,7 +96,7 @@ class XYChart extends PureComponent {
}
this.colorIterator = 0;
- const Crosshair = orientation === EuiXYChartUtils.ORIENTATION.HORIZONTAL
+ const Crosshair = orientation === ORIENTATION.HORIZONTAL
? EuiCrosshairY
: EuiCrosshairX
return (
@@ -168,7 +168,7 @@ XYChart.defaultProps = {
xPadding: 0,
truncateLegends: false,
showCrosshair: true,
- orientation: EuiXYChartUtils.ORIENTATION.VERTICAL,
+ orientation: ORIENTATION.VERTICAL,
showDefaultAxis: true,
};
From 6d2dc6c029c94ff543db5902a028501e75ff3672 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Wed, 20 Jun 2018 11:46:58 +0200
Subject: [PATCH 26/68] Revert "Refactoring exporting for utils"
This reverts commit 3340a4341a5649b342f0af57150e3ed4c534d0c6.
---
src/components/xy_chart/axis/default_axis.js | 6 +++---
src/components/xy_chart/axis/x_axis.js | 4 +++-
src/components/xy_chart/axis/y_axis.js | 4 +++-
src/components/xy_chart/utils/axis_utils.js | 12 +++++++++---
src/components/xy_chart/utils/chart_utils.js | 7 ++++++-
src/components/xy_chart/utils/index.js | 6 +++---
src/components/xy_chart/utils/text_utils.js | 6 +++++-
src/components/xy_chart/xy_chart.js | 6 +++---
8 files changed, 35 insertions(+), 16 deletions(-)
diff --git a/src/components/xy_chart/axis/default_axis.js b/src/components/xy_chart/axis/default_axis.js
index e241092c2e9f..32658f164995 100644
--- a/src/components/xy_chart/axis/default_axis.js
+++ b/src/components/xy_chart/axis/default_axis.js
@@ -4,7 +4,7 @@ import { EuiXAxis } from './x_axis';
import { EuiYAxis } from './y_axis';
import { EuiHorizontalGrid } from './horizontal_grid';
import { EuiVerticalGrid } from './vertical_grid';
-import { ORIENTATION } from '../utils/chart_utils';
+import { EuiXYChartUtils } from '../utils/chart_utils';
export class EuiDefaultAxis extends PureComponent {
_getTickLabels(ticks) {
if (!ticks) return;
@@ -30,9 +30,9 @@ export class EuiDefaultAxis extends PureComponent {
return (
{showGridLines &&
- orientation === ORIENTATION.VERTICAL && }
+ orientation === EuiXYChartUtils.ORIENTATION.VERTICAL && }
{showGridLines &&
- orientation === ORIENTATION.HORIZONTAL && }
+ orientation === EuiXYChartUtils.ORIENTATION.HORIZONTAL && }
diff --git a/src/components/xy_chart/axis/x_axis.js b/src/components/xy_chart/axis/x_axis.js
index 5debb8524048..87eb2fbc911c 100644
--- a/src/components/xy_chart/axis/x_axis.js
+++ b/src/components/xy_chart/axis/x_axis.js
@@ -1,7 +1,9 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { XAxis } from 'react-vis';
-import { TITLE_POSITION, ORIENTATION } from '../utils/axis_utils';
+import { EuiXYChartAxisUtils } from '../utils/axis_utils';
+
+const { TITLE_POSITION, ORIENTATION } = EuiXYChartAxisUtils;
export class EuiXAxis extends PureComponent {
render() {
diff --git a/src/components/xy_chart/axis/y_axis.js b/src/components/xy_chart/axis/y_axis.js
index 0571f5d670bd..303438d3c302 100644
--- a/src/components/xy_chart/axis/y_axis.js
+++ b/src/components/xy_chart/axis/y_axis.js
@@ -1,7 +1,9 @@
import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { YAxis } from 'react-vis';
-import { TITLE_POSITION, ORIENTATION } from '../utils/axis_utils';
+import { EuiXYChartAxisUtils } from '../utils/axis_utils';
+
+const { TITLE_POSITION, ORIENTATION } = EuiXYChartAxisUtils;
export class EuiYAxis extends PureComponent {
render() {
diff --git a/src/components/xy_chart/utils/axis_utils.js b/src/components/xy_chart/utils/axis_utils.js
index d2c7ae161e31..3056e7324a3d 100644
--- a/src/components/xy_chart/utils/axis_utils.js
+++ b/src/components/xy_chart/utils/axis_utils.js
@@ -1,15 +1,21 @@
import { AxisUtils } from 'react-vis';
-export const ORIENTATION = AxisUtils.ORIENTATION;
+const ORIENTATION = AxisUtils.ORIENTATION;
-export const TITLE_POSITION = {
+const TITLE_POSITION = {
MIDDLE: 'middle',
START: 'start',
END: 'end',
};
-export const GRID_TYPE = {
+const GRID_TYPE = {
HORIZONTAL: 'horizontal',
VERTICAL: 'vertical',
BOTH: 'both',
};
+
+export const EuiXYChartAxisUtils = {
+ TITLE_POSITION,
+ GRID_TYPE,
+ ORIENTATION,
+};
diff --git a/src/components/xy_chart/utils/chart_utils.js b/src/components/xy_chart/utils/chart_utils.js
index 137b722dcfa5..c867d5634f66 100644
--- a/src/components/xy_chart/utils/chart_utils.js
+++ b/src/components/xy_chart/utils/chart_utils.js
@@ -1,4 +1,9 @@
-export const ORIENTATION = {
+const ORIENTATION = {
HORIZONTAL: 'horizontal',
VERTICAL: 'vertical',
+ BOTH: 'both',
};
+
+export const EuiXYChartUtils = {
+ ORIENTATION,
+}
diff --git a/src/components/xy_chart/utils/index.js b/src/components/xy_chart/utils/index.js
index c595eb93aba0..43f4f75eb290 100644
--- a/src/components/xy_chart/utils/index.js
+++ b/src/components/xy_chart/utils/index.js
@@ -1,3 +1,3 @@
-export * as EuiXYChartUtils from './chart_utils';
-export * as EuiXYChartAxisUtils from './axis_utils';
-export * as EuiXYChartTextUtils from './text_utils';
+export { EuiXYChartUtils } from './chart_utils';
+export { EuiXYChartAxisUtils } from './axis_utils';
+export { EuiXYChartTextUtils } from './text_utils';
diff --git a/src/components/xy_chart/utils/text_utils.js b/src/components/xy_chart/utils/text_utils.js
index 0d354a2d01f3..669b468cea00 100644
--- a/src/components/xy_chart/utils/text_utils.js
+++ b/src/components/xy_chart/utils/text_utils.js
@@ -7,7 +7,7 @@ import React from 'react'
* @return {Object} Returns an Object to use with dangerouslySetInnerHTML
* with the rendered markdown HTML
*/
-export function tspanTextWrapper(texts) {
+function tspanTextWrapper(texts) {
return (
{
@@ -20,3 +20,7 @@ export function tspanTextWrapper(texts) {
)
}
+
+export const EuiXYChartTextUtils = {
+ tspanTextWrapper,
+}
diff --git a/src/components/xy_chart/xy_chart.js b/src/components/xy_chart/xy_chart.js
index a368e24142b1..1e33fbcba9d8 100644
--- a/src/components/xy_chart/xy_chart.js
+++ b/src/components/xy_chart/xy_chart.js
@@ -9,7 +9,7 @@ import { EuiCrosshairY } from './crosshairs/crosshair_y';
import { VISUALIZATION_COLORS } from '../../services';
import StatusText from './status-text';
import { getSeriesChildren } from './utils/series_utils';
-import { ORIENTATION } from './utils/chart_utils';
+import { EuiXYChartUtils } from './utils/chart_utils';
class XYExtendedPlot extends XYPlot {
/**
@@ -96,7 +96,7 @@ class XYChart extends PureComponent {
}
this.colorIterator = 0;
- const Crosshair = orientation === ORIENTATION.HORIZONTAL
+ const Crosshair = orientation === EuiXYChartUtils.ORIENTATION.HORIZONTAL
? EuiCrosshairY
: EuiCrosshairX
return (
@@ -168,7 +168,7 @@ XYChart.defaultProps = {
xPadding: 0,
truncateLegends: false,
showCrosshair: true,
- orientation: ORIENTATION.VERTICAL,
+ orientation: EuiXYChartUtils.ORIENTATION.VERTICAL,
showDefaultAxis: true,
};
From ea322ab592fb39a22d03dcca9232eac40205768b Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Wed, 20 Jun 2018 12:02:53 +0200
Subject: [PATCH 27/68] Fix missing y crosshair on horizontal histogram
---
.../xy_chart/crosshairs/crosshair_y.js | 3 +--
src/components/xy_chart/xy_chart.js | 27 +++++--------------
2 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/src/components/xy_chart/crosshairs/crosshair_y.js b/src/components/xy_chart/crosshairs/crosshair_y.js
index 5da006d3dc04..4ec718ae80d6 100644
--- a/src/components/xy_chart/crosshairs/crosshair_y.js
+++ b/src/components/xy_chart/crosshairs/crosshair_y.js
@@ -109,7 +109,7 @@ export class EuiCrosshairY extends AbstractSeries {
if (typeof item.y0 === 'number') {
// we need to compute the scaled y0 using the xScale attribute functor
// we don't have access of the y0 attribute functor
- const y0Coord = yScaleFn({ x: item.y0 });
+ const y0Coord = yScaleFn({ y: item.y0 });
itemYCoords = (yCoord - y0Coord) / 2 + y0Coord;
} else {
itemYCoords = yCoord;
@@ -132,7 +132,6 @@ export class EuiCrosshairY extends AbstractSeries {
};
})
.filter(d => d);
-
// filter and map nearest X data per dataseries to get only the nearet onces
const crosshairValues = nearestYData
.filter(value => value.minDistance === globalMinDistance)
diff --git a/src/components/xy_chart/xy_chart.js b/src/components/xy_chart/xy_chart.js
index 1e33fbcba9d8..9d6fe91a36e9 100644
--- a/src/components/xy_chart/xy_chart.js
+++ b/src/components/xy_chart/xy_chart.js
@@ -30,7 +30,6 @@ class XYExtendedPlot extends XYPlot {
}
});
}
-
}
class XYChart extends PureComponent {
@@ -59,7 +58,7 @@ class XYChart extends PureComponent {
}
return React.cloneElement(child, props);
- }
+ };
// canShowCrosshair = () => {
// const { crosshairValue, showCrosshair } = this.props;
// const { mouseOver } = this.state;
@@ -90,15 +89,13 @@ class XYChart extends PureComponent {
...rest
} = this.props;
-
if (!children || errorText) {
return ;
}
this.colorIterator = 0;
- const Crosshair = orientation === EuiXYChartUtils.ORIENTATION.HORIZONTAL
- ? EuiCrosshairY
- : EuiCrosshairX
+ const Crosshair =
+ orientation === EuiXYChartUtils.ORIENTATION.HORIZONTAL ? EuiCrosshairY : EuiCrosshairX;
return (
-
{React.Children.map(children, this._renderChildren)}
- {
- showDefaultAxis &&
- }
- { showCrosshair && (
-
+ {showDefaultAxis && }
+ {showCrosshair && (
+
)}
{onSelectEnd && }
@@ -153,10 +144,7 @@ XYChart.propTypes = {
truncateLegends: PropTypes.bool,
errorText: PropTypes.string,
showCrosshair: PropTypes.bool,
- crosshairValue: PropTypes.oneOfType([
- PropTypes.string,
- PropTypes.number
- ]),
+ crosshairValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
onCrosshairUpdate: PropTypes.func,
showDefaultAxis: PropTypes.bool,
};
@@ -170,7 +158,6 @@ XYChart.defaultProps = {
showCrosshair: true,
orientation: EuiXYChartUtils.ORIENTATION.VERTICAL,
showDefaultAxis: true,
-
};
export const EuiXYChart = makeWidthFlexible(XYChart);
From 5458ec3f093e50b840822055be70905e46ee36ff Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Wed, 20 Jun 2018 14:38:35 +0200
Subject: [PATCH 28/68] Fix time histogram example to be stacked
---
src-docs/src/views/xy_chart_histogram/time_histogram_series.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src-docs/src/views/xy_chart_histogram/time_histogram_series.js b/src-docs/src/views/xy_chart_histogram/time_histogram_series.js
index c1f3b73959af..cb118b5421e1 100644
--- a/src-docs/src/views/xy_chart_histogram/time_histogram_series.js
+++ b/src-docs/src/views/xy_chart_histogram/time_histogram_series.js
@@ -41,7 +41,7 @@ export default class Example extends Component {
-
+
{ data.map((d, i) => ( ))}
From 01728c7e266214704520a9ec0361145b6d8af47f Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Wed, 20 Jun 2018 15:36:29 +0200
Subject: [PATCH 29/68] Add propTypes docs on XYChart. Add correct displayName
to chart elements
---
.../src/views/xy_chart/xy_chart_example.js | 3 +-
.../__snapshots__/xy_chart.test.js.snap | 9 +-
src/components/xy_chart/axis/default_axis.js | 2 +
.../xy_chart/axis/horizontal_grid.js | 2 +
src/components/xy_chart/axis/vertical_grid.js | 2 +
src/components/xy_chart/axis/x_axis.js | 2 +
src/components/xy_chart/axis/y_axis.js | 2 +
.../xy_chart/crosshairs/crosshair_x.js | 2 +
.../xy_chart/crosshairs/crosshair_y.js | 2 +
src/components/xy_chart/highlight.js | 31 +-
.../__snapshots__/area_series.test.js.snap | 5520 ++++--------
.../__snapshots__/line_series.test.js.snap | 7568 +++++------------
src/components/xy_chart/series/area_series.js | 22 +-
src/components/xy_chart/series/bar_series.js | 2 +
.../xy_chart/series/horizontal_bar_series.js | 2 +
.../xy_chart/series/horizontal_rect_series.js | 2 +
src/components/xy_chart/series/line_series.js | 2 +
.../xy_chart/series/vertical_bar_series.js | 2 +
.../xy_chart/series/vertical_rect_series.js | 2 +
src/components/xy_chart/xy_chart.js | 43 +-
20 files changed, 3681 insertions(+), 9541 deletions(-)
diff --git a/src-docs/src/views/xy_chart/xy_chart_example.js b/src-docs/src/views/xy_chart/xy_chart_example.js
index 83eef010042e..72bebc96c362 100644
--- a/src-docs/src/views/xy_chart/xy_chart_example.js
+++ b/src-docs/src/views/xy_chart/xy_chart_example.js
@@ -1,6 +1,6 @@
import React from 'react';
import { GuideSectionTypes } from '../../components';
-import { EuiCode } from '../../../../src/components';
+import { EuiCode, EuiXYChart } from '../../../../src/components';
import ComplexChartExampleCode from './complex';
import EmptyExampleCode from './empty';
import MultiAxisChartExampleCode from './multi_axis';
@@ -20,6 +20,7 @@ export const XYChartExample = {
),
+ props: { EuiXYChart },
source: [
{
type: GuideSectionTypes.JS,
diff --git a/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap b/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
index 9448aa715908..4fe4d0374efe 100644
--- a/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
@@ -40,7 +40,7 @@ exports[`EuiXYChart is rendered (empty) 1`] = `
`;
exports[`EuiXYChart passes handler functions 1`] = `
-
-
-
+
-
+
`;
diff --git a/src/components/xy_chart/axis/default_axis.js b/src/components/xy_chart/axis/default_axis.js
index 32658f164995..22752510cd3e 100644
--- a/src/components/xy_chart/axis/default_axis.js
+++ b/src/components/xy_chart/axis/default_axis.js
@@ -41,6 +41,8 @@ export class EuiDefaultAxis extends PureComponent {
}
}
+EuiDefaultAxis.displayName = 'EuiDefaultAxis';
+
EuiDefaultAxis.propTypes = {
orientation: PropTypes.string,
showGridLines: PropTypes.bool,
diff --git a/src/components/xy_chart/axis/horizontal_grid.js b/src/components/xy_chart/axis/horizontal_grid.js
index 4fa5f211a8a9..1caa0d5e9ae6 100644
--- a/src/components/xy_chart/axis/horizontal_grid.js
+++ b/src/components/xy_chart/axis/horizontal_grid.js
@@ -17,4 +17,6 @@ export class EuiHorizontalGrid extends PureComponent {
}
}
+EuiHorizontalGrid.displayName = 'EuiHorizontalGrid';
+
EuiHorizontalGrid.requiresSVG = true;
diff --git a/src/components/xy_chart/axis/vertical_grid.js b/src/components/xy_chart/axis/vertical_grid.js
index b8106b87a0ae..6869f8bc06e6 100644
--- a/src/components/xy_chart/axis/vertical_grid.js
+++ b/src/components/xy_chart/axis/vertical_grid.js
@@ -17,4 +17,6 @@ export class EuiVerticalGrid extends PureComponent {
}
}
+EuiVerticalGrid.displayName = 'EuiVerticalGrid';
+
EuiVerticalGrid.requiresSVG = true;
diff --git a/src/components/xy_chart/axis/x_axis.js b/src/components/xy_chart/axis/x_axis.js
index 87eb2fbc911c..d282b15745bd 100644
--- a/src/components/xy_chart/axis/x_axis.js
+++ b/src/components/xy_chart/axis/x_axis.js
@@ -35,6 +35,8 @@ export class EuiXAxis extends PureComponent {
}
}
+EuiXAxis.displayName = 'EuiXAxis';
+
EuiXAxis.propTypes = {
title: PropTypes.string, /** The axis title */
/** The axis title position */
diff --git a/src/components/xy_chart/axis/y_axis.js b/src/components/xy_chart/axis/y_axis.js
index 303438d3c302..3188278b657e 100644
--- a/src/components/xy_chart/axis/y_axis.js
+++ b/src/components/xy_chart/axis/y_axis.js
@@ -34,6 +34,8 @@ export class EuiYAxis extends PureComponent {
}
}
+EuiYAxis.displayName = 'EuiYAxis';
+
EuiYAxis.propTypes = {
title: PropTypes.string,
titlePosition: PropTypes.oneOf([TITLE_POSITION.START, TITLE_POSITION.MIDDLE, TITLE_POSITION.END]),
diff --git a/src/components/xy_chart/crosshairs/crosshair_x.js b/src/components/xy_chart/crosshairs/crosshair_x.js
index 839bed5a7022..ab6c68062b40 100644
--- a/src/components/xy_chart/crosshairs/crosshair_x.js
+++ b/src/components/xy_chart/crosshairs/crosshair_x.js
@@ -172,6 +172,8 @@ export class EuiCrosshairX extends AbstractSeries {
}
}
+EuiCrosshairX.displayName = 'EuiCrosshairX';
+
EuiCrosshairX.propTypes = {
... AbstractSeries.propTypes,
crosshairValue: PropTypes.oneOfType([
diff --git a/src/components/xy_chart/crosshairs/crosshair_y.js b/src/components/xy_chart/crosshairs/crosshair_y.js
index 4ec718ae80d6..650a4a2ba961 100644
--- a/src/components/xy_chart/crosshairs/crosshair_y.js
+++ b/src/components/xy_chart/crosshairs/crosshair_y.js
@@ -169,3 +169,5 @@ export class EuiCrosshairY extends AbstractSeries {
)
}
}
+
+EuiCrosshairY.displayName = 'EuiCrosshairY';
diff --git a/src/components/xy_chart/highlight.js b/src/components/xy_chart/highlight.js
index 3d29900f7920..bf24a0c4a2ba 100644
--- a/src/components/xy_chart/highlight.js
+++ b/src/components/xy_chart/highlight.js
@@ -1,17 +1,17 @@
import React from 'react';
import { ScaleUtils, AbstractSeries } from 'react-vis';
-export default class Highlight extends AbstractSeries {
- static displayName = 'HighlightOverlay';
+export class EuiHighlight extends AbstractSeries {
+ static displayName = 'EuiHighlightOverlay';
static defaultProps = {
allow: 'x',
color: 'rgb(0,0, 0)',
- opacity: 0.2
+ opacity: 0.2,
};
state = {
drawing: false,
drawArea: { top: 0, right: 0, bottom: 0, left: 0 },
- startLoc: 0
+ startLoc: 0,
};
_getDrawArea(loc) {
@@ -22,14 +22,14 @@ export default class Highlight extends AbstractSeries {
return {
...drawArea,
left: Math.max(loc, 0),
- right: startLoc
+ right: startLoc,
};
}
return {
...drawArea,
right: Math.min(loc, innerWidth),
- left: startLoc
+ left: startLoc,
};
}
@@ -43,9 +43,9 @@ export default class Highlight extends AbstractSeries {
top: 0,
right: location,
bottom: innerHeight,
- left: location
+ left: location,
},
- startLoc: location
+ startLoc: location,
});
if (onSelectStart) {
@@ -67,7 +67,7 @@ export default class Highlight extends AbstractSeries {
this.setState({
drawing: false,
drawArea: { top: 0, right: 0, bottom: 0, left: 0 },
- startLoc: 0
+ startLoc: 0,
});
// Don't invoke the callback if the selected area was < 5px.
@@ -79,7 +79,7 @@ export default class Highlight extends AbstractSeries {
// Compute the corresponding domain drawn
const domainArea = {
end: xScale.invert(drawArea.right),
- begin: xScale.invert(drawArea.left)
+ begin: xScale.invert(drawArea.left),
};
if (onSelectEnd) {
@@ -88,6 +88,7 @@ export default class Highlight extends AbstractSeries {
}
onParentMouseMove(e) {
+ e.preventDefault();
const { marginLeft, onSelect } = this.props;
const { drawing } = this.state;
const loc = e.nativeEvent.offsetX - marginLeft;
@@ -113,7 +114,15 @@ export default class Highlight extends AbstractSeries {
onMouseUp={() => this.stopDrawing()}
onMouseLeave={() => this.stopDrawing()}
>
-
+
@@ -13,13 +13,12 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
}
}
>
-
-
-
-
-
-
-
-
-
+ transform="translate(2,2)"
+ />
-
+
-
-
+
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+ }
+ x1={0}
+ x2={596}
+ y1={19.599999999999994}
+ y2={19.599999999999994}
+ />
+
@@ -1504,7 +895,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
colorDomain={Array []}
colorRange={
Array [
@@ -1612,7 +1003,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
attr="x"
attrAxis="y"
colorDomain={Array []}
@@ -1722,7 +1113,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
attr="x"
attrAxis="y"
className=""
@@ -1816,723 +1207,453 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
}
yType="linear"
>
-
-
-
+
+
+
-
+
-
-
-
+
+
+
+
-
-
-
-
- 0.0
-
-
-
-
-
- 0.1
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.3
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.5
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.7
-
-
-
-
-
- 0.8
-
-
-
-
-
- 0.9
-
-
-
-
-
- 1.0
-
-
-
-
+ 0.1
+
-
-
-
-
-
-
-
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
-
+
-
-
-
+
+
+
+
+ 12
+
+
+
+
+
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
- 14
-
-
-
-
+ 14
+
-
-
-
+
+
+
-
-
+
-
+
-
+
`;
exports[`EuiAreaSeries is rendered 1`] = `
-
-
-
-
+
-
-
-
-
-
-
+ transform="translate(2,2)"
+ />
-
+
-
+
-
+
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+ }
+ x1={0}
+ x2={596}
+ y1={19.599999999999994}
+ y2={19.599999999999994}
+ />
+
@@ -5111,7 +3363,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
colorDomain={Array []}
colorRange={
Array [
@@ -5219,7 +3471,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
attr="x"
attrAxis="y"
colorDomain={Array []}
@@ -5329,7 +3581,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
attr="x"
attrAxis="y"
className=""
@@ -5423,685 +3675,415 @@ exports[`EuiAreaSeries is rendered 1`] = `
}
yType="linear"
>
-
-
-
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
-
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
-
-
-
+
+
+
+
-
-
-
-
- 0.0
-
-
-
-
-
- 0.1
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.3
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.5
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.7
-
-
-
-
-
- 0.8
-
-
-
-
-
- 0.9
-
-
-
-
-
- 1.0
-
-
-
-
+ 1.0
+
-
-
-
+
+
+
@@ -6124,7 +4106,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
colorDomain={Array []}
colorRange={
Array [
@@ -6232,7 +4214,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
attr="y"
attrAxis="x"
colorDomain={Array []}
@@ -6342,7 +4324,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
attr="y"
attrAxis="x"
className=""
@@ -6436,547 +4418,277 @@ exports[`EuiAreaSeries is rendered 1`] = `
}
yType="linear"
>
-
-
-
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
-
+
-
-
-
+
+
+
+
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
- 14
-
-
-
-
+ 14
+
-
-
-
+
+
+
-
-
+
-
+
-
+
`;
diff --git a/src/components/xy_chart/series/__snapshots__/line_series.test.js.snap b/src/components/xy_chart/series/__snapshots__/line_series.test.js.snap
index e790219d711c..454b97f4db4c 100644
--- a/src/components/xy_chart/series/__snapshots__/line_series.test.js.snap
+++ b/src/components/xy_chart/series/__snapshots__/line_series.test.js.snap
@@ -1,7 +1,7 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`EuiLineSeries all props are rendered 1`] = `
-
@@ -13,13 +13,12 @@ exports[`EuiLineSeries all props are rendered 1`] = `
}
}
>
-
-
-
-
-
-
-
-
-
+ transform="translate(2,2)"
+ />
-
-
-
-
-
-
-
+ transform="translate(2,2)"
+ />
-
-
+
-
-
-
-
-
-
-
-
+ />
+
-
+
-
-
+
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+ }
+ x1={0}
+ x2={596}
+ y1={19.599999999999994}
+ y2={19.599999999999994}
+ />
+
@@ -2510,7 +1233,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
colorDomain={Array []}
colorRange={
Array [
@@ -2618,7 +1341,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
attr="x"
attrAxis="y"
colorDomain={Array []}
@@ -2728,7 +1451,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
attr="x"
attrAxis="y"
className=""
@@ -2822,748 +1545,478 @@ exports[`EuiLineSeries all props are rendered 1`] = `
}
yType="linear"
>
-
-
-
+
+
+
-
+
-
-
-
+
+
+
+
-
-
-
-
- 0.0
-
-
-
-
-
- 0.1
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.3
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.5
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.7
-
-
-
-
-
- 0.8
-
-
-
-
-
- 0.9
-
-
-
-
-
- 1.0
-
-
-
-
+ 0.1
+
-
-
-
-
-
-
-
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
+
+
+
+
+
-
-
-
+
+
-
-
-
-
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
- 14
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
+
+
+
+
+
+
+
-
+
-
+
-
+
`;
exports[`EuiLineSeries is rendered 1`] = `
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+ Object {
+ "x": 0,
+ "y": 5,
+ },
+ Object {
+ "x": 1,
+ "y": 15,
+ },
+ ]
+ }
+ fillDomain={Array []}
+ fillRange={
+ Array [
+ "#EF5D28",
+ "#FF9833",
+ ]
+ }
+ getAngle={[Function]}
+ getAngle0={[Function]}
+ getColor={[Function]}
+ getColor0={[Function]}
+ getFill={[Function]}
+ getFill0={[Function]}
+ getNull={[Function]}
+ getOpacity={[Function]}
+ getOpacity0={[Function]}
+ getRadius={[Function]}
+ getRadius0={[Function]}
+ getSize={[Function]}
+ getSize0={[Function]}
+ getStroke={[Function]}
+ getStroke0={[Function]}
+ getX={[Function]}
+ getX0={[Function]}
+ getY={[Function]}
+ getY0={[Function]}
+ id="chart-0"
+ innerHeight={196}
+ innerWidth={596}
+ key="test-border"
+ marginBottom={2}
+ marginLeft={2}
+ marginRight={2}
+ marginTop={2}
+ opacity={1}
+ opacityDomain={Array []}
+ opacityType="literal"
+ radiusDomain={Array []}
+ sameTypeIndex={0}
+ sameTypeTotal={1}
+ seriesIndex={0}
+ sizeDomain={Array []}
+ sizeRange={
+ Array [
+ 1,
+ 10,
+ ]
+ }
+ stack={false}
+ strokeDomain={Array []}
+ strokeRange={
+ Array [
+ "#EF5D28",
+ "#FF9833",
+ ]
+ }
+ strokeStyle="solid"
+ style={
+ Object {
+ "strokeWidth": 4,
+ }
+ }
+ xDomain={
+ Array [
+ 0,
+ 1,
+ ]
+ }
+ xPadding={0}
+ xRange={
+ Array [
+ 0,
+ 596,
+ ]
+ }
+ xType="linear"
+ yDomain={
+ Array [
+ 5,
+ 15,
+ ]
+ }
+ yPadding={0}
+ yRange={
+ Array [
+ 196,
+ 0,
+ ]
+ }
+ yType="linear"
+ >
+
-
-
+
+
+
-
+
-
-
-
-
-
-
-
-
+ />
+
-
+
-
+
-
+
-
+
+
+
-
-
-
-
-
-
-
-
-
-
+ }
+ x1={0}
+ x2={596}
+ y1={19.599999999999994}
+ y2={19.599999999999994}
+ />
+
@@ -7124,7 +4040,7 @@ exports[`EuiLineSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
colorDomain={Array []}
colorRange={
Array [
@@ -7232,7 +4148,7 @@ exports[`EuiLineSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
attr="x"
attrAxis="y"
colorDomain={Array []}
@@ -7342,7 +4258,7 @@ exports[`EuiLineSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
attr="x"
attrAxis="y"
className=""
@@ -7436,685 +4352,415 @@ exports[`EuiLineSeries is rendered 1`] = `
}
yType="linear"
>
-
-
-
+
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
-
+
-
-
-
+
+
+
+
-
-
-
-
- 0.0
-
-
-
-
-
- 0.1
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.3
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.5
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.7
-
-
-
-
-
- 0.8
-
-
-
-
-
- 0.9
-
-
-
-
-
- 1.0
-
-
-
-
+ 1.0
+
-
-
-
+
+
+
@@ -8137,7 +4783,7 @@ exports[`EuiLineSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
colorDomain={Array []}
colorRange={
Array [
@@ -8245,7 +4891,7 @@ exports[`EuiLineSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
attr="y"
attrAxis="x"
colorDomain={Array []}
@@ -8355,7 +5001,7 @@ exports[`EuiLineSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={true}
+ animation={null}
attr="y"
attrAxis="x"
className=""
@@ -8449,547 +5095,277 @@ exports[`EuiLineSeries is rendered 1`] = `
}
yType="linear"
>
-
-
-
+
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
-
+
-
-
-
+
+
+
+
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
- 14
-
-
-
-
+ 14
+
-
-
-
+
+
+
-
-
+
-
+
-
+
`;
diff --git a/src/components/xy_chart/series/area_series.js b/src/components/xy_chart/series/area_series.js
index 1154832c184b..b9c0327835c4 100644
--- a/src/components/xy_chart/series/area_series.js
+++ b/src/components/xy_chart/series/area_series.js
@@ -21,27 +21,23 @@ export class EuiAreaSeries extends AbstractSeries {
);
}
}
-
+EuiAreaSeries.displayName = 'EuiAreaSeries';
EuiAreaSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
name: PropTypes.string.isRequired,
/** Array<{x: string|number, y: string|number}> */
- data: PropTypes.arrayOf(PropTypes.shape({
- x: PropTypes.oneOfType([
- PropTypes.string,
- PropTypes.number
- ]),
- y: PropTypes.oneOfType([
- PropTypes.string,
- PropTypes.number
- ]),
- })).isRequired,
+ data: PropTypes.arrayOf(
+ PropTypes.shape({
+ x: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
+ y: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
+ })
+ ).isRequired,
/** Without a color set, a random EUI color palette color will be chosen */
color: PropTypes.string,
curve: PropTypes.string,
onClick: PropTypes.func,
- onMarkClick: PropTypes.func
-}
+ onMarkClick: PropTypes.func,
+};
EuiAreaSeries.defaultProps = {
curve: 'linear',
diff --git a/src/components/xy_chart/series/bar_series.js b/src/components/xy_chart/series/bar_series.js
index d853f5e4ae86..a1ab8fac6d8e 100644
--- a/src/components/xy_chart/series/bar_series.js
+++ b/src/components/xy_chart/series/bar_series.js
@@ -25,6 +25,8 @@ export class EuiBarSeries extends AbstractSeries {
}
}
+EuiBarSeries.displayName = 'EuiBarSeries';
+
EuiBarSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
name: PropTypes.string.isRequired,
diff --git a/src/components/xy_chart/series/horizontal_bar_series.js b/src/components/xy_chart/series/horizontal_bar_series.js
index 0c4003815874..03287c5255e0 100644
--- a/src/components/xy_chart/series/horizontal_bar_series.js
+++ b/src/components/xy_chart/series/horizontal_bar_series.js
@@ -26,6 +26,8 @@ export class EuiHorizontalBarSeries extends HorizontalBarSeries {
}
}
+EuiHorizontalBarSeries.displayName = 'EuiHorizontalBarSeries';
+
EuiHorizontalBarSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
name: PropTypes.string.isRequired,
diff --git a/src/components/xy_chart/series/horizontal_rect_series.js b/src/components/xy_chart/series/horizontal_rect_series.js
index 102f0ee119ed..623ee20ee494 100644
--- a/src/components/xy_chart/series/horizontal_rect_series.js
+++ b/src/components/xy_chart/series/horizontal_rect_series.js
@@ -26,6 +26,8 @@ export class EuiHorizontalRectSeries extends HorizontalRectSeries {
}
}
+EuiHorizontalRectSeries.displayName = 'EuiHorizontalRectSeries';
+
EuiHorizontalRectSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
name: PropTypes.string.isRequired,
diff --git a/src/components/xy_chart/series/line_series.js b/src/components/xy_chart/series/line_series.js
index 5fab14dceeec..08fc2e7ac5cc 100644
--- a/src/components/xy_chart/series/line_series.js
+++ b/src/components/xy_chart/series/line_series.js
@@ -68,6 +68,8 @@ export class EuiLineSeries extends AbstractSeries {
}
}
+EuiLineSeries.displayName = 'EuiLineSeries';
+
EuiLineSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
name: PropTypes.string.isRequired,
diff --git a/src/components/xy_chart/series/vertical_bar_series.js b/src/components/xy_chart/series/vertical_bar_series.js
index f0c5cd78d181..fd6a6e26fd3e 100644
--- a/src/components/xy_chart/series/vertical_bar_series.js
+++ b/src/components/xy_chart/series/vertical_bar_series.js
@@ -26,6 +26,8 @@ export class EuiVerticalBarSeries extends VerticalBarSeries {
}
}
+EuiVerticalBarSeries.displayName = 'EuiVerticalBarSeries';
+
EuiVerticalBarSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
name: PropTypes.string.isRequired,
diff --git a/src/components/xy_chart/series/vertical_rect_series.js b/src/components/xy_chart/series/vertical_rect_series.js
index 81cdb8bf87d3..37bc50bed85b 100644
--- a/src/components/xy_chart/series/vertical_rect_series.js
+++ b/src/components/xy_chart/series/vertical_rect_series.js
@@ -27,6 +27,8 @@ export class EuiVerticalRectSeries extends VerticalRectSeries {
}
}
+EuiVerticalRectSeries.displayName = 'EuiVerticalRectSeries';
+
EuiVerticalRectSeries.propTypes = {
/** The name used to define the data in tooltips and ledgends */
name: PropTypes.string.isRequired,
diff --git a/src/components/xy_chart/xy_chart.js b/src/components/xy_chart/xy_chart.js
index 9d6fe91a36e9..1815622711ac 100644
--- a/src/components/xy_chart/xy_chart.js
+++ b/src/components/xy_chart/xy_chart.js
@@ -1,8 +1,8 @@
import React, { PureComponent } from 'react';
-import { XYPlot, makeWidthFlexible, AbstractSeries } from 'react-vis';
+import { XYPlot, makeVisFlexible, AbstractSeries } from 'react-vis';
import PropTypes from 'prop-types';
-import Highlight from './highlight';
+import { EuiHighlight } from './highlight';
import { EuiDefaultAxis } from './axis/default_axis';
import { EuiCrosshairX } from './crosshairs/crosshair_x';
import { EuiCrosshairY } from './crosshairs/crosshair_y';
@@ -10,6 +10,7 @@ import { VISUALIZATION_COLORS } from '../../services';
import StatusText from './status-text';
import { getSeriesChildren } from './utils/series_utils';
import { EuiXYChartUtils } from './utils/chart_utils';
+const { HORIZONTAL, VERTICAL } = EuiXYChartUtils.ORIENTATION
class XYExtendedPlot extends XYPlot {
/**
@@ -79,13 +80,12 @@ class XYChart extends PureComponent {
yDomain,
yPadding,
xPadding,
- animation, // eslint-disable-line no-unused-vars
+ animation,
showDefaultAxis,
showCrosshair,
orientation,
crosshairValue,
- onCrosshairUpdate, // eslint-disable-line no-unused-vars
- truncateLegends, // eslint-disable-line no-unused-vars
+ onCrosshairUpdate,
...rest
} = this.props;
@@ -104,7 +104,7 @@ class XYChart extends PureComponent {
onMouseMove={this._onMouseMove}
onMouseLeave={this._onMouseLeave}
width={width}
- animation={true}
+ animation={animation}
height={height}
margin={2}
xType={xType}
@@ -121,43 +121,64 @@ class XYChart extends PureComponent {
)}
- {onSelectEnd && }
+ {onSelectEnd && }
);
}
}
+XYChart.displayName = 'EuiXYChart';
XYChart.propTypes = {
+ /** The initial width of the chart. */
width: PropTypes.number.isRequired,
+ /** The initial height of the chart. */
height: PropTypes.number.isRequired,
- orientation: PropTypes.string,
+ /** The orientation of the chart. */
+ orientation: PropTypes.oneOf([ HORIZONTAL, VERTICAL ]),
+ /** If the chart animates on data changes. */
+ animation: PropTypes.bool,
+ /** TODO */
stackBy: PropTypes.string,
+ /** The main x axis scale type. */
xType: PropTypes.string,
+ /** The main y axis scale type. */
yType: PropTypes.string,
+ /** Manually specify the domain of x axis. */
xDomain: PropTypes.array,
+ /** Manually specify the domain of y axis. */
yDomain: PropTypes.array,
+ /** The horizontal padding between the chart borders and chart elements. */
xPadding: PropTypes.number,
+ /** The vertical padding between the chart borders and chart elements. */
yPadding: PropTypes.number,
+ /** TODO */
onHover: PropTypes.func,
+ /** Activate the brush tool and callback on brush end event. */
onSelectEnd: PropTypes.func,
+ /** TODO */
truncateLegends: PropTypes.bool,
+ /** TODO */
errorText: PropTypes.string,
+ /** Shows the crosshair tooltip on mouse move.*/
showCrosshair: PropTypes.bool,
+ /** Specify an X or Y axis value to display a crosshair. */
crosshairValue: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
+ /** Callback when the crosshair position is updated. */
onCrosshairUpdate: PropTypes.func,
+ /** Show the default X and Y axis. */
showDefaultAxis: PropTypes.bool,
};
XYChart.defaultProps = {
+ animation: true,
xType: 'linear',
yType: 'linear',
yPadding: 0,
xPadding: 0,
- truncateLegends: false,
- showCrosshair: true,
orientation: EuiXYChartUtils.ORIENTATION.VERTICAL,
+ showCrosshair: true,
showDefaultAxis: true,
};
-export const EuiXYChart = makeWidthFlexible(XYChart);
+export const EuiXYChart = makeVisFlexible(XYChart);
From d84f645ac35497d34e001a1664019e24352a37cc Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Wed, 20 Jun 2018 19:28:59 +0200
Subject: [PATCH 30/68] Renamed highlight to brush. Add vertical, horizontal
and both orientation of Brush.
---
src-docs/src/views/xy_chart/complex.js | 118 +++++++-----
.../__snapshots__/xy_chart.test.js.snap | 6 +-
src/components/xy_chart/brush.js | 173 ++++++++++++++++++
src/components/xy_chart/highlight.js | 139 --------------
.../__snapshots__/area_series.test.js.snap | 6 +
.../__snapshots__/line_series.test.js.snap | 6 +
src/components/xy_chart/xy_chart.js | 23 ++-
src/components/xy_chart/xy_chart.test.js | 2 +-
8 files changed, 274 insertions(+), 199 deletions(-)
create mode 100644 src/components/xy_chart/brush.js
delete mode 100644 src/components/xy_chart/highlight.js
diff --git a/src-docs/src/views/xy_chart/complex.js b/src-docs/src/views/xy_chart/complex.js
index 508a02bcf6a5..ac7a89269232 100644
--- a/src-docs/src/views/xy_chart/complex.js
+++ b/src-docs/src/views/xy_chart/complex.js
@@ -1,64 +1,82 @@
-import React from 'react';
+import React, { Fragment, Component } from 'react';
import {
+ EuiCodeBlock,
+ EuiSpacer,
EuiXYChart,
+ EuiXYChartUtils,
EuiVerticalBarSeries,
EuiAreaSeries,
EuiLineSeries,
} from '../../../../src/components';
-export default () => {
+const barData = [];
+for (let i = 0; i < 10; i++) {
+ const data = [];
- const barData = [];
- for (let i = 0; i < 10; i++) {
- const data = [];
+ for (let i = 0; i < 20; i++) {
+ data.push({ x: i, y: Number(Math.random().toFixed(2)) });
+ }
- for (let i = 0; i < 20; i++) {
- data.push({ x: i, y: Number(Math.random().toFixed(2)) });
- }
+ barData.push(data);
+}
- barData.push(data);
+export default class ComplexDemo extends Component {
+ state = {
+ brushOutput: 'Please drag your mouse to select an area'
}
-
- return (
- {
- alert('selection ended with an area :) Check console to see it');
- console.log(area);
- }}
- width={600}
- height={200}
- >
- {
- alert('clicked!');
- }}
- data={[
- { x: 0, y: 0 },
- { x: 1, y: 2 },
- { x: 2, y: 1 },
- { x: 3, y: 2 },
- { x: 4, y: 1 },
- { x: 10, y: 1 },
- { x: 20, y: 2 },
- ]}
- />
- {barData
- .slice(0, 1)
- .map((data, index) => (
- {
+ this.setState(() => ({
+ brushOutput: JSON.stringify(area, null, 2),
+ }));
+ }
+ render() {
+ const { brushOutput } = this.state
+ return (
+
+
+ {brushOutput}
+
+
+
+ {
+ alert('clicked!');
+ }}
+ data={[
+ { x: 0, y: 0 },
+ { x: 1, y: 2 },
+ { x: 2, y: 1 },
+ { x: 3, y: 2 },
+ { x: 4, y: 1 },
+ { x: 10, y: 1 },
+ { x: 20, y: 2 },
+ ]}
/>
- ))}
-
-
- );
+ {barData
+ .slice(0, 1)
+ .map((data, index) => (
+
+ ))}
+
+
+
+ );
+ }
};
diff --git a/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap b/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
index 4fe4d0374efe..7be629b8a635 100644
--- a/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
@@ -42,9 +42,9 @@ exports[`EuiXYChart is rendered (empty) 1`] = `
exports[`EuiXYChart passes handler functions 1`] = `
({
+ drawing: true,
+ ...drawAndRectAreas,
+ }));
+
+ if (onSelectStart) {
+ onSelectStart(e);
+ }
+ }
+
+ onParentMouseMove(e) {
+ const { onSelect } = this.props;
+ const { drawing } = this.state;
+ const { offsetX, offsetY } = e.nativeEvent;
+
+ if (drawing) {
+ const drawAndRectAreas = this._getDrawArea(offsetX, offsetY);
+ this.setState(() => ({ ...drawAndRectAreas }));
+
+ if (onSelect) {
+ onSelect(e);
+ }
+ }
+ }
+
+ stopDrawing = () => {
+ // Quickly short-circuit if the user isn't drawing in our component
+ if (!this.state.drawing) {
+ return;
+ }
+
+ const { onBrushEnd } = this.props;
+ const { x0, y0, x1, y1 } = this.state.drawArea;
+ const xScale = ScaleUtils.getAttributeScale(this.props, 'x');
+ const yScale = ScaleUtils.getAttributeScale(this.props, 'y');
+
+ // Clear the draw area
+ this.setState(() => ({
+ drawing: false,
+ ...DEFAULT_AREAS,
+ }));
+ // Don't invoke the callback if the selected area was < 5px.
+ // This is a click not a select
+ if (Math.abs(x0 - x1) < 5 || Math.abs(y0 - y1) < 5) {
+ return;
+ }
+
+ // Compute the corresponding domain drawn
+ const domainArea = {
+ startX: xScale.invert(x0 < x1 ? x0 : x1),
+ endX: xScale.invert(x0 < x1 ? x1 : x0),
+ startY: yScale.invert(y0 < y1 ? y1 : y0),
+ endY: yScale.invert(y0 < y1 ? y0 : y1),
+ };
+
+ if (onBrushEnd) {
+ onBrushEnd(domainArea);
+ }
+ }
+
+ render() {
+ const { marginLeft, marginTop, innerWidth, innerHeight, color, opacity } = this.props;
+ const { rectArea: { x, y, width, height } } = this.state;
+
+ return (
+
+
+
+
+ );
+ }
+}
+
+EuiBrush.displayName = 'EuiBrush';
+
+EuiBrush.propTypes = {
+ /** Specify the brush orientation */
+ orientation: PropTypes.oneOf([ HORIZONTAL, VERTICAL, BOTH ]),
+ /** Callback on brush end event with { begin, end } object returned. */
+ onBrushEnd: PropTypes.func.isRequired,
+ color: PropTypes.string,
+ opacity: PropTypes.number,
+};
+
+EuiBrush.defaultProps = {
+ orientation: HORIZONTAL,
+ color: 'rgb(0,0, 0)',
+ opacity: 0.2,
+}
diff --git a/src/components/xy_chart/highlight.js b/src/components/xy_chart/highlight.js
deleted file mode 100644
index bf24a0c4a2ba..000000000000
--- a/src/components/xy_chart/highlight.js
+++ /dev/null
@@ -1,139 +0,0 @@
-import React from 'react';
-import { ScaleUtils, AbstractSeries } from 'react-vis';
-
-export class EuiHighlight extends AbstractSeries {
- static displayName = 'EuiHighlightOverlay';
- static defaultProps = {
- allow: 'x',
- color: 'rgb(0,0, 0)',
- opacity: 0.2,
- };
- state = {
- drawing: false,
- drawArea: { top: 0, right: 0, bottom: 0, left: 0 },
- startLoc: 0,
- };
-
- _getDrawArea(loc) {
- const { innerWidth } = this.props;
- const { drawArea, startLoc } = this.state;
-
- if (loc < startLoc) {
- return {
- ...drawArea,
- left: Math.max(loc, 0),
- right: startLoc,
- };
- }
-
- return {
- ...drawArea,
- right: Math.min(loc, innerWidth),
- left: startLoc,
- };
- }
-
- onParentMouseDown(e) {
- const { marginLeft, innerHeight, onSelectStart } = this.props;
- const location = e.nativeEvent.offsetX - marginLeft;
-
- this.setState({
- drawing: true,
- drawArea: {
- top: 0,
- right: location,
- bottom: innerHeight,
- left: location,
- },
- startLoc: location,
- });
-
- if (onSelectStart) {
- onSelectStart(e);
- }
- }
-
- stopDrawing() {
- // Quickly short-circuit if the user isn't drawing in our component
- if (!this.state.drawing) {
- return;
- }
-
- const { onSelectEnd } = this.props;
- const { drawArea } = this.state;
- const xScale = ScaleUtils.getAttributeScale(this.props, 'x');
-
- // Clear the draw area
- this.setState({
- drawing: false,
- drawArea: { top: 0, right: 0, bottom: 0, left: 0 },
- startLoc: 0,
- });
-
- // Don't invoke the callback if the selected area was < 5px.
- // This is a click not a select
- if (Math.abs(drawArea.right - drawArea.left) < 5) {
- return;
- }
-
- // Compute the corresponding domain drawn
- const domainArea = {
- end: xScale.invert(drawArea.right),
- begin: xScale.invert(drawArea.left),
- };
-
- if (onSelectEnd) {
- onSelectEnd(domainArea);
- }
- }
-
- onParentMouseMove(e) {
- e.preventDefault();
- const { marginLeft, onSelect } = this.props;
- const { drawing } = this.state;
- const loc = e.nativeEvent.offsetX - marginLeft;
-
- if (drawing) {
- const newDrawArea = this._getDrawArea(loc);
- this.setState({ drawArea: newDrawArea });
-
- if (onSelect) {
- onSelect(e);
- }
- }
- }
-
- render() {
- const { marginLeft, marginTop, innerWidth, innerHeight, color, opacity } = this.props;
- const { drawArea: { left, right, top, bottom } } = this.state;
-
- return (
- this.stopDrawing()}
- onMouseLeave={() => this.stopDrawing()}
- >
-
-
-
- );
- }
-}
diff --git a/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap b/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap
index 6c18140b1f74..d9e472cf5317 100644
--- a/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap
+++ b/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap
@@ -15,8 +15,11 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
>
)}
- {onSelectEnd && }
+ {showBrush && }
);
@@ -154,8 +156,6 @@ XYChart.propTypes = {
yPadding: PropTypes.number,
/** TODO */
onHover: PropTypes.func,
- /** Activate the brush tool and callback on brush end event. */
- onSelectEnd: PropTypes.func,
/** TODO */
truncateLegends: PropTypes.bool,
/** TODO */
@@ -168,6 +168,12 @@ XYChart.propTypes = {
onCrosshairUpdate: PropTypes.func,
/** Show the default X and Y axis. */
showDefaultAxis: PropTypes.bool,
+ /** Enable the brush tool */
+ showBrush: PropTypes.bool,
+ /** Specify the brush orientation */
+ brushOrientation: PropTypes.oneOf([ HORIZONTAL, VERTICAL, BOTH ]),
+ /** Callback on brush end event with { begin, end } object returned. */
+ onBrushEnd: PropTypes.func,
};
XYChart.defaultProps = {
@@ -176,9 +182,12 @@ XYChart.defaultProps = {
yType: 'linear',
yPadding: 0,
xPadding: 0,
- orientation: EuiXYChartUtils.ORIENTATION.VERTICAL,
+ orientation: VERTICAL,
showCrosshair: true,
showDefaultAxis: true,
+ showBrush: false,
+ brushOrientation: HORIZONTAL,
+ onBrushEnd: () => ({}),
};
export const EuiXYChart = makeVisFlexible(XYChart);
diff --git a/src/components/xy_chart/xy_chart.test.js b/src/components/xy_chart/xy_chart.test.js
index 28715c9933be..f04e8a0f2c00 100644
--- a/src/components/xy_chart/xy_chart.test.js
+++ b/src/components/xy_chart/xy_chart.test.js
@@ -26,7 +26,7 @@ describe('EuiXYChart', () => {
height={200}
onHover={() => {}}
onMouseLeave={() => {}}
- onSelectEnd={() => {}}
+ onBrushEnd={() => {}}
yTicks={[[0, 'zero'], [100, 'one hundred']]}
xTicks={[[0, 'zero', 5, 'five'], [10, '10']]}
/>
From 4408a0858dc719bad7dbebf61e3994ce34d962b9 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Thu, 21 Jun 2018 14:51:38 +0200
Subject: [PATCH 31/68] Fix Axis example rotation to a useful one
---
src-docs/src/views/xy_chart_axis/simple_axis.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src-docs/src/views/xy_chart_axis/simple_axis.js b/src-docs/src/views/xy_chart_axis/simple_axis.js
index 13d0bb90d3c8..b511a85b3069 100644
--- a/src-docs/src/views/xy_chart_axis/simple_axis.js
+++ b/src-docs/src/views/xy_chart_axis/simple_axis.js
@@ -33,7 +33,7 @@ export default () => (
title="Top X Axis"
titlePosition={EuiXYChartAxisUtils.TITLE_POSITION.END}
orientation={EuiXYChartAxisUtils.ORIENTATION.TOP}
- tickLabelAngle={-180}
+ tickLabelAngle={-45}
/>
);
From e523c42acee9c4ea26348d60d33393e6b43b9257 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Thu, 21 Jun 2018 14:58:31 +0200
Subject: [PATCH 32/68] Fix xType and yType propTypes
---
src/components/xy_chart/utils/chart_utils.js | 11 +++++++++++
src/components/xy_chart/xy_chart.js | 17 +++++++++++++----
2 files changed, 24 insertions(+), 4 deletions(-)
diff --git a/src/components/xy_chart/utils/chart_utils.js b/src/components/xy_chart/utils/chart_utils.js
index c867d5634f66..c616052edf24 100644
--- a/src/components/xy_chart/utils/chart_utils.js
+++ b/src/components/xy_chart/utils/chart_utils.js
@@ -4,6 +4,17 @@ const ORIENTATION = {
BOTH: 'both',
};
+const SCALE_TYPE = {
+ LINEAR: 'linear',
+ ORDINAL: 'ordinal',
+ CATEGORY: 'category',
+ TIME: 'time',
+ TIME_UTC: 'time-utc',
+ LOG: 'log',
+ LITERA: 'literal'
+};
+
export const EuiXYChartUtils = {
ORIENTATION,
+ SCALE_TYPE,
}
diff --git a/src/components/xy_chart/xy_chart.js b/src/components/xy_chart/xy_chart.js
index 269ef62ae77f..5da029f921eb 100644
--- a/src/components/xy_chart/xy_chart.js
+++ b/src/components/xy_chart/xy_chart.js
@@ -11,6 +11,15 @@ import StatusText from './status-text';
import { getSeriesChildren } from './utils/series_utils';
import { EuiXYChartUtils } from './utils/chart_utils';
const { HORIZONTAL, VERTICAL, BOTH } = EuiXYChartUtils.ORIENTATION
+const {
+ LINEAR,
+ ORDINAL,
+ CATEGORY,
+ TIME,
+ TIME_UTC,
+ LOG,
+ LITERAL,
+} = EuiXYChartUtils.SCALE_TYPE;
class XYExtendedPlot extends XYPlot {
/**
@@ -142,10 +151,10 @@ XYChart.propTypes = {
animation: PropTypes.bool,
/** TODO */
stackBy: PropTypes.string,
- /** The main x axis scale type. */
- xType: PropTypes.string,
- /** The main y axis scale type. */
- yType: PropTypes.string,
+ /** The main x axis scale type. See https://github.com/uber/react-vis/blob/master/docs/scales-and-data.md */
+ xType: PropTypes.oneOf([ LINEAR, ORDINAL, CATEGORY, TIME, TIME_UTC, LOG, LITERAL ]),
+ /** The main y axis scale type. See https://github.com/uber/react-vis/blob/master/docs/scales-and-data.md*/
+ xType: PropTypes.oneOf([ LINEAR, ORDINAL, CATEGORY, TIME, TIME_UTC, LOG, LITERAL ]),
/** Manually specify the domain of x axis. */
xDomain: PropTypes.array,
/** Manually specify the domain of y axis. */
From 5aa901893ca48bb2d6d8977b6d454fc9f343e6be Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Thu, 21 Jun 2018 15:00:04 +0200
Subject: [PATCH 33/68] Removed unused functions getTicks and getTicksLabels
from default_axis
---
src/components/xy_chart/axis/default_axis.js | 18 ------------------
1 file changed, 18 deletions(-)
diff --git a/src/components/xy_chart/axis/default_axis.js b/src/components/xy_chart/axis/default_axis.js
index 22752510cd3e..e41658eb4cd1 100644
--- a/src/components/xy_chart/axis/default_axis.js
+++ b/src/components/xy_chart/axis/default_axis.js
@@ -6,24 +6,6 @@ import { EuiHorizontalGrid } from './horizontal_grid';
import { EuiVerticalGrid } from './vertical_grid';
import { EuiXYChartUtils } from '../utils/chart_utils';
export class EuiDefaultAxis extends PureComponent {
- _getTickLabels(ticks) {
- if (!ticks) return;
-
- return ticks.map(v => {
- return v[1];
- });
- }
-
- _getTicks(ticks) {
- if (!ticks) return;
-
- {
- return ticks.map(v => {
- return v[0];
- });
- }
- }
-
render() {
const { showGridLines, orientation, ...rest } = this.props;
From 092f97071baf62445e5aa9b5dbe3858f1b67f38e Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Thu, 21 Jun 2018 15:01:45 +0200
Subject: [PATCH 34/68] Removed unneccessary tspan for a better Fragment on
tspanTextWrapper
---
src/components/xy_chart/utils/text_utils.js | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/src/components/xy_chart/utils/text_utils.js b/src/components/xy_chart/utils/text_utils.js
index 669b468cea00..520cce7a8201 100644
--- a/src/components/xy_chart/utils/text_utils.js
+++ b/src/components/xy_chart/utils/text_utils.js
@@ -1,4 +1,4 @@
-import React from 'react'
+import React, { Fragment } from 'react'
/**
* Simplified version of tspan wrapper that takes an array of Strings.
@@ -9,7 +9,7 @@ import React from 'react'
*/
function tspanTextWrapper(texts) {
return (
-
+
{
texts.map((piece, i) => {
return (
@@ -17,7 +17,7 @@ function tspanTextWrapper(texts) {
)
})
}
-
+
)
}
From 71216ce7f22e9621c4f4ce47dd2bf05c6916e571 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Fri, 22 Jun 2018 12:26:19 +0200
Subject: [PATCH 35/68] Removed showLine from line_series
---
.../__snapshots__/line_series.test.js.snap | 2 -
src/components/xy_chart/series/line_series.js | 49 ++++++++-----------
2 files changed, 21 insertions(+), 30 deletions(-)
diff --git a/src/components/xy_chart/series/__snapshots__/line_series.test.js.snap b/src/components/xy_chart/series/__snapshots__/line_series.test.js.snap
index d1356432caeb..b79629e92333 100644
--- a/src/components/xy_chart/series/__snapshots__/line_series.test.js.snap
+++ b/src/components/xy_chart/series/__snapshots__/line_series.test.js.snap
@@ -160,7 +160,6 @@ exports[`EuiLineSeries all props are rendered 1`] = `
sameTypeIndex={0}
sameTypeTotal={1}
seriesIndex={0}
- showLine={true}
showLineMarks={true}
sizeDomain={Array []}
sizeRange={
@@ -2975,7 +2974,6 @@ exports[`EuiLineSeries is rendered 1`] = `
sameTypeIndex={0}
sameTypeTotal={1}
seriesIndex={0}
- showLine={true}
showLineMarks={true}
sizeDomain={Array []}
sizeRange={
diff --git a/src/components/xy_chart/series/line_series.js b/src/components/xy_chart/series/line_series.js
index 08fc2e7ac5cc..bb35fd066428 100644
--- a/src/components/xy_chart/series/line_series.js
+++ b/src/components/xy_chart/series/line_series.js
@@ -11,7 +11,6 @@ export class EuiLineSeries extends AbstractSeries {
curve,
onClick,
onMarkClick,
- showLine,
showLineMarks,
lineSize,
lineMarkColor,
@@ -22,33 +21,29 @@ export class EuiLineSeries extends AbstractSeries {
return (
- {showLine &&
-
- }
- {showLine &&
-
+
- }
+ }}
+ color={color}
+ />
{showLineMarks && (
Date: Fri, 22 Jun 2018 12:31:40 +0200
Subject: [PATCH 36/68] Renamed on0 to onZero props for axis components
---
src/components/xy_chart/axis/default_axis.js | 12 +++++++-----
src/components/xy_chart/axis/x_axis.js | 10 +++++-----
src/components/xy_chart/axis/y_axis.js | 8 ++++----
.../series/__snapshots__/area_series.test.js.snap | 12 ++++++++----
.../series/__snapshots__/line_series.test.js.snap | 12 ++++++++----
5 files changed, 32 insertions(+), 22 deletions(-)
diff --git a/src/components/xy_chart/axis/default_axis.js b/src/components/xy_chart/axis/default_axis.js
index e41658eb4cd1..a641de774a9e 100644
--- a/src/components/xy_chart/axis/default_axis.js
+++ b/src/components/xy_chart/axis/default_axis.js
@@ -7,7 +7,7 @@ import { EuiVerticalGrid } from './vertical_grid';
import { EuiXYChartUtils } from '../utils/chart_utils';
export class EuiDefaultAxis extends PureComponent {
render() {
- const { showGridLines, orientation, ...rest } = this.props;
+ const { showGridLines, orientation, xOnZero, yOnZero, ...rest } = this.props;
return (
@@ -16,8 +16,8 @@ export class EuiDefaultAxis extends PureComponent {
{showGridLines &&
orientation === EuiXYChartUtils.ORIENTATION.HORIZONTAL && }
-
-
+
+
);
}
@@ -28,13 +28,15 @@ EuiDefaultAxis.displayName = 'EuiDefaultAxis';
EuiDefaultAxis.propTypes = {
orientation: PropTypes.string,
showGridLines: PropTypes.bool,
- yOn0: PropTypes.bool,
- xOn0: PropTypes.bool,
+ yOnZero: PropTypes.bool,
+ xOnZero: PropTypes.bool,
};
EuiDefaultAxis.defaultProps = {
orientation: false,
showGridLines: true,
+ xOnZero: false,
+ yOnZero: false,
};
EuiDefaultAxis.requiresSVG = true;
diff --git a/src/components/xy_chart/axis/x_axis.js b/src/components/xy_chart/axis/x_axis.js
index d282b15745bd..7196f91c620a 100644
--- a/src/components/xy_chart/axis/x_axis.js
+++ b/src/components/xy_chart/axis/x_axis.js
@@ -15,7 +15,7 @@ export class EuiXAxis extends PureComponent {
tickLabelAngle,
tickFormat,
tickValues,
- on0,
+ onZero,
...rest
} = this.props;
return (
@@ -23,7 +23,7 @@ export class EuiXAxis extends PureComponent {
title={title}
position={titlePosition}
orientation={orientation}
- on0={on0}
+ on0={onZero}
tickSize={tickSize}
tickFormat={tickFormat}
tickValues={tickValues}
@@ -51,7 +51,7 @@ EuiXAxis.propTypes = {
ORIENTATION.BOTTOM,
]),
/** Fix the axis at zero value */
- on0: PropTypes.bool,
+ onZero: PropTypes.bool,
/** An array of ticks values */
ticks: PropTypes.array,
/** The height of the ticks in pixels */
@@ -65,10 +65,10 @@ EuiXAxis.propTypes = {
};
EuiXAxis.defaultProps = {
- on0: false,
+ onZero: false,
titlePosition: TITLE_POSITION.MIDDLE,
orientation: ORIENTATION.BOTTOM,
tickSize: 5,
-}
+};
EuiXAxis.requiresSVG = true;
diff --git a/src/components/xy_chart/axis/y_axis.js b/src/components/xy_chart/axis/y_axis.js
index 3188278b657e..f02da946ab22 100644
--- a/src/components/xy_chart/axis/y_axis.js
+++ b/src/components/xy_chart/axis/y_axis.js
@@ -15,7 +15,7 @@ export class EuiYAxis extends PureComponent {
tickLabelAngle,
tickFormat,
tickValues,
- on0,
+ onZero,
...rest
} = this.props;
return (
@@ -23,7 +23,7 @@ export class EuiYAxis extends PureComponent {
title={title}
position={titlePosition}
orientation={orientation}
- on0={on0}
+ on0={onZero}
tickSize={tickSize}
tickFormat={tickFormat}
tickValues={tickValues}
@@ -40,7 +40,7 @@ EuiYAxis.propTypes = {
title: PropTypes.string,
titlePosition: PropTypes.oneOf([TITLE_POSITION.START, TITLE_POSITION.MIDDLE, TITLE_POSITION.END]),
orientation: PropTypes.oneOf([ORIENTATION.LEFT, ORIENTATION.RIGHT]),
- on0: PropTypes.bool,
+ onZero: PropTypes.bool,
ticks: PropTypes.array,
tickSize: PropTypes.number,
tickValues: PropTypes.array,
@@ -49,7 +49,7 @@ EuiYAxis.propTypes = {
};
EuiYAxis.defaultProps = {
- on0: false,
+ onZero: false,
titlePosition: TITLE_POSITION.MIDDLE,
orientation: ORIENTATION.LEFT,
tickSize: 5,
diff --git a/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap b/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap
index d9e472cf5317..a0a5f5a7a71f 100644
--- a/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap
+++ b/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap
@@ -450,6 +450,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
1,
]
}
+ xOnZero={false}
xPadding={0}
xRange={
Array [
@@ -464,6 +465,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
15,
]
}
+ yOnZero={false}
yPadding={0}
yRange={
Array [
@@ -937,7 +939,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
marginLeft={2}
marginRight={2}
marginTop={2}
- on0={false}
+ onZero={false}
opacityDomain={Array []}
opacityType="literal"
orientation="bottom"
@@ -1680,7 +1682,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
marginLeft={2}
marginRight={2}
marginTop={2}
- on0={false}
+ onZero={false}
opacityDomain={Array []}
opacityType="literal"
orientation="left"
@@ -2921,6 +2923,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
1,
]
}
+ xOnZero={false}
xPadding={0}
xRange={
Array [
@@ -2935,6 +2938,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
15,
]
}
+ yOnZero={false}
yPadding={0}
yRange={
Array [
@@ -3408,7 +3412,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
marginLeft={2}
marginRight={2}
marginTop={2}
- on0={false}
+ onZero={false}
opacityDomain={Array []}
opacityType="literal"
orientation="bottom"
@@ -4151,7 +4155,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
marginLeft={2}
marginRight={2}
marginTop={2}
- on0={false}
+ onZero={false}
opacityDomain={Array []}
opacityType="literal"
orientation="left"
diff --git a/src/components/xy_chart/series/__snapshots__/line_series.test.js.snap b/src/components/xy_chart/series/__snapshots__/line_series.test.js.snap
index b79629e92333..d2ad5ed71ade 100644
--- a/src/components/xy_chart/series/__snapshots__/line_series.test.js.snap
+++ b/src/components/xy_chart/series/__snapshots__/line_series.test.js.snap
@@ -787,6 +787,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
1,
]
}
+ xOnZero={false}
xPadding={0}
xRange={
Array [
@@ -801,6 +802,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
15,
]
}
+ yOnZero={false}
yPadding={0}
yRange={
Array [
@@ -1274,7 +1276,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
marginLeft={2}
marginRight={2}
marginTop={2}
- on0={false}
+ onZero={false}
opacityDomain={Array []}
opacityType="literal"
orientation="bottom"
@@ -2017,7 +2019,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
marginLeft={2}
marginRight={2}
marginTop={2}
- on0={false}
+ onZero={false}
opacityDomain={Array []}
opacityType="literal"
orientation="left"
@@ -3596,6 +3598,7 @@ exports[`EuiLineSeries is rendered 1`] = `
1,
]
}
+ xOnZero={false}
xPadding={0}
xRange={
Array [
@@ -3610,6 +3613,7 @@ exports[`EuiLineSeries is rendered 1`] = `
15,
]
}
+ yOnZero={false}
yPadding={0}
yRange={
Array [
@@ -4083,7 +4087,7 @@ exports[`EuiLineSeries is rendered 1`] = `
marginLeft={2}
marginRight={2}
marginTop={2}
- on0={false}
+ onZero={false}
opacityDomain={Array []}
opacityType="literal"
orientation="bottom"
@@ -4826,7 +4830,7 @@ exports[`EuiLineSeries is rendered 1`] = `
marginLeft={2}
marginRight={2}
marginTop={2}
- on0={false}
+ onZero={false}
opacityDomain={Array []}
opacityType="literal"
orientation="left"
From 7ffb5a0e31270268dd9f728079437ef1474d52da Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Fri, 22 Jun 2018 13:31:43 +0200
Subject: [PATCH 37/68] Renamed EuiBrush to EuiSelectionBrush
---
src/components/xy_chart/brush.js | 12 ++++++------
src/components/xy_chart/xy_chart.js | 4 ++--
2 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/src/components/xy_chart/brush.js b/src/components/xy_chart/brush.js
index b234ed9c664a..c298f66d62e1 100644
--- a/src/components/xy_chart/brush.js
+++ b/src/components/xy_chart/brush.js
@@ -19,7 +19,7 @@ const DEFAULT_AREAS = {
}
};
-export class EuiBrush extends AbstractSeries {
+export class EuiSelectionBrush extends AbstractSeries {
state = {
drawing: false,
...DEFAULT_AREAS,
@@ -127,7 +127,7 @@ export class EuiBrush extends AbstractSeries {
return (
@@ -141,7 +141,7 @@ export class EuiBrush extends AbstractSeries {
height={innerHeight}
/>
)}
- {showBrush && }
+ {showBrush && }
);
From 20171ee75eea534463e880de46627af0dedbf214 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Fri, 22 Jun 2018 13:33:39 +0200
Subject: [PATCH 38/68] Renamed prop animation to animateData in XYChart
---
.../__snapshots__/xy_chart.test.js.snap | 1 +
.../__snapshots__/area_series.test.js.snap | 5257 +++++++++----
.../__snapshots__/line_series.test.js.snap | 6847 +++++++++++++----
src/components/xy_chart/xy_chart.js | 8 +-
4 files changed, 9016 insertions(+), 3097 deletions(-)
diff --git a/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap b/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
index 7be629b8a635..a55843cacf67 100644
--- a/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
@@ -82,6 +82,7 @@ exports[`EuiXYChart passes handler functions 1`] = `
}
>
-
+
-
+ xDomain={
+ Array [
+ 0,
+ 1,
+ ]
+ }
+ xPadding={0}
+ xRange={
+ Array [
+ 0,
+ 596,
+ ]
+ }
+ xType="linear"
+ yDomain={
+ Array [
+ 5,
+ 15,
+ ]
+ }
+ yPadding={0}
+ yRange={
+ Array [
+ 196,
+ 0,
+ ]
+ }
+ yType="linear"
+ >
+
+
+
+
+
+
@@ -385,7 +733,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
colorDomain={Array []}
colorRange={
Array [
@@ -494,7 +842,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
colorDomain={Array []}
colorRange={
Array [
@@ -598,7 +946,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="y"
colorDomain={Array []}
colorRange={
@@ -710,7 +1058,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="y"
colorDomain={Array []}
colorRange={
@@ -803,81 +1151,344 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
}
yType="linear"
>
-
-
-
-
-
+
-
-
+ >
+
+
+
+
+
+
+
+
+
+
+
@@ -900,7 +1511,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
colorDomain={Array []}
colorRange={
Array [
@@ -1008,7 +1619,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="x"
attrAxis="y"
colorDomain={Array []}
@@ -1118,7 +1729,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="x"
attrAxis="y"
className=""
@@ -1212,415 +1823,685 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
}
yType="linear"
>
-
-
-
-
-
-
-
-
- 0.0
-
-
-
-
-
- 0.1
-
-
-
-
-
- 0.2
-
-
-
-
+
+
-
- 0.3
-
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
-
-
-
- 0.4
-
-
-
-
-
- 0.5
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.7
-
-
-
-
-
- 0.8
-
-
-
-
-
- 0.9
-
-
-
-
-
- 1.0
-
-
-
-
-
+
+
+
@@ -1643,7 +2524,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
colorDomain={Array []}
colorRange={
Array [
@@ -1751,7 +2632,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="y"
attrAxis="x"
colorDomain={Array []}
@@ -1861,7 +2742,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="y"
attrAxis="x"
className=""
@@ -1955,271 +2836,541 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
}
yType="linear"
>
-
-
-
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
+
+
- 14
-
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
-
-
-
+
+
+
@@ -2246,7 +3397,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
_colorValue="#79C7E3"
_opacityValue={1}
angleDomain={Array []}
- animation={null}
+ animation={true}
clusters={
Set {
undefined,
@@ -2361,7 +3512,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
_colorValue="#79C7E3"
_opacityValue={1}
angleDomain={Array []}
- animation={null}
+ animation={true}
clusters={
Set {
undefined,
@@ -2490,6 +3641,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
}
>
-
+ xDomain={
+ Array [
+ 0,
+ 1,
+ ]
+ }
+ xPadding={0}
+ xRange={
+ Array [
+ 0,
+ 596,
+ ]
+ }
+ xType="linear"
+ yDomain={
+ Array [
+ 5,
+ 15,
+ ]
+ }
+ yPadding={0}
+ yRange={
+ Array [
+ 196,
+ 0,
+ ]
+ }
+ yType="linear"
+ >
+
+
+
+
+
+
@@ -2858,7 +4346,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
colorDomain={Array []}
colorRange={
Array [
@@ -2967,7 +4455,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
colorDomain={Array []}
colorRange={
Array [
@@ -3071,7 +4559,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="y"
colorDomain={Array []}
colorRange={
@@ -3183,7 +4671,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="y"
colorDomain={Array []}
colorRange={
@@ -3276,81 +4764,344 @@ exports[`EuiAreaSeries is rendered 1`] = `
}
yType="linear"
>
-
-
-
-
-
+
-
-
+ >
+
+
+
+
+
+
+
+
+
+
+
@@ -3373,7 +5124,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
colorDomain={Array []}
colorRange={
Array [
@@ -3481,7 +5232,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="x"
attrAxis="y"
colorDomain={Array []}
@@ -3591,7 +5342,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="x"
attrAxis="y"
className=""
@@ -3685,415 +5436,685 @@ exports[`EuiAreaSeries is rendered 1`] = `
}
yType="linear"
>
-
-
-
-
-
-
-
-
- 0.0
-
-
-
-
-
- 0.1
-
-
-
-
-
+
+
- 0.2
-
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
-
-
-
- 0.3
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.5
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.7
-
-
-
-
-
- 0.8
-
-
-
-
-
- 0.9
-
-
-
-
-
- 1.0
-
-
-
-
-
+
+
+
@@ -4116,7 +6137,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
colorDomain={Array []}
colorRange={
Array [
@@ -4224,7 +6245,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="y"
attrAxis="x"
colorDomain={Array []}
@@ -4334,7 +6355,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="y"
attrAxis="x"
className=""
@@ -4428,271 +6449,541 @@ exports[`EuiAreaSeries is rendered 1`] = `
}
yType="linear"
>
-
-
-
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
-
+
+
- 14
-
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
-
-
-
+
+
+
@@ -4719,7 +7010,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
_colorValue="#79C7E3"
_opacityValue={1}
angleDomain={Array []}
- animation={null}
+ animation={true}
clusters={
Set {
undefined,
@@ -4834,7 +7125,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
_colorValue="#79C7E3"
_opacityValue={1}
angleDomain={Array []}
- animation={null}
+ animation={true}
clusters={
Set {
undefined,
diff --git a/src/components/xy_chart/series/__snapshots__/line_series.test.js.snap b/src/components/xy_chart/series/__snapshots__/line_series.test.js.snap
index d2ad5ed71ade..3e8f7c6dba4b 100644
--- a/src/components/xy_chart/series/__snapshots__/line_series.test.js.snap
+++ b/src/components/xy_chart/series/__snapshots__/line_series.test.js.snap
@@ -14,6 +14,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
}
>
-
+
-
+ xDomain={
+ Array [
+ 0,
+ 1,
+ ]
+ }
+ xPadding={0}
+ xRange={
+ Array [
+ 0,
+ 596,
+ ]
+ }
+ xType="linear"
+ yDomain={
+ Array [
+ 5,
+ 15,
+ ]
+ }
+ yPadding={0}
+ yRange={
+ Array [
+ 196,
+ 0,
+ ]
+ }
+ yType="linear"
+ >
+
+
+
+
+
+
-
-
-
+
+
+
+
+
+
+
+
-
-
-
-
+ >
+
+
+
+
+
+
+
+
@@ -722,7 +1738,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
colorDomain={Array []}
colorRange={
Array [
@@ -831,7 +1847,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
colorDomain={Array []}
colorRange={
Array [
@@ -935,7 +1951,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="y"
colorDomain={Array []}
colorRange={
@@ -1047,7 +2063,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="y"
colorDomain={Array []}
colorRange={
@@ -1140,81 +2156,344 @@ exports[`EuiLineSeries all props are rendered 1`] = `
}
yType="linear"
>
-
-
+
-
-
-
-
-
+ yType="linear"
+ >
+
+
+
+
+
+
+
+
+
+
@@ -1237,7 +2516,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
colorDomain={Array []}
colorRange={
Array [
@@ -1345,7 +2624,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="x"
attrAxis="y"
colorDomain={Array []}
@@ -1455,7 +2734,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="x"
attrAxis="y"
className=""
@@ -1532,432 +2811,702 @@ exports[`EuiLineSeries all props are rendered 1`] = `
0,
596,
]
- }
- xType="linear"
- yDomain={
- Array [
- 5,
- 15,
- ]
- }
- yPadding={0}
- yRange={
- Array [
- 196,
- 0,
- ]
- }
- yType="linear"
- >
-
-
-
-
-
-
-
-
-
- 0.0
-
-
-
-
-
- 0.1
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.3
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.5
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.7
-
-
-
-
-
- 0.8
-
-
+ }
+ xType="linear"
+ yDomain={
+ Array [
+ 5,
+ 15,
+ ]
+ }
+ yPadding={0}
+ yRange={
+ Array [
+ 196,
+ 0,
+ ]
+ }
+ yType="linear"
+ >
+
+
+
-
-
- 0.9
-
-
-
-
-
+
+
- 1.0
-
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
-
-
-
+
+
+
@@ -1980,7 +3529,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
colorDomain={Array []}
colorRange={
Array [
@@ -2088,7 +3637,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="y"
attrAxis="x"
colorDomain={Array []}
@@ -2198,7 +3747,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="y"
attrAxis="x"
className=""
@@ -2292,271 +3841,541 @@ exports[`EuiLineSeries all props are rendered 1`] = `
}
yType="linear"
>
-
-
-
-
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
+
-
-
- 12
-
-
-
-
-
+
+
- 14
-
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
-
-
-
+
+
+
@@ -2583,7 +4402,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
_colorValue="#79C7E3"
_opacityValue={1}
angleDomain={Array []}
- animation={null}
+ animation={true}
clusters={
Set {
undefined,
@@ -2698,7 +4517,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
_colorValue="#79C7E3"
_opacityValue={1}
angleDomain={Array []}
- animation={null}
+ animation={true}
clusters={
Set {
undefined,
@@ -2827,6 +4646,7 @@ exports[`EuiLineSeries is rendered 1`] = `
}
>
-
+ xDomain={
+ Array [
+ 0,
+ 1,
+ ]
+ }
+ xPadding={0}
+ xRange={
+ Array [
+ 0,
+ 596,
+ ]
+ }
+ xType="linear"
+ yDomain={
+ Array [
+ 5,
+ 15,
+ ]
+ }
+ yPadding={0}
+ yRange={
+ Array [
+ 196,
+ 0,
+ ]
+ }
+ yType="linear"
+ >
+
+
+
+
+
+
-
+ xDomain={
+ Array [
+ 0,
+ 1,
+ ]
+ }
+ xPadding={0}
+ xRange={
+ Array [
+ 0,
+ 596,
+ ]
+ }
+ xType="linear"
+ yDomain={
+ Array [
+ 5,
+ 15,
+ ]
+ }
+ yPadding={0}
+ yRange={
+ Array [
+ 196,
+ 0,
+ ]
+ }
+ yType="linear"
+ >
+
+
+
+
+
+
-
-
-
-
+ >
+
+
+
+
+
+
+
+
@@ -3533,7 +6357,7 @@ exports[`EuiLineSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
colorDomain={Array []}
colorRange={
Array [
@@ -3642,7 +6466,7 @@ exports[`EuiLineSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
colorDomain={Array []}
colorRange={
Array [
@@ -3746,7 +6570,7 @@ exports[`EuiLineSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="y"
colorDomain={Array []}
colorRange={
@@ -3858,7 +6682,7 @@ exports[`EuiLineSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="y"
colorDomain={Array []}
colorRange={
@@ -3951,81 +6775,344 @@ exports[`EuiLineSeries is rendered 1`] = `
}
yType="linear"
>
-
-
-
-
+
-
-
-
+ getAngle={[Function]}
+ getAngle0={[Function]}
+ getColor={[Function]}
+ getColor0={[Function]}
+ getFill={[Function]}
+ getFill0={[Function]}
+ getOpacity={[Function]}
+ getOpacity0={[Function]}
+ getRadius={[Function]}
+ getRadius0={[Function]}
+ getSize={[Function]}
+ getSize0={[Function]}
+ getStroke={[Function]}
+ getStroke0={[Function]}
+ getX={[Function]}
+ getX0={[Function]}
+ getY={[Function]}
+ getY0={[Function]}
+ innerHeight={196}
+ innerWidth={596}
+ marginBottom={2}
+ marginLeft={2}
+ marginRight={2}
+ marginTop={2}
+ opacityDomain={Array []}
+ opacityType="literal"
+ radiusDomain={Array []}
+ sizeDomain={Array []}
+ sizeRange={
+ Array [
+ 1,
+ 10,
+ ]
+ }
+ strokeDomain={Array []}
+ strokeRange={
+ Array [
+ "#EF5D28",
+ "#FF9833",
+ ]
+ }
+ style={
+ Object {
+ "strokeDasharray": "5 5",
+ "strokeOpacity": 0.3,
+ }
+ }
+ xDomain={
+ Array [
+ 0,
+ 1,
+ ]
+ }
+ xPadding={0}
+ xRange={
+ Array [
+ 0,
+ 596,
+ ]
+ }
+ xType="linear"
+ yDomain={
+ Array [
+ 5,
+ 15,
+ ]
+ }
+ yPadding={0}
+ yRange={
+ Array [
+ 196,
+ 0,
+ ]
+ }
+ yType="linear"
+ >
+
+
+
+
+
+
+
+
+
+
@@ -4048,7 +7135,7 @@ exports[`EuiLineSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
colorDomain={Array []}
colorRange={
Array [
@@ -4156,7 +7243,7 @@ exports[`EuiLineSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="x"
attrAxis="y"
colorDomain={Array []}
@@ -4266,7 +7353,7 @@ exports[`EuiLineSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="x"
attrAxis="y"
className=""
@@ -4360,415 +7447,685 @@ exports[`EuiLineSeries is rendered 1`] = `
}
yType="linear"
>
-
-
-
-
-
-
-
-
-
- 0.0
-
-
-
-
-
- 0.1
-
-
-
-
-
- 0.2
-
-
-
-
-
- 0.3
-
-
-
-
-
- 0.4
-
-
-
-
-
- 0.5
-
-
-
-
-
- 0.6
-
-
-
-
-
- 0.7
-
-
-
-
-
- 0.8
-
-
+ Object {
+ "x": 0,
+ "y": 5,
+ },
+ Object {
+ "x": 1,
+ "y": 15,
+ },
+ ],
+ undefined,
+ ]
+ }
+ angleDomain={Array []}
+ animatedProps={
+ Array [
+ "xRange",
+ "yRange",
+ "xDomain",
+ "yDomain",
+ "width",
+ "height",
+ "marginLeft",
+ "marginTop",
+ "marginRight",
+ "marginBottom",
+ "tickSize",
+ "tickTotal",
+ "tickSizeInner",
+ "tickSizeOuter",
+ ]
+ }
+ animation={true}
+ attr="x"
+ attrAxis="y"
+ className=""
+ colorDomain={Array []}
+ colorRange={
+ Array [
+ "#EF5D28",
+ "#FF9833",
+ ]
+ }
+ fillDomain={Array []}
+ fillRange={
+ Array [
+ "#EF5D28",
+ "#FF9833",
+ ]
+ }
+ getAngle={[Function]}
+ getAngle0={[Function]}
+ getColor={[Function]}
+ getColor0={[Function]}
+ getFill={[Function]}
+ getFill0={[Function]}
+ getOpacity={[Function]}
+ getOpacity0={[Function]}
+ getRadius={[Function]}
+ getRadius0={[Function]}
+ getSize={[Function]}
+ getSize0={[Function]}
+ getStroke={[Function]}
+ getStroke0={[Function]}
+ getX={[Function]}
+ getX0={[Function]}
+ getY={[Function]}
+ getY0={[Function]}
+ innerHeight={196}
+ innerWidth={596}
+ marginBottom={2}
+ marginLeft={2}
+ marginRight={2}
+ marginTop={2}
+ on0={false}
+ opacityDomain={Array []}
+ opacityType="literal"
+ orientation="bottom"
+ position="middle"
+ radiusDomain={Array []}
+ sizeDomain={Array []}
+ sizeRange={
+ Array [
+ 1,
+ 10,
+ ]
+ }
+ strokeDomain={Array []}
+ strokeRange={
+ Array [
+ "#EF5D28",
+ "#FF9833",
+ ]
+ }
+ style={Object {}}
+ tickPadding={8}
+ tickSize={0}
+ xDomain={
+ Array [
+ 0,
+ 1,
+ ]
+ }
+ xPadding={0}
+ xRange={
+ Array [
+ 0,
+ 596,
+ ]
+ }
+ xType="linear"
+ yDomain={
+ Array [
+ 5,
+ 15,
+ ]
+ }
+ yPadding={0}
+ yRange={
+ Array [
+ 196,
+ 0,
+ ]
+ }
+ yType="linear"
+ >
+
+
-
-
- 0.9
-
-
-
-
-
+
+
- 1.0
-
+
+
+
+
+ 0.0
+
+
+
+
+
+ 0.1
+
+
+
+
+
+ 0.2
+
+
+
+
+
+ 0.3
+
+
+
+
+
+ 0.4
+
+
+
+
+
+ 0.5
+
+
+
+
+
+ 0.6
+
+
+
+
+
+ 0.7
+
+
+
+
+
+ 0.8
+
+
+
+
+
+ 0.9
+
+
+
+
+
+ 1.0
+
+
+
+
-
-
-
+
+
+
@@ -4791,7 +8148,7 @@ exports[`EuiLineSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
colorDomain={Array []}
colorRange={
Array [
@@ -4899,7 +8256,7 @@ exports[`EuiLineSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="y"
attrAxis="x"
colorDomain={Array []}
@@ -5009,7 +8366,7 @@ exports[`EuiLineSeries is rendered 1`] = `
]
}
angleDomain={Array []}
- animation={null}
+ animation={true}
attr="y"
attrAxis="x"
className=""
@@ -5103,271 +8460,541 @@ exports[`EuiLineSeries is rendered 1`] = `
}
yType="linear"
>
-
-
-
-
-
-
-
-
- 6
-
-
-
-
-
- 8
-
-
-
-
-
- 10
-
-
-
-
-
- 12
-
-
-
-
+
+
-
- 14
-
+
+
+
+
+ 6
+
+
+
+
+
+ 8
+
+
+
+
+
+ 10
+
+
+
+
+
+ 12
+
+
+
+
+
+ 14
+
+
+
+
-
-
-
+
+
+
@@ -5394,7 +9021,7 @@ exports[`EuiLineSeries is rendered 1`] = `
_colorValue="#79C7E3"
_opacityValue={1}
angleDomain={Array []}
- animation={null}
+ animation={true}
clusters={
Set {
undefined,
@@ -5509,7 +9136,7 @@ exports[`EuiLineSeries is rendered 1`] = `
_colorValue="#79C7E3"
_opacityValue={1}
angleDomain={Array []}
- animation={null}
+ animation={true}
clusters={
Set {
undefined,
diff --git a/src/components/xy_chart/xy_chart.js b/src/components/xy_chart/xy_chart.js
index 039e13422603..a60974fd35e3 100644
--- a/src/components/xy_chart/xy_chart.js
+++ b/src/components/xy_chart/xy_chart.js
@@ -88,7 +88,7 @@ class XYChart extends PureComponent {
yDomain,
yPadding,
xPadding,
- animation,
+ animateData,
showDefaultAxis,
showCrosshair,
showBrush,
@@ -115,7 +115,7 @@ class XYChart extends PureComponent {
onMouseMove={this._onMouseMove}
onMouseLeave={this._onMouseLeave}
width={width}
- animation={animation}
+ animation={animateData}
height={height}
margin={2}
xType={xType}
@@ -148,7 +148,7 @@ XYChart.propTypes = {
/** The orientation of the chart. */
orientation: PropTypes.oneOf([ HORIZONTAL, VERTICAL ]),
/** If the chart animates on data changes. */
- animation: PropTypes.bool,
+ animateData: PropTypes.bool,
/** TODO */
stackBy: PropTypes.string,
/** The main x axis scale type. See https://github.com/uber/react-vis/blob/master/docs/scales-and-data.md */
@@ -186,7 +186,7 @@ XYChart.propTypes = {
};
XYChart.defaultProps = {
- animation: true,
+ animateData: true,
xType: 'linear',
yType: 'linear',
yPadding: 0,
From fb5431f1cd90038d5cc684eb0ced0e8301698ad2 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Fri, 22 Jun 2018 13:39:24 +0200
Subject: [PATCH 39/68] Renamed selection brush props on XYChart
---
src-docs/src/views/xy_chart/complex.js | 8 ++++----
.../__snapshots__/xy_chart.test.js.snap | 5 +++--
.../__snapshots__/area_series.test.js.snap | 12 +++++------
.../__snapshots__/line_series.test.js.snap | 12 +++++------
src/components/xy_chart/xy_chart.js | 20 +++++++++----------
5 files changed, 29 insertions(+), 28 deletions(-)
diff --git a/src-docs/src/views/xy_chart/complex.js b/src-docs/src/views/xy_chart/complex.js
index ac7a89269232..313f0b3c182c 100644
--- a/src-docs/src/views/xy_chart/complex.js
+++ b/src-docs/src/views/xy_chart/complex.js
@@ -25,7 +25,7 @@ export default class ComplexDemo extends Component {
state = {
brushOutput: 'Please drag your mouse to select an area'
}
- onHandleBrushEnd = (area) => {
+ handleSelectionBrushEnd = (area) => {
this.setState(() => ({
brushOutput: JSON.stringify(area, null, 2),
}));
@@ -39,9 +39,9 @@ export default class ComplexDemo extends Component {
diff --git a/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap b/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
index a55843cacf67..f591f58618f2 100644
--- a/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
@@ -84,13 +84,14 @@ exports[`EuiXYChart passes handler functions 1`] = `
)}
- {showBrush && }
+ {enableSelectionBrush && }
);
@@ -178,11 +178,11 @@ XYChart.propTypes = {
/** Show the default X and Y axis. */
showDefaultAxis: PropTypes.bool,
/** Enable the brush tool */
- showBrush: PropTypes.bool,
+ enableSelectionBrush: PropTypes.bool,
/** Specify the brush orientation */
- brushOrientation: PropTypes.oneOf([ HORIZONTAL, VERTICAL, BOTH ]),
+ selectionBrushOrientation: PropTypes.oneOf([ HORIZONTAL, VERTICAL, BOTH ]),
/** Callback on brush end event with { begin, end } object returned. */
- onBrushEnd: PropTypes.func,
+ onSelectionBrushEnd: PropTypes.func,
};
XYChart.defaultProps = {
@@ -194,9 +194,9 @@ XYChart.defaultProps = {
orientation: VERTICAL,
showCrosshair: true,
showDefaultAxis: true,
- showBrush: false,
- brushOrientation: HORIZONTAL,
- onBrushEnd: () => ({}),
+ enableSelectionBrush: false,
+ selectionBrushOrientation: HORIZONTAL,
+ onSelectionBrushEnd: () => ({}),
};
export const EuiXYChart = makeVisFlexible(XYChart);
From 81a40445f26b49541a696ffc9053caa44bd85c93 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Fri, 22 Jun 2018 13:46:30 +0200
Subject: [PATCH 40/68] Fix wrong xy chart and line props on examples
---
src-docs/src/views/xy_chart/complex.js | 2 +-
src-docs/src/views/xy_chart_line/custom_style_line.js | 3 +--
2 files changed, 2 insertions(+), 3 deletions(-)
diff --git a/src-docs/src/views/xy_chart/complex.js b/src-docs/src/views/xy_chart/complex.js
index 313f0b3c182c..d1c7784e4b58 100644
--- a/src-docs/src/views/xy_chart/complex.js
+++ b/src-docs/src/views/xy_chart/complex.js
@@ -39,7 +39,7 @@ export default class ComplexDemo extends Component {
From b0ad4950d6ef4bc866714f8cefff2777edbe9e6d Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Mon, 25 Jun 2018 14:17:08 +0200
Subject: [PATCH 41/68] Add prop checking for series color
---
.../__snapshots__/area_series.test.js.snap | 20 +++++------
.../horizontal_bar_series.test.js.snap | 12 +++----
.../horizontal_rect_series.test.js.snap | 12 +++----
.../__snapshots__/line_series.test.js.snap | 34 +++++++++----------
.../vertical_bar_series.test.js.snap | 12 +++----
.../vertical_rect_series.test.js.snap | 12 +++----
src/components/xy_chart/series/area_series.js | 6 ++--
.../xy_chart/series/area_series.test.js | 3 +-
src/components/xy_chart/series/bar_series.js | 5 +--
.../xy_chart/series/horizontal_bar_series.js | 5 +--
.../series/horizontal_bar_series.test.js | 7 ++--
.../xy_chart/series/horizontal_rect_series.js | 5 +--
.../series/horizontal_rect_series.test.js | 7 ++--
src/components/xy_chart/series/line_series.js | 6 ++--
.../xy_chart/series/line_series.test.js | 3 +-
.../xy_chart/series/vertical_bar_series.js | 5 +--
.../series/vertical_bar_series.test.js | 7 ++--
.../xy_chart/series/vertical_rect_series.js | 5 +--
.../series/vertical_rect_series.test.js | 7 ++--
src/services/color/index.js | 2 +-
src/services/color/visualization_colors.js | 2 ++
src/services/index.js | 1 +
22 files changed, 96 insertions(+), 82 deletions(-)
diff --git a/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap b/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap
index 54a4ffb8c0f2..48453c178dd8 100644
--- a/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap
+++ b/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap
@@ -87,7 +87,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
undefined,
]
}
- _colorValue="#ff0000"
+ _colorValue="#DB1374"
_opacityValue={1}
angleDomain={Array []}
animation={true}
@@ -96,7 +96,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
undefined,
}
}
- color="#ff0000"
+ color="#DB1374"
colorDomain={Array []}
colorRange={
Array [
@@ -224,7 +224,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
undefined,
]
}
- _colorValue="#ff0000"
+ _colorValue="#DB1374"
_opacityValue={1}
angleDomain={Array []}
animation={true}
@@ -234,7 +234,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
undefined,
}
}
- color="#ff0000"
+ color="#DB1374"
colorDomain={Array []}
colorRange={
Array [
@@ -367,7 +367,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
undefined,
]
}
- _colorValue="#ff0000"
+ _colorValue="#DB1374"
_opacityValue={1}
angleDomain={Array []}
animatedProps={
@@ -415,7 +415,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
undefined,
}
}
- color="#ff0000"
+ color="#DB1374"
colorDomain={Array []}
colorRange={
Array [
@@ -567,7 +567,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
]
}
_animation={0.00002}
- _colorValue="#ff0000"
+ _colorValue="#DB1374"
_opacityValue={1}
angleDomain={Array []}
animation={null}
@@ -577,7 +577,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
undefined,
}
}
- color="#ff0000"
+ color="#DB1374"
colorDomain={Array []}
colorRange={
Array [
@@ -700,9 +700,9 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
onMouseOver={[Function]}
style={
Object {
- "fill": "#ff0000",
+ "fill": "#DB1374",
"opacity": 1,
- "stroke": "#ff0000",
+ "stroke": "#DB1374",
"strokeWidth": 0,
}
}
diff --git a/src/components/xy_chart/series/__snapshots__/horizontal_bar_series.test.js.snap b/src/components/xy_chart/series/__snapshots__/horizontal_bar_series.test.js.snap
index dade74f85cee..7396df1ea96a 100644
--- a/src/components/xy_chart/series/__snapshots__/horizontal_bar_series.test.js.snap
+++ b/src/components/xy_chart/series/__snapshots__/horizontal_bar_series.test.js.snap
@@ -21,14 +21,14 @@ exports[`EuiHorizontalBarSeries all props are rendered 1`] = `
>
{
{
{}}
/>
@@ -66,13 +67,13 @@ describe('EuiHorizontalBarSeries', () => {
{}}
/>
{}}
/>
diff --git a/src/components/xy_chart/series/horizontal_rect_series.js b/src/components/xy_chart/series/horizontal_rect_series.js
index 623ee20ee494..85670e4916bb 100644
--- a/src/components/xy_chart/series/horizontal_rect_series.js
+++ b/src/components/xy_chart/series/horizontal_rect_series.js
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { HorizontalRectSeries } from 'react-vis';
+import { VISUALIZATION_COLORS } from '../../../services';
export class EuiHorizontalRectSeries extends HorizontalRectSeries {
render() {
@@ -37,8 +38,8 @@ EuiHorizontalRectSeries.propTypes = {
y: PropTypes.number,
y0: PropTypes.number,
})).isRequired,
- /** Without a color set, a random EUI color palette color will be chosen */
- color: PropTypes.string,
+ /** An EUI visualization color, the default value is enforced by EuiXYChart */
+ color: PropTypes.oneOf(VISUALIZATION_COLORS),
onClick: PropTypes.func
};
diff --git a/src/components/xy_chart/series/horizontal_rect_series.test.js b/src/components/xy_chart/series/horizontal_rect_series.test.js
index 1538d5aefb5c..0d74a3301c6d 100644
--- a/src/components/xy_chart/series/horizontal_rect_series.test.js
+++ b/src/components/xy_chart/series/horizontal_rect_series.test.js
@@ -5,6 +5,7 @@ import { requiredProps } from '../../../test/required_props';
import { EuiXYChart } from '../xy_chart';
import { EuiHorizontalRectSeries } from './horizontal_rect_series';
+import { VISUALIZATION_COLORS } from '../../../services';
beforeEach(patchRandom);
afterEach(unpatchRandom);
@@ -46,7 +47,7 @@ describe('EuiHorizontalRectSeries', () => {
{}}
/>
@@ -66,13 +67,13 @@ describe('EuiHorizontalRectSeries', () => {
{}}
/>
{}}
/>
diff --git a/src/components/xy_chart/series/line_series.js b/src/components/xy_chart/series/line_series.js
index bb35fd066428..47cb79b28ae7 100644
--- a/src/components/xy_chart/series/line_series.js
+++ b/src/components/xy_chart/series/line_series.js
@@ -1,7 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
-
import { LineSeries, MarkSeries, AbstractSeries } from 'react-vis';
+import { VISUALIZATION_COLORS } from '../../../services';
export class EuiLineSeries extends AbstractSeries {
render() {
@@ -79,8 +79,8 @@ EuiLineSeries.propTypes = {
PropTypes.number
]),
})).isRequired,
- /** Without a color set, a random EUI color palette color will be chosen */
- color: PropTypes.string,
+ /** An EUI visualization color, the default value is enforced by EuiXYChart */
+ color: PropTypes.oneOf(VISUALIZATION_COLORS),
curve: PropTypes.string,
showLineMarks: PropTypes.bool,
lineSize: PropTypes.number,
diff --git a/src/components/xy_chart/series/line_series.test.js b/src/components/xy_chart/series/line_series.test.js
index 9eb7863ef0aa..fd43a81014a0 100644
--- a/src/components/xy_chart/series/line_series.test.js
+++ b/src/components/xy_chart/series/line_series.test.js
@@ -6,6 +6,7 @@ import { requiredProps } from '../../../test/required_props';
import { EuiXYChart } from '../xy_chart';
import { EuiLineSeries } from './line_series';
+import { VISUALIZATION_COLORS } from '../../../services';
beforeEach(patchRandom);
afterEach(unpatchRandom);
@@ -30,7 +31,7 @@ describe('EuiLineSeries', () => {
{
{}}
/>
@@ -67,13 +68,13 @@ describe('EuiVerticalBarSeries', () => {
{}}
/>
{}}
/>
diff --git a/src/components/xy_chart/series/vertical_rect_series.js b/src/components/xy_chart/series/vertical_rect_series.js
index 37bc50bed85b..2d0326dbdfd5 100644
--- a/src/components/xy_chart/series/vertical_rect_series.js
+++ b/src/components/xy_chart/series/vertical_rect_series.js
@@ -1,6 +1,7 @@
import React from 'react';
import PropTypes from 'prop-types';
import { VerticalRectSeries } from 'react-vis';
+import { VISUALIZATION_COLORS } from '../../../services';
export class EuiVerticalRectSeries extends VerticalRectSeries {
render() {
@@ -38,8 +39,8 @@ EuiVerticalRectSeries.propTypes = {
x: PropTypes.number,
y: PropTypes.number,
})).isRequired,
- /** Without a color set, a random EUI color palette color will be chosen */
- color: PropTypes.string,
+ /** An EUI visualization color, the default value is enforced by EuiXYChart */
+ color: PropTypes.oneOf(VISUALIZATION_COLORS),
onClick: PropTypes.func
};
diff --git a/src/components/xy_chart/series/vertical_rect_series.test.js b/src/components/xy_chart/series/vertical_rect_series.test.js
index c44212074a52..2821e427f079 100644
--- a/src/components/xy_chart/series/vertical_rect_series.test.js
+++ b/src/components/xy_chart/series/vertical_rect_series.test.js
@@ -6,6 +6,7 @@ import { requiredProps } from '../../../test/required_props';
import { EuiXYChart } from '../xy_chart';
import { EuiVerticalRectSeries } from './vertical_rect_series';
import { benchmarkFunction } from '../../../test/time_execution';
+import { VISUALIZATION_COLORS } from '../../../services';
beforeEach(patchRandom);
afterEach(unpatchRandom);
@@ -47,7 +48,7 @@ describe('EuiVerticalRectSeries', () => {
{}}
/>
@@ -67,13 +68,13 @@ describe('EuiVerticalRectSeries', () => {
{}}
/>
{}}
/>
diff --git a/src/services/color/index.js b/src/services/color/index.js
index 750249aabcb1..0c4908fe99b4 100644
--- a/src/services/color/index.js
+++ b/src/services/color/index.js
@@ -2,4 +2,4 @@ export { isColorDark } from './is_color_dark';
export { hexToRgb } from './hex_to_rgb';
export { rgbToHex } from './rgb_to_hex';
export { calculateContrast, calculateLuminance } from './luminance_and_contrast';
-export { VISUALIZATION_COLORS } from './visualization_colors';
+export { VISUALIZATION_COLORS, DEFAULT_VISUALIZATION_COLOR } from './visualization_colors';
diff --git a/src/services/color/visualization_colors.js b/src/services/color/visualization_colors.js
index b628f4b7c224..0ca8ab243ced 100644
--- a/src/services/color/visualization_colors.js
+++ b/src/services/color/visualization_colors.js
@@ -14,3 +14,5 @@ export const VISUALIZATION_COLORS = [
'#461A0A',
'#920000',
];
+
+export const DEFAULT_VISUALIZATION_COLOR = VISUALIZATION_COLORS[1];
diff --git a/src/services/index.js b/src/services/index.js
index 0a71e340409d..ade40feeeac0 100644
--- a/src/services/index.js
+++ b/src/services/index.js
@@ -22,6 +22,7 @@ export {
hexToRgb,
rgbToHex,
VISUALIZATION_COLORS,
+ DEFAULT_VISUALIZATION_COLOR,
} from './color';
export {
From d275c08ebbf30910c2e803b445fc2ca9fd418011 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Mon, 25 Jun 2018 14:19:30 +0200
Subject: [PATCH 42/68] Fix custom line example after removing showLine props
from EuiLineSeries
---
src-docs/src/views/xy_chart_line/custom_style_line.js | 5 -----
1 file changed, 5 deletions(-)
diff --git a/src-docs/src/views/xy_chart_line/custom_style_line.js b/src-docs/src/views/xy_chart_line/custom_style_line.js
index 48a0b12f0cc1..4bf72ee4d3ab 100644
--- a/src-docs/src/views/xy_chart_line/custom_style_line.js
+++ b/src-docs/src/views/xy_chart_line/custom_style_line.js
@@ -22,17 +22,12 @@ export default class extends Component {
lineMarkSize: '4',
lineSize: '2',
lineProps: [
- {
- id: `showLine`,
- label: 'Show Line',
- },
{
id: `showLineMarks`,
label: 'Show Line Marks',
},
],
linePropsIdToSelectedMap: {
- showLine: true,
showLineMarks: true,
},
};
From 1b7b677d10f3b279efd5ad8c7b0863bb00a39505 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Mon, 25 Jun 2018 15:49:35 +0200
Subject: [PATCH 43/68] Add basic annotation component
---
.../src/views/xy_chart_axis/annotations.js | 51 +++++++
.../views/xy_chart_axis/xy_axis_example.js | 30 +++-
src-docs/src/views/xy_chart_line/line.js | 35 ++++-
src/components/index.js | 1 +
src/components/xy_chart/_index.scss | 3 +-
src/components/xy_chart/index.js | 1 +
src/components/xy_chart/line_annotation.js | 133 ++++++++++++++++++
src/components/xy_chart/line_annotation.scss | 3 +
8 files changed, 254 insertions(+), 3 deletions(-)
create mode 100644 src-docs/src/views/xy_chart_axis/annotations.js
create mode 100644 src/components/xy_chart/line_annotation.js
create mode 100644 src/components/xy_chart/line_annotation.scss
diff --git a/src-docs/src/views/xy_chart_axis/annotations.js b/src-docs/src/views/xy_chart_axis/annotations.js
new file mode 100644
index 000000000000..7dbb66ff2118
--- /dev/null
+++ b/src-docs/src/views/xy_chart_axis/annotations.js
@@ -0,0 +1,51 @@
+import React from 'react';
+
+import {
+ EuiXYChart,
+ EuiLineSeries,
+ EuiLineAnnotation,
+ EuiXYChartUtils,
+ EuiXYChartAxisUtils,
+} from '../../../../src/components';
+
+const DATA_A = [
+ { x: 0, y: 1 },
+ { x: 1, y: 1 },
+ { x: 2, y: 2 },
+ { x: 3, y: -1 },
+ { x: 4, y: null },
+ { x: 5, y: 2 },
+];
+
+export default () => (
+
+
+
+
+
+
+
+
+
+);
diff --git a/src-docs/src/views/xy_chart_axis/xy_axis_example.js b/src-docs/src/views/xy_chart_axis/xy_axis_example.js
index b57378115059..04d24bb06154 100644
--- a/src-docs/src/views/xy_chart_axis/xy_axis_example.js
+++ b/src-docs/src/views/xy_chart_axis/xy_axis_example.js
@@ -1,7 +1,8 @@
import React from 'react';
import { GuideSectionTypes } from '../../components';
-import { EuiCode, EuiXAxis, EuiYAxis } from '../../../../src/components';
+import { EuiCode, EuiXAxis, EuiYAxis, EuiLineAnnotation } from '../../../../src/components';
import SimpleAxisExampleCode from './simple_axis';
+import AnnotationExampleCode from './annotations';
export const XYChartAxisExample = {
title: 'Axis',
@@ -34,5 +35,32 @@ export const XYChartAxisExample = {
),
},
+ {
+ title: 'Annotations',
+ text: (
+
+
+ EuiLineAnnotation can be used to add annotation lines with optional text
+ on the chart.
+
+
+ ),
+ props: { EuiLineAnnotation },
+ source: [
+ {
+ type: GuideSectionTypes.JS,
+ code: require('!!raw-loader!./simple_axis'),
+ },
+ {
+ type: GuideSectionTypes.HTML,
+ code: 'This component can only be used from React',
+ },
+ ],
+ demo: (
+
+ ),
+ },
],
};
diff --git a/src-docs/src/views/xy_chart_line/line.js b/src-docs/src/views/xy_chart_line/line.js
index 6dc34c377c9f..7dbb66ff2118 100644
--- a/src-docs/src/views/xy_chart_line/line.js
+++ b/src-docs/src/views/xy_chart_line/line.js
@@ -1,6 +1,12 @@
import React from 'react';
-import { EuiXYChart, EuiLineSeries } from '../../../../src/components';
+import {
+ EuiXYChart,
+ EuiLineSeries,
+ EuiLineAnnotation,
+ EuiXYChartUtils,
+ EuiXYChartAxisUtils,
+} from '../../../../src/components';
const DATA_A = [
{ x: 0, y: 1 },
@@ -14,5 +20,32 @@ const DATA_A = [
export default () => (
+
+
+
+
+
+
);
diff --git a/src/components/index.js b/src/components/index.js
index cb5d86f1dbea..62565ba92f12 100644
--- a/src/components/index.js
+++ b/src/components/index.js
@@ -319,4 +319,5 @@ export {
EuiYAxis,
EuiCrosshairX,
EuiCrosshairY,
+ EuiLineAnnotation,
} from './xy_chart';
diff --git a/src/components/xy_chart/_index.scss b/src/components/xy_chart/_index.scss
index abd633274265..0d63623b36d3 100644
--- a/src/components/xy_chart/_index.scss
+++ b/src/components/xy_chart/_index.scss
@@ -1,4 +1,5 @@
@import "reactvis";
@import "legend";
-@import "chart";
\ No newline at end of file
+@import "chart";
+@import "line_annotation";
diff --git a/src/components/xy_chart/index.js b/src/components/xy_chart/index.js
index 2a105961fc2a..7f2a702d8167 100644
--- a/src/components/xy_chart/index.js
+++ b/src/components/xy_chart/index.js
@@ -1,4 +1,5 @@
export { EuiXYChart } from './xy_chart';
+export { EuiLineAnnotation } from './line_annotation';
// XY chart data series
export * from './series';
diff --git a/src/components/xy_chart/line_annotation.js b/src/components/xy_chart/line_annotation.js
new file mode 100644
index 000000000000..3ba05353b8bc
--- /dev/null
+++ b/src/components/xy_chart/line_annotation.js
@@ -0,0 +1,133 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { AbstractSeries, ScaleUtils } from 'react-vis';
+import { EuiXYChartUtils } from './utils/chart_utils';
+import { EuiXYChartAxisUtils } from './utils/axis_utils';
+const { HORIZONTAL, VERTICAL } = EuiXYChartUtils.ORIENTATION;
+const { START, MIDDLE, END } = EuiXYChartAxisUtils.TITLE_POSITION;
+
+/**
+ * Draw simple line annotation into the chart. Currently it's a work in progress
+ * but will be extented to add text and tooltips if required.
+ * The basic usage is for displaying the current time marker.
+ */
+export class EuiLineAnnotation extends AbstractSeries {
+ /**
+ * Get attribute functor.
+ * @param {string} attr Attribute name
+ * @returns {*} Functor.
+ * @protected
+ */
+ _getAttributeFunctor(attr) {
+ return ScaleUtils.getAttributeFunctor(this.props, attr);
+ }
+ /**
+ * Get the attribute value if it is available.
+ * @param {string} attr Attribute name.
+ * @returns {*} Attribute value if available, fallback value or undefined
+ * otherwise.
+ * @protected
+ */
+ _getAttributeValue(attr) {
+ return ScaleUtils.getAttributeValue(this.props, attr);
+ }
+ _getTextXY(textPosition, min, max) {
+ switch (textPosition) {
+ case END:
+ return min;
+ case START:
+ return max;
+ case MIDDLE:
+ return Math.abs((max - min) / 2);
+ }
+ }
+ render() {
+ const { data, orientation, textPosition, innerHeight, innerWidth, marginLeft, marginTop } = this.props;
+ const axis = orientation === HORIZONTAL ? 'y' : 'x';
+ const scale = this._getAttributeFunctor(axis);
+
+ return (
+
+
+ {
+ data.map((d, i) => {
+ const { value } = d;
+ const position = scale({ [axis] : value });
+ return (
+
+ )
+ })
+ }
+
+
+ {
+ data
+ .filter(d => d.text)
+ .map((d, i) => {
+ const { value } = d;
+ let x = 0;
+ let y = 0;
+ let rotation = 0;
+ if (orientation === VERTICAL) {
+ x = scale({ [axis] : value });
+ y = this._getTextXY(textPosition, 0 , innerHeight);
+ rotation = '-90'
+ } else {
+ x = this._getTextXY(textPosition, innerWidth, 0);
+ y = scale({ [axis] : value });
+ }
+
+ return (
+
+ {d.text}
+
+ )
+ })
+ }
+
+
+ );
+ }
+}
+EuiLineAnnotation.displayName = 'EuiLineAnnotation';
+EuiLineAnnotation.propTypes = {
+ /** An annotation data Array<{value: string|number, text: string}> */
+ data: PropTypes.arrayOf(
+ PropTypes.shape({
+ value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
+ text: PropTypes.string,
+ }),
+ ).isRequired,
+ /** The orientation of the annotation. */
+ orientation: PropTypes.oneOf([ HORIZONTAL, VERTICAL ]),
+ textPosition: PropTypes.oneOf([ START, MIDDLE, END ])
+};
+
+EuiLineAnnotation.defaultProps = {
+ orientation: VERTICAL,
+ textPosition: START,
+};
diff --git a/src/components/xy_chart/line_annotation.scss b/src/components/xy_chart/line_annotation.scss
new file mode 100644
index 000000000000..d98c87f90740
--- /dev/null
+++ b/src/components/xy_chart/line_annotation.scss
@@ -0,0 +1,3 @@
+.euiLineAnnotationText {
+ font-size: $euiFontSizeXS;
+}
From c6dc3a0483751977beeced206b6499c7257f76a8 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Tue, 26 Jun 2018 18:40:32 +0200
Subject: [PATCH 44/68] WIP fix mouseover behaviours on series
---
src-docs/src/views/xy_chart/complex.js | 78 ++++++------
src-docs/src/views/xy_chart/crosshair_sync.js | 2 -
.../views/xy_chart_bar/vertical_bar_series.js | 10 +-
src/components/xy_chart/brush.js | 103 +++++++++------
src/components/xy_chart/series/area_series.js | 5 +-
.../xy_chart/series/horizontal_bar_series.js | 33 +++--
.../xy_chart/series/horizontal_rect_series.js | 33 +++--
src/components/xy_chart/series/line_series.js | 20 +--
.../xy_chart/series/vertical_bar_series.js | 24 +++-
.../xy_chart/series/vertical_rect_series.js | 33 +++--
src/components/xy_chart/xy_chart.js | 118 +++++++++++++-----
11 files changed, 278 insertions(+), 181 deletions(-)
diff --git a/src-docs/src/views/xy_chart/complex.js b/src-docs/src/views/xy_chart/complex.js
index d1c7784e4b58..42b6f6313f08 100644
--- a/src-docs/src/views/xy_chart/complex.js
+++ b/src-docs/src/views/xy_chart/complex.js
@@ -1,81 +1,87 @@
import React, { Fragment, Component } from 'react';
import {
+ EuiText,
EuiCodeBlock,
EuiSpacer,
EuiXYChart,
- EuiXYChartUtils,
EuiVerticalBarSeries,
EuiAreaSeries,
EuiLineSeries,
} from '../../../../src/components';
-const barData = [];
-for (let i = 0; i < 10; i++) {
- const data = [];
-
- for (let i = 0; i < 20; i++) {
- data.push({ x: i, y: Number(Math.random().toFixed(2)) });
- }
-
- barData.push(data);
+const barSeries = [];
+for (let i = 0; i < 2; i++) {
+ const data = new Array(20).fill(0).map((d, i) => ({ x: i, y: Number((Math.random() * 4).toFixed(2)) }));
+ barSeries.push(data);
}
+const lineData = new Array(20).fill(0).map((d, i) => ({ x: i, y: Number((Math.random() * 4).toFixed(2)) }));
+const areaData = new Array(20).fill(0).map((d, i) => ({ x: i, y: Number((Math.random() * 4).toFixed(2)) }));
export default class ComplexDemo extends Component {
state = {
- brushOutput: 'Please drag your mouse to select an area'
+ json: 'Please drag your mouse to select an area or click on an element'
}
handleSelectionBrushEnd = (area) => {
this.setState(() => ({
- brushOutput: JSON.stringify(area, null, 2),
+ eventName: 'onSelectionBrushEnd',
+ json: JSON.stringify(area, null, 2),
+ }));
+ }
+ handleOnValueClick = (data) => {
+ this.setState(() => ({
+ eventName: 'onValueClick',
+ json: JSON.stringify(data, null, 2),
+ }));
+ }
+ handleOnSeriesClick = (series) => () => {
+ this.setState(() => ({
+ eventName: 'onSeriesClick',
+ json: JSON.stringify({ name: series }),
}));
}
render() {
- const { brushOutput } = this.state
+ const { eventName, json } = this.state
return (
-
- {brushOutput}
-
-
{
- alert('clicked!');
- }}
- data={[
- { x: 0, y: 0 },
- { x: 1, y: 2 },
- { x: 2, y: 1 },
- { x: 3, y: 2 },
- { x: 4, y: 1 },
- { x: 10, y: 1 },
- { x: 20, y: 2 },
- ]}
+ curve="curveMonotoneX"
+ data={areaData}
+ onSeriesClick={this.handleOnSeriesClick('EuiAreaSeries')}
/>
- {barData
- .slice(0, 1)
+ {barSeries
.map((data, index) => (
))}
+
+ { eventName && (
+
+ Event: { eventName }
+
+ )}
+
+ { json }
+
);
}
diff --git a/src-docs/src/views/xy_chart/crosshair_sync.js b/src-docs/src/views/xy_chart/crosshair_sync.js
index a55605d8682d..e2f10281c7af 100644
--- a/src-docs/src/views/xy_chart/crosshair_sync.js
+++ b/src-docs/src/views/xy_chart/crosshair_sync.js
@@ -22,7 +22,6 @@ export class ExampleCrosshair extends React.Component {
@@ -35,7 +34,6 @@ export class ExampleCrosshair extends React.Component {
diff --git a/src-docs/src/views/xy_chart_bar/vertical_bar_series.js b/src-docs/src/views/xy_chart_bar/vertical_bar_series.js
index c45fe68c35d1..a30bc8e5547c 100644
--- a/src-docs/src/views/xy_chart_bar/vertical_bar_series.js
+++ b/src-docs/src/views/xy_chart_bar/vertical_bar_series.js
@@ -3,11 +3,11 @@ import React from 'react';
import { EuiXYChart, EuiVerticalBarSeries } from '../../../../src/components';
const data = [
- { x: 'A', y: 3 },
- { x: 'B', y: 1 },
- { x: 'C', y: 5 },
- { x: 'D', y: 2 },
- { x: 'E', y: 1 },
+ { x: 'A', y: 3, color: 'red' },
+ { x: 'B', y: 1, color: 'red' },
+ { x: 'C', y: 5, color: 'red' },
+ { x: 'D', y: 2, color: 'red' },
+ { x: 'E', y: 1, color: 'red' },
];
export default () => (
diff --git a/src/components/xy_chart/brush.js b/src/components/xy_chart/brush.js
index c298f66d62e1..05d415dae2dd 100644
--- a/src/components/xy_chart/brush.js
+++ b/src/components/xy_chart/brush.js
@@ -5,6 +5,7 @@ import { EuiXYChartUtils } from './utils/chart_utils';
const { HORIZONTAL, VERTICAL, BOTH } = EuiXYChartUtils.ORIENTATION
const DEFAULT_AREAS = {
+ areaSize: 0,
drawArea: {
x0: 0,
x1: 0,
@@ -23,7 +24,23 @@ export class EuiSelectionBrush extends AbstractSeries {
state = {
drawing: false,
...DEFAULT_AREAS,
- };
+ }
+
+ onParentMouseDown(e) {
+ this._startDrawing(e);
+ }
+
+ onParentMouseMove(e) {
+ this._brushing(e);
+ }
+
+ onParentMouseUp() {
+ this._stopDrawing();
+ }
+
+ onParentMouseLeave() {
+ this._stopDrawing();
+ }
_getDrawArea(offsetX, offsetY, isStartingPoint) {
const { orientation, marginTop, marginLeft, innerHeight, innerWidth } = this.props;
@@ -40,7 +57,9 @@ export class EuiSelectionBrush extends AbstractSeries {
}
const x1 = orientation === VERTICAL ? innerWidth : xLocation;
const y1 = orientation === HORIZONTAL ? innerHeight : yLocation;
+ const areaSize = Math.abs(x0 - x1) * Math.abs(y0 - y1);
return {
+ areaSize,
drawArea: {
x0,
x1,
@@ -56,8 +75,8 @@ export class EuiSelectionBrush extends AbstractSeries {
};
}
- onParentMouseDown(e) {
- const { onSelectStart } = this.props;
+ _startDrawing = (e) => {
+ const { onBrushStart } = this.props;
const { offsetX, offsetY } = e.nativeEvent;
const drawAndRectAreas = this._getDrawArea(offsetX, offsetY, true);
this.setState(() => ({
@@ -65,47 +84,57 @@ export class EuiSelectionBrush extends AbstractSeries {
...drawAndRectAreas,
}));
- if (onSelectStart) {
- onSelectStart(e);
+ if (onBrushStart) {
+ onBrushStart(drawAndRectAreas);
}
}
- onParentMouseMove(e) {
- const { onSelect } = this.props;
+ _brushing = (e) => {
+ const { onBrushing } = this.props;
const { drawing } = this.state;
const { offsetX, offsetY } = e.nativeEvent;
-
if (drawing) {
const drawAndRectAreas = this._getDrawArea(offsetX, offsetY);
- this.setState(() => ({ ...drawAndRectAreas }));
+ this.setState(() => ({
+ ...drawAndRectAreas
+ }));
- if (onSelect) {
- onSelect(e);
+ if (onBrushing) {
+ onBrushing(drawAndRectAreas);
}
+ } else {
+ this.setState(() => ({
+ drawing: false,
+ ...DEFAULT_AREAS,
+ }));
}
}
- stopDrawing = () => {
+ _stopDrawing = () => {
// Quickly short-circuit if the user isn't drawing in our component
- if (!this.state.drawing) {
+ const { drawing } = this.state;
+ if (!drawing) {
return;
}
- const { onBrushEnd } = this.props;
- const { x0, y0, x1, y1 } = this.state.drawArea;
- const xScale = ScaleUtils.getAttributeScale(this.props, 'x');
- const yScale = ScaleUtils.getAttributeScale(this.props, 'y');
-
// Clear the draw area
this.setState(() => ({
drawing: false,
...DEFAULT_AREAS,
}));
- // Don't invoke the callback if the selected area was < 5px.
+
+
+ // Don't invoke the callback if the selected area was < 25 square px.
// This is a click not a select
- if (Math.abs(x0 - x1) < 5 || Math.abs(y0 - y1) < 5) {
+ const { areaSize } = this.state;
+ if (areaSize < 25) {
return;
}
+ const { drawArea } = this.state;
+ const { x0, y0, x1, y1 } = drawArea;
+ const { onBrushEnd } = this.props;
+ const xScale = ScaleUtils.getAttributeScale(this.props, 'x');
+ const yScale = ScaleUtils.getAttributeScale(this.props, 'y');
// Compute the corresponding domain drawn
const domainArea = {
@@ -116,33 +145,25 @@ export class EuiSelectionBrush extends AbstractSeries {
};
if (onBrushEnd) {
- onBrushEnd(domainArea);
+ onBrushEnd({
+ domainArea,
+ drawArea,
+ });
}
}
render() {
- const { marginLeft, marginTop, innerWidth, innerHeight, color, opacity } = this.props;
+ const { marginLeft, marginTop, color, opacity } = this.props;
const { rectArea: { x, y, width, height } } = this.state;
return (
-
-
-
+
);
}
}
@@ -42,7 +40,8 @@ EuiHorizontalBarSeries.propTypes = {
})).isRequired,
/** An EUI visualization color, the default value is enforced by EuiXYChart */
color: PropTypes.oneOf(VISUALIZATION_COLORS),
- onClick: PropTypes.func
+ /** Callback when clicking on a single bar */
+ onValueClick: PropTypes.func
};
EuiHorizontalBarSeries.defaultProps = {};
diff --git a/src/components/xy_chart/series/horizontal_rect_series.js b/src/components/xy_chart/series/horizontal_rect_series.js
index 85670e4916bb..b5515e8d90a5 100644
--- a/src/components/xy_chart/series/horizontal_rect_series.js
+++ b/src/components/xy_chart/series/horizontal_rect_series.js
@@ -5,24 +5,22 @@ import { VISUALIZATION_COLORS } from '../../../services';
export class EuiHorizontalRectSeries extends HorizontalRectSeries {
render() {
- const { name, data, color, onClick, ...rest } = this.props;
+ const { name, data, color, onValueClick, ...rest } = this.props;
return (
-
-
-
+
);
}
}
@@ -40,7 +38,8 @@ EuiHorizontalRectSeries.propTypes = {
})).isRequired,
/** An EUI visualization color, the default value is enforced by EuiXYChart */
color: PropTypes.oneOf(VISUALIZATION_COLORS),
- onClick: PropTypes.func
+ /** Callback when clicking on a single bar */
+ onValueClick: PropTypes.func
};
EuiHorizontalRectSeries.defaultProps = {};
diff --git a/src/components/xy_chart/series/line_series.js b/src/components/xy_chart/series/line_series.js
index 47cb79b28ae7..1167e34f46e1 100644
--- a/src/components/xy_chart/series/line_series.js
+++ b/src/components/xy_chart/series/line_series.js
@@ -1,4 +1,4 @@
-import React from 'react';
+import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { LineSeries, MarkSeries, AbstractSeries } from 'react-vis';
import { VISUALIZATION_COLORS } from '../../../services';
@@ -9,7 +9,7 @@ export class EuiLineSeries extends AbstractSeries {
data,
name,
curve,
- onClick,
+ onSeriesClick,
onMarkClick,
showLineMarks,
lineSize,
@@ -20,16 +20,17 @@ export class EuiLineSeries extends AbstractSeries {
} = this.props;
return (
-
+
@@ -40,7 +41,8 @@ export class EuiLineSeries extends AbstractSeries {
data={data}
opacity={1}
style={{
- strokeWidth: lineSize,
+ pointerEvents: 'visiblestroke',
+ strokeWidth: lineSize,
}}
color={color}
/>
@@ -54,11 +56,11 @@ export class EuiLineSeries extends AbstractSeries {
size={lineMarkSize}
stroke={'white'}
opacity={1}
- onSeriesClick={onMarkClick || onClick}
+ onSeriesClick={onMarkClick || onSeriesClick}
strokeWidth={2}
/>
)}
-
+
)
}
}
@@ -86,7 +88,7 @@ EuiLineSeries.propTypes = {
lineSize: PropTypes.number,
lineMarkColor: PropTypes.string,
lineMarkSize: PropTypes.number,
- onClick: PropTypes.func,
+ onSeriesClick: PropTypes.func,
onMarkClick: PropTypes.func
};
diff --git a/src/components/xy_chart/series/vertical_bar_series.js b/src/components/xy_chart/series/vertical_bar_series.js
index 12f141a3bb34..47264e967bd7 100644
--- a/src/components/xy_chart/series/vertical_bar_series.js
+++ b/src/components/xy_chart/series/vertical_bar_series.js
@@ -4,21 +4,34 @@ import { VerticalBarSeries } from 'react-vis';
import { VISUALIZATION_COLORS } from '../../../services';
export class EuiVerticalBarSeries extends VerticalBarSeries {
-
+ state = {
+ hoverBars: false,
+ }
+ _handleOnSeriesOver = () => {
+ this.setState(() => { hoverBars: true })
+ }
+ _handleOnSeriesOut = () => {
+ this.setState(() => { hoverBars: false })
+ }
render() {
- const { name, data, color, onClick, ...rest } = this.props;
+ const { name, data, color, onValueClick, ...rest } = this.props;
+ const { hoverBars } = this.state
const isHighDataVolume = data.length > 80 ? true : false;
-
+ const canHover = hoverBars && onValueClick
+ console.log('canHover',canHover)
return (
80 ? true : false;
return (
-
-
-
+
);
}
}
@@ -41,7 +39,8 @@ EuiVerticalRectSeries.propTypes = {
})).isRequired,
/** An EUI visualization color, the default value is enforced by EuiXYChart */
color: PropTypes.oneOf(VISUALIZATION_COLORS),
- onClick: PropTypes.func
+ /** Callback when clicking on a single rect */
+ onValueClick: PropTypes.func
};
EuiVerticalRectSeries.defaultProps = {};
diff --git a/src/components/xy_chart/xy_chart.js b/src/components/xy_chart/xy_chart.js
index 75753883f84c..f9b0a30a17cd 100644
--- a/src/components/xy_chart/xy_chart.js
+++ b/src/components/xy_chart/xy_chart.js
@@ -10,16 +10,8 @@ import { VISUALIZATION_COLORS } from '../../services';
import StatusText from './status-text';
import { getSeriesChildren } from './utils/series_utils';
import { EuiXYChartUtils } from './utils/chart_utils';
-const { HORIZONTAL, VERTICAL, BOTH } = EuiXYChartUtils.ORIENTATION
-const {
- LINEAR,
- ORDINAL,
- CATEGORY,
- TIME,
- TIME_UTC,
- LOG,
- LITERAL,
-} = EuiXYChartUtils.SCALE_TYPE;
+const { HORIZONTAL, VERTICAL, BOTH } = EuiXYChartUtils.ORIENTATION;
+const { LINEAR, ORDINAL, CATEGORY, TIME, TIME_UTC, LOG, LITERAL } = EuiXYChartUtils.SCALE_TYPE;
class XYExtendedPlot extends XYPlot {
/**
@@ -40,6 +32,76 @@ class XYExtendedPlot extends XYPlot {
}
});
}
+
+ /**
+ * Trigger onMouseUp handler if it was passed in props.
+ * @param {Event} event Native event.
+ * @private
+ */
+ _mouseUpHandler = (event) => {
+ const { onMouseUp, children } = this.props;
+ if (onMouseUp) {
+ super.onMouseUp(event);
+ }
+ const seriesChildren = getSeriesChildren(children);
+ seriesChildren.forEach((child, index) => {
+ const component = this.refs[`series${index}`];
+ if (component && component.onParentMouseUp) {
+ component.onParentMouseUp(event);
+ }
+ });
+ }
+
+ render() {
+ const {
+ className,
+ dontCheckIfEmpty,
+ style,
+ width,
+ height,
+ errorText,
+ } = this.props;
+
+ if (!dontCheckIfEmpty && this._isPlotEmpty()) {
+ return (
+
+ );
+ }
+ const components = this._getClonedChildComponents();
+
+ return (
+
+
+ {components.filter(c => c && c.type.requiresSVG)}
+
+ {this.renderCanvasComponents(components, this.props)}
+ {components.filter(c => c && !c.type.requiresSVG && !c.type.isCanvas)}
+
+ );
+ }
}
class XYChart extends PureComponent {
@@ -69,11 +131,6 @@ class XYChart extends PureComponent {
return React.cloneElement(child, props);
};
- // canShowCrosshair = () => {
- // const { crosshairValue, showCrosshair } = this.props;
- // const { mouseOver } = this.state;
- // return showCrosshair && ( mouseOver || crosshairValue !== undefined)
- // }
render() {
const {
@@ -100,10 +157,6 @@ class XYChart extends PureComponent {
...rest
} = this.props;
- if (!children || errorText) {
- return ;
- }
-
this.colorIterator = 0;
const Crosshair =
orientation === EuiXYChartUtils.ORIENTATION.HORIZONTAL ? EuiCrosshairY : EuiCrosshairX;
@@ -111,9 +164,7 @@ class XYChart extends PureComponent {
)}
- {enableSelectionBrush && }
+ {enableSelectionBrush && (
+
+ )}
);
@@ -146,15 +202,15 @@ XYChart.propTypes = {
/** The initial height of the chart. */
height: PropTypes.number.isRequired,
/** The orientation of the chart. */
- orientation: PropTypes.oneOf([ HORIZONTAL, VERTICAL ]),
+ orientation: PropTypes.oneOf([HORIZONTAL, VERTICAL]),
/** If the chart animates on data changes. */
- animateData: PropTypes.bool,
+ animateData: PropTypes.bool,
/** TODO */
stackBy: PropTypes.string,
/** The main x axis scale type. See https://github.com/uber/react-vis/blob/master/docs/scales-and-data.md */
- xType: PropTypes.oneOf([ LINEAR, ORDINAL, CATEGORY, TIME, TIME_UTC, LOG, LITERAL ]),
+ xType: PropTypes.oneOf([LINEAR, ORDINAL, CATEGORY, TIME, TIME_UTC, LOG, LITERAL]),
/** The main y axis scale type. See https://github.com/uber/react-vis/blob/master/docs/scales-and-data.md*/
- xType: PropTypes.oneOf([ LINEAR, ORDINAL, CATEGORY, TIME, TIME_UTC, LOG, LITERAL ]),
+ xType: PropTypes.oneOf([LINEAR, ORDINAL, CATEGORY, TIME, TIME_UTC, LOG, LITERAL]),
/** Manually specify the domain of x axis. */
xDomain: PropTypes.array,
/** Manually specify the domain of y axis. */
@@ -163,11 +219,7 @@ XYChart.propTypes = {
xPadding: PropTypes.number,
/** The vertical padding between the chart borders and chart elements. */
yPadding: PropTypes.number,
- /** TODO */
- onHover: PropTypes.func,
- /** TODO */
- truncateLegends: PropTypes.bool,
- /** TODO */
+ /** Add a text to show an error on the chart */
errorText: PropTypes.string,
/** Shows the crosshair tooltip on mouse move.*/
showCrosshair: PropTypes.bool,
@@ -180,7 +232,7 @@ XYChart.propTypes = {
/** Enable the brush tool */
enableSelectionBrush: PropTypes.bool,
/** Specify the brush orientation */
- selectionBrushOrientation: PropTypes.oneOf([ HORIZONTAL, VERTICAL, BOTH ]),
+ selectionBrushOrientation: PropTypes.oneOf([HORIZONTAL, VERTICAL, BOTH]),
/** Callback on brush end event with { begin, end } object returned. */
onSelectionBrushEnd: PropTypes.func,
};
From 4c3520e9315d219cc702803da96092d093035c8f Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Tue, 26 Jun 2018 19:03:43 +0200
Subject: [PATCH 45/68] Add mouse pointer change on hover
---
src/components/xy_chart/series/area_series.js | 38 ++++++++++++-------
.../xy_chart/series/horizontal_bar_series.js | 14 +++++++
.../xy_chart/series/horizontal_rect_series.js | 14 +++++++
.../xy_chart/series/vertical_bar_series.js | 23 +++++------
.../xy_chart/series/vertical_rect_series.js | 16 ++++++++
5 files changed, 81 insertions(+), 24 deletions(-)
diff --git a/src/components/xy_chart/series/area_series.js b/src/components/xy_chart/series/area_series.js
index 6f9249201d45..887ff6ce504b 100644
--- a/src/components/xy_chart/series/area_series.js
+++ b/src/components/xy_chart/series/area_series.js
@@ -3,22 +3,34 @@ import PropTypes from 'prop-types';
import { AreaSeries, AbstractSeries } from 'react-vis';
import { VISUALIZATION_COLORS } from '../../../services';
export class EuiAreaSeries extends AbstractSeries {
+ state = {
+ isMouseOverSeries: false,
+ }
+
+ _onSeriesMouseOver = () => {
+ this.setState(() => ({ isMouseOverSeries: true }));
+ }
+
+ _onSeriesMouseOut = () => {
+ this.setState(() => ({ isMouseOverSeries: false }));
+ }
+
render() {
+ const { isMouseOverSeries } = this.state;
const { name, data, curve, color, onSeriesClick, ...rest } = this.props;
return (
-
-
-
+
);
}
}
diff --git a/src/components/xy_chart/series/horizontal_bar_series.js b/src/components/xy_chart/series/horizontal_bar_series.js
index 283872f8911a..06b148179e27 100644
--- a/src/components/xy_chart/series/horizontal_bar_series.js
+++ b/src/components/xy_chart/series/horizontal_bar_series.js
@@ -4,7 +4,20 @@ import { HorizontalBarSeries } from 'react-vis';
import { VISUALIZATION_COLORS } from '../../../services';
export class EuiHorizontalBarSeries extends HorizontalBarSeries {
+ state = {
+ isMouseOverValue: false,
+ }
+
+ _onValueMouseOver = () => {
+ this.setState(() => ({ isMouseOverValue: true }));
+ }
+
+ _onValueMouseOut = () => {
+ this.setState(() => ({ isMouseOverValue: false }));
+ }
+
render() {
+ const { isMouseOverValue } = this.state;
const { name, data, color, onValueClick, ...rest } = this.props;
return (
@@ -17,6 +30,7 @@ export class EuiHorizontalBarSeries extends HorizontalBarSeries {
stroke: 'white',
rx: 2,
ry: 2,
+ cursor: isMouseOverValue && onValueClick ? 'pointer' : 'default',
}}
data={data}
{...rest}
diff --git a/src/components/xy_chart/series/horizontal_rect_series.js b/src/components/xy_chart/series/horizontal_rect_series.js
index b5515e8d90a5..0b213e61b49f 100644
--- a/src/components/xy_chart/series/horizontal_rect_series.js
+++ b/src/components/xy_chart/series/horizontal_rect_series.js
@@ -4,7 +4,20 @@ import { HorizontalRectSeries } from 'react-vis';
import { VISUALIZATION_COLORS } from '../../../services';
export class EuiHorizontalRectSeries extends HorizontalRectSeries {
+ state = {
+ isMouseOverValue: false,
+ }
+
+ _onValueMouseOver = () => {
+ this.setState(() => ({ isMouseOverValue: true }));
+ }
+
+ _onValueMouseOut = () => {
+ this.setState(() => ({ isMouseOverValue: false }));
+ }
+
render() {
+ const { isMouseOverValue } = this.state;
const { name, data, color, onValueClick, ...rest } = this.props;
return (
@@ -17,6 +30,7 @@ export class EuiHorizontalRectSeries extends HorizontalRectSeries {
stroke: 'white',
rx: 2,
ry: 2,
+ cursor: isMouseOverValue && onValueClick ? 'pointer' : 'default',
}}
data={data}
{...rest}
diff --git a/src/components/xy_chart/series/vertical_bar_series.js b/src/components/xy_chart/series/vertical_bar_series.js
index 47264e967bd7..7a81e16d1a64 100644
--- a/src/components/xy_chart/series/vertical_bar_series.js
+++ b/src/components/xy_chart/series/vertical_bar_series.js
@@ -5,33 +5,34 @@ import { VISUALIZATION_COLORS } from '../../../services';
export class EuiVerticalBarSeries extends VerticalBarSeries {
state = {
- hoverBars: false,
+ isMouseOverValue: false,
}
- _handleOnSeriesOver = () => {
- this.setState(() => { hoverBars: true })
+
+ _onValueMouseOver = () => {
+ this.setState(() => ({ isMouseOverValue: true }));
}
- _handleOnSeriesOut = () => {
- this.setState(() => { hoverBars: false })
+
+ _onValueMouseOut = () => {
+ this.setState(() => ({ isMouseOverValue: false }));
}
+
render() {
+ const { isMouseOverValue } = this.state
const { name, data, color, onValueClick, ...rest } = this.props;
- const { hoverBars } = this.state
const isHighDataVolume = data.length > 80 ? true : false;
- const canHover = hoverBars && onValueClick
- console.log('canHover',canHover)
return (
{
+ this.setState(() => ({ isMouseOverValue: true }));
+ }
+
+ _onValueMouseOut = () => {
+ this.setState(() => ({ isMouseOverValue: false }));
+ }
+
render() {
+ const { isMouseOverValue } = this.state;
const { name, data, color, onValueClick, ...rest } = this.props;
const isHighDataVolume = data.length > 80 ? true : false;
@@ -12,12 +25,15 @@ export class EuiVerticalRectSeries extends VerticalRectSeries {
Date: Tue, 26 Jun 2018 19:15:09 +0200
Subject: [PATCH 46/68] Move curves to enum
---
.../src/views/xy_chart_line/curved_line.js | 37 +++++++++++++------
src/components/xy_chart/series/area_series.js | 6 ++-
src/components/xy_chart/series/line_series.js | 5 ++-
src/components/xy_chart/utils/chart_utils.js | 18 ++++++++-
4 files changed, 49 insertions(+), 17 deletions(-)
diff --git a/src-docs/src/views/xy_chart_line/curved_line.js b/src-docs/src/views/xy_chart_line/curved_line.js
index 07dc833a1107..2c4f2d07c247 100644
--- a/src-docs/src/views/xy_chart_line/curved_line.js
+++ b/src-docs/src/views/xy_chart_line/curved_line.js
@@ -7,8 +7,23 @@ import {
EuiSpacer,
EuiXYChart,
EuiLineSeries,
+ EuiXYChartUtils,
} from '../../../../src/components';
+const {
+ LINEAR,
+ CURVE_CARDINAL,
+ CURVE_NATURAL,
+ CURVE_MONOTONE_X,
+ CURVE_MONOTONE_Y,
+ CURVE_BASIS,
+ CURVE_BUNDLE,
+ CURVE_CATMULL_ROM,
+ CURVE_STEP,
+ CURVE_STEP_AFTER,
+ CURVE_STEP_BEFORE,
+} = EuiXYChartUtils.CURVES;
+
const DATA_A = [{ x: 0, y: 1 }, { x: 1, y: 1 }, { x: 2, y: 2 }, { x: 3, y: -1 }, { x: 5, y: 2 }];
export default class extends Component {
@@ -16,17 +31,17 @@ export default class extends Component {
super(props);
this.options = [
- { value: 'linear', text: 'Linear' },
- { value: 'curveCardinal', text: 'Curve Cardinal' },
- { value: 'curveNatural', text: 'Curve Natural' },
- { value: 'curveMonotoneX', text: 'Curve Monotone X' },
- { value: 'curveMonotoneY', text: 'Curve Monotone Y' },
- { value: 'curveBasis', text: 'Curve Basis' },
- { value: 'curveBundle', text: 'Curve Bundle' },
- { value: 'curveCatmullRom', text: 'Curve Catmull Rom' },
- { value: 'curveStep', text: 'Curve Step' },
- { value: 'curveStepAfter', text: 'Curve Step After' },
- { value: 'curveStepBefore', text: 'Curve Step Before' },
+ { value: LINEAR, text: 'Linear' },
+ { value: CURVE_CARDINAL, text: 'Curve Cardinal' },
+ { value: CURVE_NATURAL, text: 'Curve Natural' },
+ { value: CURVE_MONOTONE_X, text: 'Curve Monotone X' },
+ { value: CURVE_MONOTONE_Y, text: 'Curve Monotone Y' },
+ { value: CURVE_BASIS, text: 'Curve Basis' },
+ { value: CURVE_BUNDLE, text: 'Curve Bundle' },
+ { value: CURVE_CATMULL_ROM, text: 'Curve Catmull Rom' },
+ { value: CURVE_STEP, text: 'Curve Step' },
+ { value: CURVE_STEP_AFTER, text: 'Curve Step After' },
+ { value: CURVE_STEP_BEFORE, text: 'Curve Step Before' },
];
this.state = {
diff --git a/src/components/xy_chart/series/area_series.js b/src/components/xy_chart/series/area_series.js
index 887ff6ce504b..85ac262c773b 100644
--- a/src/components/xy_chart/series/area_series.js
+++ b/src/components/xy_chart/series/area_series.js
@@ -2,6 +2,8 @@ import React from 'react';
import PropTypes from 'prop-types';
import { AreaSeries, AbstractSeries } from 'react-vis';
import { VISUALIZATION_COLORS } from '../../../services';
+import { CURVES } from '../utils/chart_utils';
+
export class EuiAreaSeries extends AbstractSeries {
state = {
isMouseOverSeries: false,
@@ -47,11 +49,11 @@ EuiAreaSeries.propTypes = {
).isRequired,
/** An EUI visualization color, the default value is enforced by EuiXYChart */
color: PropTypes.oneOf(VISUALIZATION_COLORS),
- curve: PropTypes.string,
+ curve: PropTypes.oneOf(Object.values(CURVES)),
onSeriesClick: PropTypes.func,
onMarkClick: PropTypes.func,
};
EuiAreaSeries.defaultProps = {
- curve: 'linear',
+ curve: CURVES.LINEAR,
};
diff --git a/src/components/xy_chart/series/line_series.js b/src/components/xy_chart/series/line_series.js
index 1167e34f46e1..69b7d689b47e 100644
--- a/src/components/xy_chart/series/line_series.js
+++ b/src/components/xy_chart/series/line_series.js
@@ -2,6 +2,7 @@ import React, { Fragment } from 'react';
import PropTypes from 'prop-types';
import { LineSeries, MarkSeries, AbstractSeries } from 'react-vis';
import { VISUALIZATION_COLORS } from '../../../services';
+import { CURVES } from '../utils/chart_utils';
export class EuiLineSeries extends AbstractSeries {
render() {
@@ -83,7 +84,7 @@ EuiLineSeries.propTypes = {
})).isRequired,
/** An EUI visualization color, the default value is enforced by EuiXYChart */
color: PropTypes.oneOf(VISUALIZATION_COLORS),
- curve: PropTypes.string,
+ curve: PropTypes.oneOf(Object.values(CURVES)),
showLineMarks: PropTypes.bool,
lineSize: PropTypes.number,
lineMarkColor: PropTypes.string,
@@ -93,7 +94,7 @@ EuiLineSeries.propTypes = {
};
EuiLineSeries.defaultProps = {
- curve: 'linear',
+ curve: CURVES.LINEAR,
showLineMarks: true,
lineSize: 2,
lineMarkSize: 5
diff --git a/src/components/xy_chart/utils/chart_utils.js b/src/components/xy_chart/utils/chart_utils.js
index c616052edf24..cb60e7927c27 100644
--- a/src/components/xy_chart/utils/chart_utils.js
+++ b/src/components/xy_chart/utils/chart_utils.js
@@ -1,10 +1,10 @@
-const ORIENTATION = {
+export const ORIENTATION = {
HORIZONTAL: 'horizontal',
VERTICAL: 'vertical',
BOTH: 'both',
};
-const SCALE_TYPE = {
+export const SCALE_TYPE = {
LINEAR: 'linear',
ORDINAL: 'ordinal',
CATEGORY: 'category',
@@ -13,8 +13,22 @@ const SCALE_TYPE = {
LOG: 'log',
LITERA: 'literal'
};
+export const CURVES = {
+ 'LINEAR': 'linear',
+ 'CURVE_CARDINAL': 'curveCardinal',
+ 'CURVE_NATURAL': 'curveNatural',
+ 'CURVE_MONOTONE_X': 'curveMonotoneX',
+ 'CURVE_MONOTONE_Y': 'curveMonotoneY',
+ 'CURVE_BASIS': 'curveBasis',
+ 'CURVE_BUNDLE': 'curveBundle',
+ 'CURVE_CATMULL_ROM': 'curveCatmullRom',
+ 'CURVE_STEP': 'curveStep',
+ 'CURVE_STEP_AFTER': 'curveStepAfter',
+ 'CURVE_STEP_BEFORE': 'curveStepBefore',
+}
export const EuiXYChartUtils = {
ORIENTATION,
SCALE_TYPE,
+ CURVES,
}
From df79e6d4e129ad003b47922bcfe87fe98f98f2b3 Mon Sep 17 00:00:00 2001
From: Marco Vettorello
Date: Tue, 26 Jun 2018 22:33:54 +0200
Subject: [PATCH 47/68] Update snapshots
---
.../__snapshots__/xy_chart.test.js.snap | 254 +-
.../__snapshots__/area_series.test.js.snap | 2266 +++----
.../horizontal_bar_series.test.js.snap | 352 +-
.../horizontal_rect_series.test.js.snap | 382 +-
.../__snapshots__/line_series.test.js.snap | 5482 +++++++++--------
.../vertical_bar_series.test.js.snap | 344 +-
.../vertical_rect_series.test.js.snap | 414 +-
src/components/xy_chart/xy_chart.js | 10 +-
src/components/xy_chart/xy_chart.test.js | 7 -
9 files changed, 4734 insertions(+), 4777 deletions(-)
diff --git a/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap b/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
index f591f58618f2..088fe1deb457 100644
--- a/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
+++ b/src/components/xy_chart/__snapshots__/xy_chart.test.js.snap
@@ -5,34 +5,40 @@ exports[`EuiXYChart is rendered (empty) 1`] = `
style="width:100%;height:100%"
>
@@ -42,36 +48,7 @@ exports[`EuiXYChart is rendered (empty) 1`] = `
exports[`EuiXYChart passes handler functions 1`] = `
-
-
-
-
-
+
-
+
+
+
+
+
+
+
-
-
-
-
-
- Graph not avaliable
-
+ Graph not avaliable
+
+
+
-
-
-
+
+
+
diff --git a/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap b/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap
index 48453c178dd8..c6f9a25254a4 100644
--- a/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap
+++ b/src/components/xy_chart/series/__snapshots__/area_series.test.js.snap
@@ -35,9 +35,8 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
-
-
+
-
-
-
+
-
-
-
-
-
-
+ transform="translate(0,0)"
+ />
+
+
+
+
@@ -1544,12 +1546,12 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
onZero={false}
opacityDomain={Array []}
opacityType="literal"
@@ -1581,7 +1583,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -1594,7 +1596,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -1654,12 +1656,12 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -1691,7 +1693,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -1704,7 +1706,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -1765,12 +1767,12 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -1804,7 +1806,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -1817,7 +1819,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -1896,12 +1898,12 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -1935,7 +1937,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -1948,7 +1950,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -2030,12 +2032,12 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -2069,7 +2071,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -2082,7 +2084,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -2091,19 +2093,19 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
@@ -2165,14 +2167,14 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- height={2}
- innerHeight={196}
- innerWidth={596}
- left={2}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ height={0}
+ innerHeight={200}
+ innerWidth={600}
+ left={0}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -2197,8 +2199,8 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
tickPadding={8}
tickSize={0}
tickTotal={10}
- top={198}
- width={596}
+ top={200}
+ width={600}
xDomain={
Array [
0,
@@ -2209,7 +2211,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -2222,7 +2224,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -2260,7 +2262,7 @@ exports[`EuiAreaSeries all props are rendered 1`] = `
className="rv-xy-plot__axis__tick"
key="1"
style={Object {}}
- transform="translate(59.6, 0)"
+ transform="translate(60, 0)"
>
-
-
+
-
-
-
+
-
-
-
-
-
-
+ transform="translate(0,0)"
+ />
+
+
+
+
@@ -5157,12 +5161,12 @@ exports[`EuiAreaSeries is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
onZero={false}
opacityDomain={Array []}
opacityType="literal"
@@ -5194,7 +5198,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -5207,7 +5211,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -5267,12 +5271,12 @@ exports[`EuiAreaSeries is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -5304,7 +5308,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -5317,7 +5321,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -5378,12 +5382,12 @@ exports[`EuiAreaSeries is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -5417,7 +5421,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -5430,7 +5434,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -5509,12 +5513,12 @@ exports[`EuiAreaSeries is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -5548,7 +5552,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -5561,7 +5565,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -5643,12 +5647,12 @@ exports[`EuiAreaSeries is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -5682,7 +5686,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -5695,7 +5699,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -5704,19 +5708,19 @@ exports[`EuiAreaSeries is rendered 1`] = `
@@ -5778,14 +5782,14 @@ exports[`EuiAreaSeries is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- height={2}
- innerHeight={196}
- innerWidth={596}
- left={2}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ height={0}
+ innerHeight={200}
+ innerWidth={600}
+ left={0}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -5810,8 +5814,8 @@ exports[`EuiAreaSeries is rendered 1`] = `
tickPadding={8}
tickSize={0}
tickTotal={10}
- top={198}
- width={596}
+ top={200}
+ width={600}
xDomain={
Array [
0,
@@ -5822,7 +5826,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -5835,7 +5839,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -5873,7 +5877,7 @@ exports[`EuiAreaSeries is rendered 1`] = `
className="rv-xy-plot__axis__tick"
key="1"
style={Object {}}
- transform="translate(59.6, 0)"
+ transform="translate(60, 0)"
>
-
-
-
-
-
+
+
+
@@ -117,7 +115,7 @@ exports[`EuiHorizontalBarSeries all props are rendered 1`] = `
-
-
-
-
-
+
+
+
@@ -561,7 +557,7 @@ exports[`EuiHorizontalBarSeries is rendered 1`] = `
-
-
-
-
-
+
+
+
-
-
-
-
-
+
+
+
@@ -1002,7 +994,7 @@ exports[`EuiHorizontalBarSeries renders stacked bar chart 1`] = `
>
-
-
-
-
-
+
+
+
@@ -117,7 +115,7 @@ exports[`EuiHorizontalRectSeries all props are rendered 1`] = `
-
-
-
-
-
+
+
+
@@ -561,7 +557,7 @@ exports[`EuiHorizontalRectSeries is rendered 1`] = `
-
-
-
-
-
+
+
+
-
-
-
-
-
+
+
+
@@ -1026,7 +1018,7 @@ exports[`EuiHorizontalRectSeries renders stacked bar chart 1`] = `
>
-
-
+
-
-
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
-
-
+
-
-
-
+
-
-
-
-
-
-
+ }
+ />
+
+
+
+
+
@@ -2549,12 +2561,12 @@ exports[`EuiLineSeries all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
onZero={false}
opacityDomain={Array []}
opacityType="literal"
@@ -2586,7 +2598,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -2599,7 +2611,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -2659,12 +2671,12 @@ exports[`EuiLineSeries all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -2696,7 +2708,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -2709,7 +2721,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -2770,12 +2782,12 @@ exports[`EuiLineSeries all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -2809,7 +2821,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -2822,7 +2834,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -2901,12 +2913,12 @@ exports[`EuiLineSeries all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -2940,7 +2952,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -2953,7 +2965,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -3035,12 +3047,12 @@ exports[`EuiLineSeries all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -3074,7 +3086,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -3087,7 +3099,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -3096,19 +3108,19 @@ exports[`EuiLineSeries all props are rendered 1`] = `
@@ -3170,14 +3182,14 @@ exports[`EuiLineSeries all props are rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- height={2}
- innerHeight={196}
- innerWidth={596}
- left={2}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ height={0}
+ innerHeight={200}
+ innerWidth={600}
+ left={0}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -3202,8 +3214,8 @@ exports[`EuiLineSeries all props are rendered 1`] = `
tickPadding={8}
tickSize={0}
tickTotal={10}
- top={198}
- width={596}
+ top={200}
+ width={600}
xDomain={
Array [
0,
@@ -3214,7 +3226,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -3227,7 +3239,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -3265,7 +3277,7 @@ exports[`EuiLineSeries all props are rendered 1`] = `
className="rv-xy-plot__axis__tick"
key="1"
style={Object {}}
- transform="translate(59.6, 0)"
+ transform="translate(60, 0)"
>
-
-
+
+
-
+
-
-
+
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
-
-
-
-
-
-
-
+
+
+
+
+
+
-
+
-
-
+
-
-
-
+
-
-
-
-
-
-
+ }
+ />
+
+
+
+
+
@@ -7168,12 +7186,12 @@ exports[`EuiLineSeries is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
onZero={false}
opacityDomain={Array []}
opacityType="literal"
@@ -7205,7 +7223,7 @@ exports[`EuiLineSeries is rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -7218,7 +7236,7 @@ exports[`EuiLineSeries is rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -7278,12 +7296,12 @@ exports[`EuiLineSeries is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -7315,7 +7333,7 @@ exports[`EuiLineSeries is rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -7328,7 +7346,7 @@ exports[`EuiLineSeries is rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -7389,12 +7407,12 @@ exports[`EuiLineSeries is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -7428,7 +7446,7 @@ exports[`EuiLineSeries is rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -7441,7 +7459,7 @@ exports[`EuiLineSeries is rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -7520,12 +7538,12 @@ exports[`EuiLineSeries is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -7559,7 +7577,7 @@ exports[`EuiLineSeries is rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -7572,7 +7590,7 @@ exports[`EuiLineSeries is rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -7654,12 +7672,12 @@ exports[`EuiLineSeries is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- innerHeight={196}
- innerWidth={596}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ innerHeight={200}
+ innerWidth={600}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -7693,7 +7711,7 @@ exports[`EuiLineSeries is rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -7706,7 +7724,7 @@ exports[`EuiLineSeries is rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -7715,19 +7733,19 @@ exports[`EuiLineSeries is rendered 1`] = `
@@ -7789,14 +7807,14 @@ exports[`EuiLineSeries is rendered 1`] = `
getX0={[Function]}
getY={[Function]}
getY0={[Function]}
- height={2}
- innerHeight={196}
- innerWidth={596}
- left={2}
- marginBottom={2}
- marginLeft={2}
- marginRight={2}
- marginTop={2}
+ height={0}
+ innerHeight={200}
+ innerWidth={600}
+ left={0}
+ marginBottom={0}
+ marginLeft={0}
+ marginRight={0}
+ marginTop={0}
on0={false}
opacityDomain={Array []}
opacityType="literal"
@@ -7821,8 +7839,8 @@ exports[`EuiLineSeries is rendered 1`] = `
tickPadding={8}
tickSize={0}
tickTotal={10}
- top={198}
- width={596}
+ top={200}
+ width={600}
xDomain={
Array [
0,
@@ -7833,7 +7851,7 @@ exports[`EuiLineSeries is rendered 1`] = `
xRange={
Array [
0,
- 596,
+ 600,
]
}
xType="linear"
@@ -7846,7 +7864,7 @@ exports[`EuiLineSeries is rendered 1`] = `
yPadding={0}
yRange={
Array [
- 196,
+ 200,
0,
]
}
@@ -7884,7 +7902,7 @@ exports[`EuiLineSeries is rendered 1`] = `
className="rv-xy-plot__axis__tick"
key="1"
style={Object {}}
- transform="translate(59.6, 0)"
+ transform="translate(60, 0)"
>
@@ -119,7 +119,7 @@ exports[`EuiVerticalBarSeries all props are rendered 1`] = `
>