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: add series name settings #539

Merged
merged 21 commits into from
Feb 24, 2020
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
a6ead1c
feat: add series label settings
nickofthyme Feb 6, 2020
ebd5fcc
tests: update tests
nickofthyme Feb 10, 2020
9bc6baa
Merge branch 'master' into feat/add-labeling-options
nickofthyme Feb 10, 2020
f6e6d90
chore: udpate pr comments
nickofthyme Feb 10, 2020
88cecd1
chore: fix type/lint errors
nickofthyme Feb 10, 2020
6e9ee73
refactor: update custom series label api
nickofthyme Feb 11, 2020
f056b77
chore: add parsing action and split tooltipValues (#516)
markov00 Feb 13, 2020
2242fca
refactor: decouple legend and tooltip phase 1 (#491)
markov00 Feb 14, 2020
fd759be
Merge branch 'master' into feat/add-labeling-options
nickofthyme Feb 18, 2020
a1b1950
refactor: move custom labeling to name and update logic
nickofthyme Feb 18, 2020
8262d19
docs: fix filteredLabel ids (#552)
markov00 Feb 19, 2020
c7fd818
Fix story naming
nickofthyme Feb 19, 2020
4298157
Merge branch 'master' into feat/add-labeling-options
nickofthyme Feb 19, 2020
1ed6957
refactor: decouple tooltip from XY chart (#553)
markov00 Feb 20, 2020
55f9712
chore: address pr comments
nickofthyme Feb 20, 2020
15eb37f
Merge branch 'master' into feat/add-labeling-options
nickofthyme Feb 20, 2020
76f000f
chore: update screenshots
nickofthyme Feb 20, 2020
264980d
Merge branch 'master' into feat/add-labeling-options
nickofthyme Feb 21, 2020
f8ba94a
Merge branch 'master' into feat/add-labeling-options
nickofthyme Feb 21, 2020
9dcb740
udpate screenshots
nickofthyme Feb 21, 2020
9a6828e
chore: address pr comments
nickofthyme Feb 24, 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
58 changes: 29 additions & 29 deletions .playground/playground.tsx
Original file line number Diff line number Diff line change
@@ -1,39 +1,39 @@
import React from 'react';
import { Chart, ScaleType, Position, Axis, getAxisId, timeFormatter, getSpecId, AreaSeries } from '../src';
import { KIBANA_METRICS } from '../src/utils/data_samples/test_dataset_kibana';
export class Playground extends React.Component {
chartRef: React.RefObject<Chart> = React.createRef();
onBrushEnd = (min: number, max: number) => {
// eslint-disable-next-line no-console
console.log({ min, max });
};

import { Chart, LineSeries, ScaleType, Position, Axis } from '../src';
import { SeededDataGenerator } from '../src/mocks/utils';

export class Playground extends React.Component<{}, { isSunburstShown: boolean }> {
render() {
const dg = new SeededDataGenerator();
const data = dg.generateGroupedSeries(10, 2).map((item) => ({
...item,
y1: item.y + 100,
}));

return (
<>
<div className="chart">
<Chart className={'story-chart'}>
<Axis
id={getAxisId('bottom')}
title={'timestamp per 1 minute'}
position={Position.Bottom}
showOverlappingTicks={true}
tickFormat={timeFormatter('HH:mm')}
<Chart>
<Axis id="y1" position={Position.Left} title={'y1'} />
<Axis id="y2" domain={{ fit: true }} groupId="g2" position={Position.Right} title={'y2'} />
<Axis id="x" position={Position.Bottom} title={'x'} />
<LineSeries
id="line1"
xScaleType={ScaleType.Linear}
xAccessor={'x'}
yAccessors={['y']}
splitSeriesAccessors={['g']}
data={data}
/>
<Axis
id={getAxisId('left')}
title={KIBANA_METRICS.metrics.kibana_os_load[0].metric.title}
position={Position.Left}
tickFormat={(d) => Number(d).toFixed(2)}
/>

<AreaSeries
id={getSpecId('area')}
xScaleType={ScaleType.Time}
yScaleType={ScaleType.Linear}
xAccessor={0}
yAccessors={[1]}
data={KIBANA_METRICS.metrics.kibana_os_load[0].data}
<LineSeries
id="line2"
groupId="g2"
xScaleType={ScaleType.Linear}
xAccessor={'x'}
yAccessors={['y1']}
splitSeriesAccessors={['g']}
data={data}
/>
</Chart>
</div>
Expand Down
Binary file not shown.
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.
3 changes: 2 additions & 1 deletion src/chart_types/partition_chart/layout/types/config_types.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Distance, Pixels, Radian, Radius, Ratio, SizeRatio, TimeMs } from './geometry_types';
import { Color, Font, FontFamily, PartialFont } from './types';
import { Font, FontFamily, PartialFont } from './types';
import { $Values as Values } from 'utility-types';
import { Color } from '../../../../utils/commons';

export const PartitionLayout = Object.freeze({
sunburst: 'sunburst',
Expand Down
2 changes: 0 additions & 2 deletions src/chart_types/partition_chart/layout/types/types.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { ArrayEntry } from '../utils/group_by_rollup';

export type Color = string; // todo refine later (union type)

export const FONT_VARIANTS = Object.freeze(['normal', 'small-caps'] as const);
export type FontVariant = typeof FONT_VARIANTS[number];

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Config } from './config_types';
import { Coordinate, Distance, PointObject, PointTuple, Radian } from './geometry_types';
import { Color, Font } from './types';
import { Font } from './types';
import { config } from '../config/config';
import { ArrayNode } from '../utils/group_by_rollup';
import { Color } from '../../../../utils/commons';

export type LinkLabelVM = {
link: [PointTuple, ...PointTuple[]]; // at least one point
Expand Down
3 changes: 1 addition & 2 deletions src/chart_types/partition_chart/specs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,7 @@ import { getConnect, specComponentFactory } from '../../../state/spec_factory';
import { AccessorFn, IndexedAccessorFn } from '../../../utils/accessor';
import { Spec, SpecTypes } from '../../../specs/index';
import { Config, FillLabelConfig } from '../layout/types/config_types';
import { RecursivePartial } from '../../../utils/commons';
import { Datum } from '../../../utils/domain';
import { RecursivePartial, Datum } from '../../../utils/commons';

type ColorAccessor = (d: Datum, index: number, array: Datum[]) => string;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import * as React from 'react';

import { AnnotationDomainTypes, AnnotationSpec, Position, Rotation, AnnotationTypes } from '../utils/specs';
import { AnnotationDomainTypes, AnnotationSpec, AnnotationTypes } from '../utils/specs';
import { Position, Rotation } from '../../../utils/commons';
import { DEFAULT_ANNOTATION_LINE_STYLE } from '../../../utils/themes/theme';
import { Dimensions } from '../../../utils/dimensions';
import { GroupId } from '../../../utils/ids';
import { ScaleContinuous } from '../../../utils/scales/scale_continuous';
import { Scale, ScaleType } from '../../../utils/scales/scales';
import { Scale, ScaleType, ScaleContinuous } from '../../../scales';
import { computeLineAnnotationDimensions, AnnotationLineProps } from './line_annotation_tooltip';
import { ChartTypes } from '../..';
import { SpecTypes } from '../../../specs/settings';
Expand Down
7 changes: 2 additions & 5 deletions src/chart_types/xy_chart/annotations/annotation_utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,14 @@ import {
AnnotationSpec,
AxisSpec,
LineAnnotationSpec,
Position,
RectAnnotationSpec,
Rotation,
AnnotationTypes,
} from '../utils/specs';
import { Position, Rotation } from '../../../utils/commons';
import { DEFAULT_ANNOTATION_LINE_STYLE } from '../../../utils/themes/theme';
import { Dimensions } from '../../../utils/dimensions';
import { getAxisId, getGroupId, GroupId, AnnotationId } from '../../../utils/ids';
import { ScaleBand } from '../../../utils/scales/scale_band';
import { ScaleContinuous } from '../../../utils/scales/scale_continuous';
import { Scale, ScaleType } from '../../../utils/scales/scales';
import { Scale, ScaleType, ScaleBand, ScaleContinuous } from '../../../scales';
import {
computeAnnotationDimensions,
computeAnnotationTooltipState,
Expand Down
5 changes: 2 additions & 3 deletions src/chart_types/xy_chart/annotations/annotation_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import {
HistogramModeAlignments,
isLineAnnotation,
isRectAnnotation,
Position,
Rotation,
} from '../utils/specs';
import { Dimensions } from '../../../utils/dimensions';
import { AnnotationId, GroupId } from '../../../utils/ids';
import { Scale, ScaleType } from '../../../utils/scales/scales';
import { Scale, ScaleType } from '../../../scales';
import { computeXScaleOffset, getAxesSpecForSpecId, isHorizontalRotation, getSpecsById } from '../state/utils';
import { Point } from '../../../utils/point';
import {
Expand All @@ -25,6 +23,7 @@ import {
AnnotationRectProps,
computeRectAnnotationDimensions,
} from './rect_annotation_tooltip';
import { Rotation, Position } from '../../../utils/commons';

export type AnnotationTooltipFormatter = (details?: string) => JSX.Element | null;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ import {
AnnotationDomainType,
AnnotationDomainTypes,
AnnotationTypes,
Position,
Rotation,
LineAnnotationSpec,
LineAnnotationDatum,
AxisSpec,
} from '../utils/specs';
import { Position, Rotation } from '../../../utils/commons';
import {
AnnotationTooltipState,
AnnotationDetails,
Expand All @@ -19,7 +18,7 @@ import {
import { isHorizontalRotation, getAxesSpecForSpecId } from '../state/utils';
import { isHorizontalAxis } from '../utils/axis_utils';
import { Dimensions } from '../../../utils/dimensions';
import { Scale } from '../../../utils/scales/scales';
import { Scale } from '../../../scales';
import { GroupId } from '../../../utils/ids';
import { LineAnnotationStyle } from '../../../utils/themes/theme';
import { Point } from '../../../utils/point';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { AnnotationTypes, RectAnnotationDatum, RectAnnotationSpec, Rotation } from '../utils/specs';
import { AnnotationTypes, RectAnnotationDatum, RectAnnotationSpec } from '../utils/specs';
import { Rotation } from '../../../utils/commons';
import { Dimensions } from '../../../utils/dimensions';
import { GroupId } from '../../../utils/ids';
import { Scale } from '../../../utils/scales/scales';
import { Scale } from '../../../scales';
import { Point } from '../../../utils/point';
import {
AnnotationTooltipFormatter,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { computeXScale } from '../utils/scales';
import { BasicSeriesSpec, SeriesTypes } from '../utils/specs';
import { Dimensions } from '../../../utils/dimensions';
import { getGroupId, getSpecId } from '../../../utils/ids';
import { ScaleType } from '../../../utils/scales/scales';
import { ScaleType } from '../../../scales';
import { getCursorBandPosition, getSnapPosition } from './crosshair_utils';
import { computeSeriesDomains } from '../state/utils';
import { ChartTypes } from '../..';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { computeXScale } from '../utils/scales';
import { BasicSeriesSpec, SeriesTypes } from '../utils/specs';
import { getGroupId, getSpecId } from '../../../utils/ids';
import { ScaleType } from '../../../utils/scales/scales';
import { ScaleType } from '../../../scales';
import { getSnapPosition } from './crosshair_utils';
import { computeSeriesDomains } from '../state/utils';
import { ChartTypes } from '../..';
Expand Down
4 changes: 2 additions & 2 deletions src/chart_types/xy_chart/crosshair/crosshair_utils.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Rotation } from '../utils/specs';
import { Rotation } from '../../../utils/commons';
import { Dimensions } from '../../../utils/dimensions';
import { Scale } from '../../../utils/scales/scales';
import { Scale } from '../../../scales';
import { isHorizontalRotation } from '../state/utils';
import { Point } from '../../../utils/point';

Expand Down
2 changes: 1 addition & 1 deletion src/chart_types/xy_chart/domains/domain.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Domain } from '../../../utils/domain';
import { ScaleType } from '../../../utils/scales/scales';
import { ScaleType } from '../../../scales';

export interface BaseDomain {
scaleType: ScaleType;
Expand Down
2 changes: 1 addition & 1 deletion src/chart_types/xy_chart/domains/x_domain.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ScaleType } from '../../../utils/scales/scales';
import { ScaleType } from '../../../scales';
import { getSplittedSeries } from '../utils/series';
import { BasicSeriesSpec, SeriesTypes } from '../utils/specs';
import { convertXScaleTypes, findMinInterval, mergeXDomain } from './x_domain';
Expand Down
2 changes: 1 addition & 1 deletion src/chart_types/xy_chart/domains/x_domain.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { isCompleteBound, isLowerBound, isUpperBound } from '../utils/axis_utils';
import { compareByValueAsc, identity, isNumberArray } from '../../../utils/commons';
import { computeContinuousDataDomain, computeOrdinalDataDomain, Domain } from '../../../utils/domain';
import { ScaleType } from '../../../utils/scales/scales';
import { ScaleType } from '../../../scales';
import { BasicSeriesSpec, DomainRange, SeriesTypes } from '../utils/specs';
import { BaseDomain } from './domain';

Expand Down
2 changes: 1 addition & 1 deletion src/chart_types/xy_chart/domains/y_domain.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ScaleType } from '../../../utils/scales/scales';
import { ScaleType } from '../../../scales';
import { RawDataSeries } from '../utils/series';
import { BasicSeriesSpec, DomainRange, SeriesTypes } from '../utils/specs';
import { BARCHART_1Y0G } from '../../../utils/data_samples/test_dataset';
Expand Down
2 changes: 1 addition & 1 deletion src/chart_types/xy_chart/domains/y_domain.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { BasicSeriesSpec, DomainRange, DEFAULT_GLOBAL_ID, SeriesTypes } from '../utils/specs';
import { GroupId, SpecId, getGroupId } from '../../../utils/ids';
import { ScaleContinuousType, ScaleType } from '../../../utils/scales/scales';
import { ScaleContinuousType, ScaleType } from '../../../scales';
import { isCompleteBound, isLowerBound, isUpperBound } from '../utils/axis_utils';
import { BaseDomain } from './domain';
import { RawDataSeries } from '../utils/series';
Expand Down
Loading