Skip to content

Commit

Permalink
Refactoring exporting for utils
Browse files Browse the repository at this point in the history
  • Loading branch information
markov00 committed Jun 20, 2018
1 parent 0509196 commit 3340a43
Show file tree
Hide file tree
Showing 8 changed files with 16 additions and 35 deletions.
6 changes: 3 additions & 3 deletions src/components/xy_chart/axis/default_axis.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -30,9 +30,9 @@ export class EuiDefaultAxis extends PureComponent {
return (
<Fragment>
{showGridLines &&
orientation === EuiXYChartUtils.ORIENTATION.VERTICAL && <EuiHorizontalGrid {...rest} />}
orientation === ORIENTATION.VERTICAL && <EuiHorizontalGrid {...rest} />}
{showGridLines &&
orientation === EuiXYChartUtils.ORIENTATION.HORIZONTAL && <EuiVerticalGrid {...rest} />}
orientation === ORIENTATION.HORIZONTAL && <EuiVerticalGrid {...rest} />}

<EuiXAxis tickSize={0} {...rest} />
<EuiYAxis tickSize={0} {...rest} />
Expand Down
4 changes: 1 addition & 3 deletions src/components/xy_chart/axis/x_axis.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
4 changes: 1 addition & 3 deletions src/components/xy_chart/axis/y_axis.js
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
12 changes: 3 additions & 9 deletions src/components/xy_chart/utils/axis_utils.js
Original file line number Diff line number Diff line change
@@ -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,
};
7 changes: 1 addition & 6 deletions src/components/xy_chart/utils/chart_utils.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
const ORIENTATION = {
export const ORIENTATION = {
HORIZONTAL: 'horizontal',
VERTICAL: 'vertical',
BOTH: 'both',
};

export const EuiXYChartUtils = {
ORIENTATION,
}
6 changes: 3 additions & 3 deletions src/components/xy_chart/utils/index.js
Original file line number Diff line number Diff line change
@@ -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';
6 changes: 1 addition & 5 deletions src/components/xy_chart/utils/text_utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<tspan>
{
Expand All @@ -20,7 +20,3 @@ function tspanTextWrapper(texts) {
</tspan>
)
}

export const EuiXYChartTextUtils = {
tspanTextWrapper,
}
6 changes: 3 additions & 3 deletions src/components/xy_chart/xy_chart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
/**
Expand Down Expand Up @@ -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 (
Expand Down Expand Up @@ -168,7 +168,7 @@ XYChart.defaultProps = {
xPadding: 0,
truncateLegends: false,
showCrosshair: true,
orientation: EuiXYChartUtils.ORIENTATION.VERTICAL,
orientation: ORIENTATION.VERTICAL,
showDefaultAxis: true,

};
Expand Down

0 comments on commit 3340a43

Please sign in to comment.