Skip to content

Commit ab19df0

Browse files
authored
fix: cleanup example prop default values (#173)
SVG renderer is not ready yet, this commit will set the rendering to `canvas` as default. The BasicSeries component and all the code that use `basic` series type is removed.
1 parent b8df1f0 commit ab19df0

File tree

18 files changed

+180
-345
lines changed

18 files changed

+180
-345
lines changed

src/components/chart.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,17 @@ import { ReactiveChart as SVGChart } from './svg/reactive_chart';
1414
import { Tooltips } from './tooltips';
1515

1616
interface ChartProps {
17-
renderer: 'svg' | 'canvas' | 'canvas_old';
17+
/** The type of rendered
18+
* @default 'canvas'
19+
*/
20+
renderer: 'svg' | 'canvas';
1821
size?: [number, number];
1922
className?: string;
2023
}
2124

2225
export class Chart extends React.Component<ChartProps> {
23-
static defaultProps: Pick<ChartProps, 'renderer'> = {
24-
renderer: 'svg',
26+
static defaultProps: ChartProps = {
27+
renderer: 'canvas',
2528
};
2629
private chartSpecStore: ChartStore;
2730
constructor(props: any) {

src/lib/series/specs.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ export interface SeriesSpec {
4242
/** An array of data */
4343
data: Datum[];
4444
/** The type of series you are looking to render */
45-
seriesType: 'bar' | 'line' | 'area' | 'basic';
45+
seriesType: 'bar' | 'line' | 'area';
4646
/** Custom colors for series */
4747
customSeriesColors?: CustomSeriesColorsMap;
4848
/** If the series should appear in the legend
@@ -88,7 +88,10 @@ export interface SeriesScales {
8888
* @default ScaleType.Linear
8989
*/
9090
yScaleType: ScaleContinuousType;
91-
/** if true, the min y value is set to the minimum domain value, 0 otherwise */
91+
/**
92+
* if true, the min y value is set to the minimum domain value, 0 otherwise
93+
* @default false
94+
*/
9295
yScaleToDataExtent: boolean;
9396
}
9497

src/specs/basic_series.tsx

Lines changed: 0 additions & 34 deletions
This file was deleted.

src/specs/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
export { Axis } from './axis';
2-
export { BasicSeries } from './basic_series';
32
export { LineAnnotation } from './line_annotation';
43
export { LineSeries } from './line_series';
54
export { BarSeries } from './bar_series';

src/state/utils.ts

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import {
1111
renderArea,
1212
renderBars,
1313
renderLine,
14-
renderPoints,
1514
} from '../lib/series/rendering';
1615
import { computeXScale, computeYScales, countBarsInCluster } from '../lib/series/scales';
1716
import {
@@ -309,7 +308,7 @@ export function renderGeometries(
309308
const bars: BarGeometry[] = [];
310309
const areas: AreaGeometry[] = [];
311310
const lines: LineGeometry[] = [];
312-
let pointGeometriesIndex: Map<any, IndexedGeometry[]> = new Map();
311+
const pointGeometriesIndex: Map<any, IndexedGeometry[]> = new Map();
313312
let barGeometriesIndex: Map<any, IndexedGeometry[]> = new Map();
314313
let lineGeometriesIndex: Map<any, IndexedGeometry[]> = new Map();
315314
let areaGeometriesIndex: Map<any, IndexedGeometry[]> = new Map();
@@ -329,26 +328,6 @@ export function renderGeometries(
329328
}
330329
const color = seriesColorsMap.get(ds.seriesColorKey) || defaultColor;
331330
switch (spec.seriesType) {
332-
case 'basic':
333-
const pointShift = clusteredCount > 0 ? clusteredCount : 1;
334-
335-
const renderedPoints = renderPoints(
336-
(xScale.bandwidth * pointShift) / 2,
337-
ds.data,
338-
xScale,
339-
yScale,
340-
color,
341-
ds.specId,
342-
Boolean(spec.y0Accessors),
343-
ds.key,
344-
);
345-
points.push(...renderedPoints.pointGeometries);
346-
pointGeometriesIndex = mergeGeometriesIndexes(
347-
pointGeometriesIndex,
348-
renderedPoints.indexedGeometries,
349-
);
350-
geometriesCounts.points += renderedPoints.pointGeometries.length;
351-
break;
352331
case 'bar':
353332
const shift = isStacked ? indexOffset : indexOffset + i;
354333
const barSeriesStyle = spec.barSeriesStyle;

stories/annotations.tsx

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ storiesOf('Annotations', module)
6969
const axisPosition = isBottom ? Position.Bottom : Position.Top;
7070

7171
return (
72-
<Chart renderer="canvas" className={'story-chart'}>
72+
<Chart className={'story-chart'}>
7373
<Settings debug={boolean('debug', false)} rotation={chartRotation} />
7474
<LineAnnotation
7575
annotationId={getAnnotationId('anno_1')}
@@ -87,7 +87,6 @@ storiesOf('Annotations', module)
8787
xAccessor="x"
8888
yAccessors={['y']}
8989
data={[{ x: 0, y: 2 }, { x: 1, y: 7 }, { x: 3, y: 6 }]}
90-
yScaleToDataExtent={false}
9190
/>
9291
</Chart>
9392
);
@@ -107,7 +106,7 @@ storiesOf('Annotations', module)
107106
);
108107

109108
return (
110-
<Chart renderer="canvas" className={'story-chart'}>
109+
<Chart className={'story-chart'}>
111110
<Settings debug={boolean('debug', false)} rotation={chartRotation} />
112111
<LineAnnotation
113112
annotationId={getAnnotationId('anno_1')}
@@ -129,7 +128,6 @@ storiesOf('Annotations', module)
129128
xAccessor="x"
130129
yAccessors={['y']}
131130
data={[{ x: 'a', y: 2 }, { x: 'b', y: 7 }, { x: 'c', y: 3 }, { x: 'd', y: 6 }]}
132-
yScaleToDataExtent={false}
133131
/>
134132
</Chart>
135133
);
@@ -154,7 +152,7 @@ storiesOf('Annotations', module)
154152
const axisPosition = isLeft ? Position.Left : Position.Right;
155153

156154
return (
157-
<Chart renderer="canvas" className={'story-chart'}>
155+
<Chart className={'story-chart'}>
158156
<Settings debug={boolean('debug', false)} rotation={chartRotation} />
159157
<LineAnnotation
160158
annotationId={getAnnotationId('anno_')}
@@ -171,7 +169,6 @@ storiesOf('Annotations', module)
171169
xAccessor="x"
172170
yAccessors={['y']}
173171
data={[{ x: 0, y: 2 }, { x: 1, y: 7 }, { x: 2, y: 3 }, { x: 3, y: 6 }]}
174-
yScaleToDataExtent={false}
175172
/>
176173
</Chart>
177174
);
@@ -197,7 +194,7 @@ storiesOf('Annotations', module)
197194
);
198195

199196
return (
200-
<Chart renderer="canvas" className={'story-chart'}>
197+
<Chart className={'story-chart'}>
201198
<Settings debug={boolean('debug', false)} rotation={chartRotation} />
202199
<LineAnnotation
203200
annotationId={getAnnotationId('anno_1')}
@@ -219,7 +216,6 @@ storiesOf('Annotations', module)
219216
xAccessor={0}
220217
yAccessors={[1]}
221218
data={KIBANA_METRICS.metrics.kibana_os_load[0].data.slice(0, 20)}
222-
yScaleToDataExtent={false}
223219
/>
224220
</Chart>
225221
);
@@ -263,7 +259,7 @@ storiesOf('Annotations', module)
263259
const hideTooltips = boolean('annotation tooltips hidden', false);
264260

265261
return (
266-
<Chart renderer="canvas" className={'story-chart'}>
262+
<Chart className={'story-chart'}>
267263
<Settings debug={boolean('debug', false)} rotation={chartRotation} />
268264
<LineAnnotation
269265
annotationId={getAnnotationId('anno_1')}
@@ -283,7 +279,6 @@ storiesOf('Annotations', module)
283279
xAccessor="x"
284280
yAccessors={['y']}
285281
data={[{ x: 0, y: 2 }, { x: 1, y: 7 }, { x: 3, y: 6 }]}
286-
yScaleToDataExtent={false}
287282
/>
288283
</Chart>
289284
);

0 commit comments

Comments
 (0)