Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: wiggle and silhouette stacks #751

Merged
merged 30 commits into from
Jul 29, 2020
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
1e21b8d
refactor: remove unnecessary code
markov00 Jul 15, 2020
a40fcc7
refactor: code cleanup on series counts
markov00 Jul 15, 2020
4240a01
refactor: remove scaleToExtent from format
markov00 Jul 16, 2020
d3d9b61
Merge branch 'master' into 2020_07_15-stack_mode
markov00 Jul 16, 2020
6220e49
refactor: add d3 stack order and stack mode on stacked charts
markov00 Jul 22, 2020
11b2abe
Merge branch 'master' into 2020_07_15-stack_mode
markov00 Jul 22, 2020
2b73892
docs: update API signature
markov00 Jul 23, 2020
cbb1ccd
refactor: fix typings
markov00 Jul 23, 2020
bb2191f
feat: add various stackModes to bar and area charts
markov00 Jul 23, 2020
57cca57
fix: add streamgraph example and fix few screenshots
markov00 Jul 27, 2020
434e225
fix: fitting function should respect new datum format
markov00 Jul 28, 2020
5d0072f
test: update screenshot tests
markov00 Jul 28, 2020
e7ced6c
Merge branch 'master' into 2020_07_15-stack_mode
markov00 Jul 28, 2020
2af6f80
refactor: reset playground to its default
markov00 Jul 28, 2020
d35f124
test: unskip test
markov00 Jul 28, 2020
4028d7c
refactor: rename file
markov00 Jul 28, 2020
3f3e5cd
refactor: moved new data sample to datasample folder
markov00 Jul 28, 2020
6c2b913
test: cleanup tests
markov00 Jul 28, 2020
fdb00ea
refactor: rename StackModes to StackMode
markov00 Jul 28, 2020
259efec
test: update screenshot based on StackMode name change
markov00 Jul 28, 2020
aff9ecd
test: update last two screenshots
markov00 Jul 28, 2020
6919182
refactor: remove comments and cleanup code
markov00 Jul 29, 2020
3d99441
refactor: add comments on getDatumYValue
markov00 Jul 29, 2020
5a8b6a0
refactor: hasOffsetDifferentThanZero fn rename
markov00 Jul 29, 2020
63b29a6
test: add storybook test for fitted stacked charts
markov00 Jul 29, 2020
7e50ea1
test: remove unused knob from story
markov00 Jul 29, 2020
0517701
refactor: rollback changes to playground
markov00 Jul 29, 2020
df312fd
refactor: align clipping ranges on line and areas
markov00 Jul 29, 2020
af500d8
refactor: dry up some code
markov00 Jul 29, 2020
0a39b18
test: remove unnecessary test
markov00 Jul 29, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
72 changes: 70 additions & 2 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,13 +20,80 @@

import React from 'react';

import { Example } from '../stories/sunburst/15_single_sunburst';
import { Chart, AreaSeries, Axis, Position, Settings, StackModes } from '../src';

export class Playground extends React.Component {
render() {
return (
<div className="testing">
<div className="chart">{Example()}</div>
<div className="chart">
<Chart>
<Settings showLegend showLegendExtra />

<Axis
id="y"
position={Position.Left}
/>
<Axis
id="x"
position={Position.Bottom}
// tickFormat={timeFormatter(niceTimeFormatByDay(365 * 10))}
/>

<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')}
stackMode={StackModes.Percentage}
splitSeriesAccessors={['g']}
yAccessors={['y1']}
stackAccessors={['x']}
y0Accessors={['y0']}
data={[
{ x: 1, y0: 1, y1: 2, g: 'a' },
{ x: 2, y0: 2, y1: 2.5, g: 'a' },
{ x: 3, y0: 1, y1: 4, g: 'a' },
{ x: 4, y0: 1, y1: 2, g: 'a' },
{ x: 1, y0: 2, y1: 4, g: 'b' },
{ x: 2, y0: 2, y1: 5, g: 'b' },
{ x: 3, y0: 2, y1: 3, g: 'b' },
{ x: 4, y0: 2, y1: 5, g: 'b' },
]}
/>

{/* <AreaSeries
id="spec2"
yAccessors={['y1']}
splitSeriesAccessors={['g']}
// 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: 2, y1: 5, g: 'b' },
// { x: 3, y1: 23, g: 'b' },
]}
/> */}
</Chart>
</div>
</div>
);
}
Expand Down
25 changes: 21 additions & 4 deletions api/charts.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -225,10 +225,8 @@ export interface BarSeriesStyle {
rectBorder: RectBorderStyle;
}

// Warning: (ae-forgotten-export) The symbol "RawDataSeriesDatum" needs to be exported by the entry point index.d.ts
//
// @public
export type BarStyleAccessor = (datum: RawDataSeriesDatum, seriesIdentifier: XYChartSeriesIdentifier) => BarStyleOverride;
export type BarStyleAccessor = (datum: DataSeriesDatum, seriesIdentifier: XYChartSeriesIdentifier) => BarStyleOverride;

// @public (undocumented)
export type BarStyleOverride = RecursivePartial<BarSeriesStyle> | Color | null;
Expand Down Expand Up @@ -460,6 +458,18 @@ export class DataGenerator {
}[];
}

// @public (undocumented)
export interface DataSeriesDatum<T = any> {
datum: T;
filled?: FilledValues;
initialY0: number | null;
initialY1: number | null;
mark: number | null;
x: number | string;
y0: number | null;
y1: number | null;
}

// @public (undocumented)
export type Datum = any;

Expand Down Expand Up @@ -550,6 +560,13 @@ export interface ExternalPointerEventsSettings {
};
}

// @public (undocumented)
export interface FilledValues {
x?: number | string;
y0?: number;
y1?: number;
}

// Warning: (ae-missing-release-tag) "FillStyle" is exported by the package, but it is missing a release tag (@alpha, @beta, @public, or @internal)
//
// @public (undocumented)
Expand Down Expand Up @@ -1049,7 +1066,7 @@ export interface PointStyle {
}

// @public
export type PointStyleAccessor = (datum: RawDataSeriesDatum, seriesIdentifier: XYChartSeriesIdentifier) => PointStyleOverride;
export type PointStyleAccessor = (datum: DataSeriesDatum, seriesIdentifier: XYChartSeriesIdentifier) => PointStyleOverride;

// @public (undocumented)
export type PointStyleOverride = RecursivePartial<PointStyle> | Color | null;
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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 @@ -474,7 +474,7 @@ describe('X Domain', () => {
min: 0,
};

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

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

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

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

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

const mergedDomain = mergeXDomain(
[
Expand Down
Loading