Skip to content

Commit

Permalink
refactor: add d3 stack order and stack mode on stacked charts
Browse files Browse the repository at this point in the history
BREAKING CHANGE: PointStyleAccessor and BarStyleAccessor now calls the method with a DataSeriesDatum not with a RawDataSeriesDatum
  • Loading branch information
markov00 committed Jul 22, 2020
1 parent d3d9b61 commit 6220e49
Show file tree
Hide file tree
Showing 27 changed files with 4,873 additions and 3,446 deletions.
20 changes: 20 additions & 0 deletions .playground/data.ts

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions .playground/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
/*display: inline-block;
position: relative;
*/
width: 500px;
height: 200px;
width: 800px;
height: 400px;
overflow: auto;
}

Expand Down
45 changes: 38 additions & 7 deletions .playground/playground.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
Expand All @@ -19,7 +20,8 @@

import React from 'react';

import { Chart, BarSeries, Axis, Position, ScaleType } from '../src';
import { Chart, AreaSeries, Axis, Position, ScaleType, Fit, Settings, CurveType, timeFormatter, niceTimeFormatByDay } from '../src';
import { data } from './data';

export class Playground extends React.Component {
render() {
Expand All @@ -30,22 +32,51 @@ export class Playground extends React.Component {
<Axis
id="y"
position={Position.Left}
domain={{ fit: true }}
/>
<BarSeries
<Axis
id="x"
position={Position.Bottom}
tickFormat={timeFormatter(niceTimeFormatByDay(365 * 10))}
/>
<Settings />

<AreaSeries
id="spec1"
xAccessor="date"
yAccessors={['count']}
// y0Accessors={['metric0']}
splitSeriesAccessors={['series']}
stackAccessors={['date']}
xScaleType={ScaleType.Time}
fit={Fit.Lookahead}
curve={CurveType.CURVE_MONOTONE_X}
// areaSeriesStyle={{ point: { visible: true } }}
// stackAsPercentage
data={data.filter((d) => d.year !== 2006 || d.series !== 'Manufacturing')}
/>

{/* <AreaSeries
id="spec2"
yAccessors={['y1']}
splitSeriesAccessors={['g']}
stackAccessors={['x']}
// stackAccessors={['x']}
xScaleType={ScaleType.Linear}
fit={Fit.Carry}
areaSeriesStyle={{
point: {
visible: true,
},
}}
data={[
{ x: 1, y1: 1, g: 'a' },
{ x: 2, y1: 2, g: 'a' },
{ x: 3, y1: 2, g: 'a' },
{ x: 4, y1: 4, g: 'a' },
{ x: 1, y1: 21, g: 'b' },
{ x: 3, y1: 23, g: 'b' },
// { x: 1, y1: 21, g: 'b' },
// { x: 2, y1: 5, g: 'b' },
// { x: 3, y1: 23, g: 'b' },
]}
/>
/> */}
</Chart>
</div>
</div>
Expand Down
22 changes: 11 additions & 11 deletions src/chart_types/xy_chart/domains/x_domain.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import { ChartTypes } from '../..';
import { ScaleType } from '../../../scales/constants';
import { SpecTypes } from '../../../specs/constants';
import { getSplittedSeries } from '../utils/series';
import { getDataSeriesBySpecId } from '../utils/series';
import { BasicSeriesSpec, SeriesTypes } from '../utils/specs';
import { convertXScaleTypes, findMinInterval, mergeXDomain } from './x_domain';

Expand Down Expand Up @@ -221,7 +221,7 @@ describe('X Domain', () => {
],
};
const specDataSeries: BasicSeriesSpec[] = [ds1, ds2];
const { xValues } = getSplittedSeries(specDataSeries);
const { xValues } = getDataSeriesBySpecId(specDataSeries);
const mergedDomain = mergeXDomain(
[
{
Expand Down Expand Up @@ -268,7 +268,7 @@ describe('X Domain', () => {
};
const specDataSeries = [ds1, ds2];

const { xValues } = getSplittedSeries(specDataSeries);
const { xValues } = getDataSeriesBySpecId(specDataSeries);
const mergedDomain = mergeXDomain(
[
{
Expand Down Expand Up @@ -315,7 +315,7 @@ describe('X Domain', () => {
};
const specDataSeries = [ds1, ds2];

const { xValues } = getSplittedSeries(specDataSeries);
const { xValues } = getDataSeriesBySpecId(specDataSeries);
const mergedDomain = mergeXDomain(
[
{
Expand Down Expand Up @@ -366,7 +366,7 @@ describe('X Domain', () => {
};
const specDataSeries = [ds1, ds2];

const { xValues } = getSplittedSeries(specDataSeries);
const { xValues } = getDataSeriesBySpecId(specDataSeries);
const mergedDomain = mergeXDomain(
[
{
Expand Down Expand Up @@ -417,7 +417,7 @@ describe('X Domain', () => {
};
const specDataSeries = [ds1, ds2];

const { xValues } = getSplittedSeries(specDataSeries);
const { xValues } = getDataSeriesBySpecId(specDataSeries);
const mergedDomain = mergeXDomain(
[
{
Expand Down Expand Up @@ -471,7 +471,7 @@ describe('X Domain', () => {
};
const specDataSeries = [ds1, ds2];

const { xValues } = getSplittedSeries(specDataSeries);
const { xValues } = getDataSeriesBySpecId(specDataSeries);
const mergedDomain = mergeXDomain(
[
{
Expand Down Expand Up @@ -523,7 +523,7 @@ describe('X Domain', () => {
};
const specDataSeries = [ds1, ds2];

const { xValues } = getSplittedSeries(specDataSeries);
const { xValues } = getDataSeriesBySpecId(specDataSeries);
const mergedDomain = mergeXDomain(
[
{
Expand Down Expand Up @@ -574,7 +574,7 @@ describe('X Domain', () => {
};
const specDataSeries = [ds1, ds2];

const { xValues } = getSplittedSeries(specDataSeries);
const { xValues } = getDataSeriesBySpecId(specDataSeries);
const mergedDomain = mergeXDomain(
[
{
Expand Down Expand Up @@ -625,7 +625,7 @@ describe('X Domain', () => {
};
const specDataSeries = [ds1, ds2];

const { xValues } = getSplittedSeries(specDataSeries);
const { xValues } = getDataSeriesBySpecId(specDataSeries);
const mergedDomain = mergeXDomain(
[
{
Expand Down Expand Up @@ -670,7 +670,7 @@ describe('X Domain', () => {
};
const specDataSeries = [ds1, ds2];

const { xValues } = getSplittedSeries(specDataSeries);
const { xValues } = getDataSeriesBySpecId(specDataSeries);

const mergedDomain = mergeXDomain(
[
Expand Down
Loading

0 comments on commit 6220e49

Please sign in to comment.