@gravity-ui/chartkit 4.6.1 → 4.7.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/plugins/d3/examples/bar-x/Basic.d.ts +4 -0
- package/build/plugins/d3/examples/bar-x/Basic.js +78 -0
- package/build/plugins/d3/examples/bar-x/GroupedColumns.d.ts +2 -0
- package/build/plugins/d3/examples/bar-x/GroupedColumns.js +44 -0
- package/build/plugins/d3/examples/bar-x/StackedColumns.d.ts +2 -0
- package/build/plugins/d3/examples/bar-x/StackedColumns.js +45 -0
- package/build/plugins/d3/examples/nintendoGames.d.ts +62 -0
- package/build/plugins/d3/examples/nintendoGames.js +12037 -0
- package/build/plugins/d3/examples/pie/Basic.d.ts +2 -0
- package/build/plugins/d3/examples/pie/Basic.js +30 -0
- package/build/plugins/d3/examples/pie/Donut.d.ts +2 -0
- package/build/plugins/d3/examples/pie/Donut.js +31 -0
- package/build/plugins/d3/examples/scatter/Basic.d.ts +2 -0
- package/build/plugins/d3/examples/scatter/Basic.js +66 -0
- package/build/plugins/d3/renderer/components/AxisX.js +6 -7
- package/build/plugins/d3/renderer/components/AxisY.js +50 -18
- package/build/plugins/d3/renderer/components/Chart.js +24 -16
- package/build/plugins/d3/renderer/components/Legend.js +20 -22
- package/build/plugins/d3/renderer/components/Title.js +1 -1
- package/build/plugins/d3/renderer/components/Tooltip/DefaultContent.d.ts +2 -2
- package/build/plugins/d3/renderer/components/Tooltip/DefaultContent.js +8 -0
- package/build/plugins/d3/renderer/components/Tooltip/TooltipTriggerArea.d.ts +14 -0
- package/build/plugins/d3/renderer/components/Tooltip/TooltipTriggerArea.js +70 -0
- package/build/plugins/d3/renderer/components/Tooltip/index.d.ts +5 -3
- package/build/plugins/d3/renderer/components/Tooltip/index.js +4 -2
- package/build/plugins/d3/renderer/components/styles.css +3 -0
- package/build/plugins/d3/renderer/constants/defaults/axis.d.ts +9 -0
- package/build/plugins/d3/renderer/constants/defaults/axis.js +6 -0
- package/build/plugins/d3/renderer/constants/defaults/index.d.ts +1 -0
- package/build/plugins/d3/renderer/constants/defaults/index.js +1 -0
- package/build/plugins/d3/renderer/constants/defaults/series-options.d.ts +11 -0
- package/build/plugins/d3/renderer/constants/defaults/series-options.js +41 -0
- package/build/plugins/d3/renderer/constants/index.d.ts +0 -1
- package/build/plugins/d3/renderer/constants/index.js +0 -1
- package/build/plugins/d3/renderer/d3-dispatcher.d.ts +1 -0
- package/build/plugins/d3/renderer/d3-dispatcher.js +4 -0
- package/build/plugins/d3/renderer/hooks/index.d.ts +0 -1
- package/build/plugins/d3/renderer/hooks/index.js +0 -1
- package/build/plugins/d3/renderer/hooks/useAxisScales/index.d.ts +6 -5
- package/build/plugins/d3/renderer/hooks/useAxisScales/index.js +2 -1
- package/build/plugins/d3/renderer/hooks/useChartDimensions/index.js +8 -41
- package/build/plugins/d3/renderer/hooks/useChartDimensions/utils.d.ts +3 -0
- package/build/plugins/d3/renderer/hooks/useChartDimensions/utils.js +17 -4
- package/build/plugins/d3/renderer/hooks/useChartOptions/chart.d.ts +2 -4
- package/build/plugins/d3/renderer/hooks/useChartOptions/chart.js +4 -23
- package/build/plugins/d3/renderer/hooks/useChartOptions/index.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useChartOptions/index.js +2 -10
- package/build/plugins/d3/renderer/hooks/useChartOptions/title.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useChartOptions/title.js +1 -0
- package/build/plugins/d3/renderer/hooks/useChartOptions/types.d.ts +8 -5
- package/build/plugins/d3/renderer/hooks/useChartOptions/x-axis.d.ts +5 -3
- package/build/plugins/d3/renderer/hooks/useChartOptions/x-axis.js +61 -6
- package/build/plugins/d3/renderer/hooks/useChartOptions/y-axis.d.ts +1 -1
- package/build/plugins/d3/renderer/hooks/useChartOptions/y-axis.js +20 -12
- package/build/plugins/d3/renderer/hooks/useSeries/index.d.ts +1 -0
- package/build/plugins/d3/renderer/hooks/useSeries/index.js +8 -2
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-legend.js +8 -3
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-options.d.ts +3 -0
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-options.js +5 -0
- package/build/plugins/d3/renderer/hooks/useSeries/prepareSeries.js +6 -3
- package/build/plugins/d3/renderer/hooks/useSeries/types.d.ts +5 -1
- package/build/plugins/d3/renderer/hooks/useShapes/bar-x/index.d.ts +12 -0
- package/build/plugins/d3/renderer/hooks/useShapes/bar-x/index.js +91 -0
- package/build/plugins/d3/renderer/hooks/useShapes/bar-x/prepare-data.d.ts +19 -0
- package/build/plugins/d3/renderer/hooks/useShapes/{bar-x.js → bar-x/prepare-data.js} +7 -87
- package/build/plugins/d3/renderer/hooks/useShapes/index.d.ts +13 -10
- package/build/plugins/d3/renderer/hooks/useShapes/index.js +28 -13
- package/build/plugins/d3/renderer/hooks/useShapes/pie.d.ts +6 -4
- package/build/plugins/d3/renderer/hooks/useShapes/pie.js +98 -20
- package/build/plugins/d3/renderer/hooks/useShapes/scatter/index.d.ts +15 -0
- package/build/plugins/d3/renderer/hooks/useShapes/scatter/index.js +89 -0
- package/build/plugins/d3/renderer/hooks/useShapes/scatter/prepare-data.d.ts +19 -0
- package/build/plugins/d3/renderer/hooks/useShapes/scatter/prepare-data.js +55 -0
- package/build/plugins/d3/renderer/hooks/useShapes/styles.css +1 -9
- package/build/plugins/d3/renderer/hooks/useTooltip/index.d.ts +6 -6
- package/build/plugins/d3/renderer/hooks/useTooltip/index.js +15 -17
- package/build/plugins/d3/renderer/hooks/useTooltip/types.d.ts +0 -6
- package/build/plugins/d3/renderer/utils/axis-generators/bottom.d.ts +3 -1
- package/build/plugins/d3/renderer/utils/axis-generators/bottom.js +32 -22
- package/build/plugins/d3/renderer/utils/index.d.ts +5 -0
- package/build/plugins/d3/renderer/utils/index.js +13 -8
- package/build/plugins/d3/renderer/utils/math.d.ts +2 -0
- package/build/plugins/d3/renderer/utils/math.js +8 -0
- package/build/plugins/d3/renderer/utils/text.d.ts +6 -6
- package/build/plugins/d3/renderer/utils/text.js +24 -14
- package/build/types/widget-data/axis.d.ts +10 -0
- package/build/types/widget-data/series.d.ts +51 -0
- package/build/types/widget-data/tooltip.d.ts +18 -7
- package/package.json +2 -2
- package/build/plugins/d3/renderer/hooks/useChartEvents/index.d.ts +0 -5
- package/build/plugins/d3/renderer/hooks/useChartEvents/index.js +0 -15
- package/build/plugins/d3/renderer/hooks/useShapes/bar-x.d.ts +0 -21
- package/build/plugins/d3/renderer/hooks/useShapes/defaults.d.ts +0 -5
- package/build/plugins/d3/renderer/hooks/useShapes/defaults.js +0 -5
- package/build/plugins/d3/renderer/hooks/useShapes/scatter.d.ts +0 -19
- package/build/plugins/d3/renderer/hooks/useShapes/scatter.js +0 -89
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ChartKit } from '../../../../components/ChartKit';
|
|
3
|
+
import nintendoGames from '../nintendoGames';
|
|
4
|
+
import { groups } from 'd3';
|
|
5
|
+
function prepareData(field = 'platform') {
|
|
6
|
+
const gamesByPlatform = groups(nintendoGames, (item) => item[field]);
|
|
7
|
+
const data = gamesByPlatform.map(([value, games]) => ({
|
|
8
|
+
x: value,
|
|
9
|
+
y: games.length,
|
|
10
|
+
}));
|
|
11
|
+
return {
|
|
12
|
+
categories: gamesByPlatform.map(([key]) => key),
|
|
13
|
+
series: [
|
|
14
|
+
{
|
|
15
|
+
data,
|
|
16
|
+
name: 'Games released',
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export const BasicBarXChart = () => {
|
|
22
|
+
const { categories, series } = prepareData();
|
|
23
|
+
const widgetData = {
|
|
24
|
+
series: {
|
|
25
|
+
data: series.map((s) => ({
|
|
26
|
+
type: 'bar-x',
|
|
27
|
+
data: s.data,
|
|
28
|
+
name: s.name,
|
|
29
|
+
})),
|
|
30
|
+
},
|
|
31
|
+
xAxis: {
|
|
32
|
+
type: 'category',
|
|
33
|
+
categories: categories.map(String),
|
|
34
|
+
title: {
|
|
35
|
+
text: 'Game Platforms',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
yAxis: [{ title: { text: 'Number of games released' } }],
|
|
39
|
+
};
|
|
40
|
+
return React.createElement(ChartKit, { type: "d3", data: widgetData });
|
|
41
|
+
};
|
|
42
|
+
export const BasicLinearBarXChart = () => {
|
|
43
|
+
const { series } = prepareData('meta_score');
|
|
44
|
+
const widgetData = {
|
|
45
|
+
series: {
|
|
46
|
+
data: series.map((s) => ({
|
|
47
|
+
type: 'bar-x',
|
|
48
|
+
data: s.data,
|
|
49
|
+
name: s.name,
|
|
50
|
+
})),
|
|
51
|
+
},
|
|
52
|
+
xAxis: {
|
|
53
|
+
title: {
|
|
54
|
+
text: 'Meta scores',
|
|
55
|
+
},
|
|
56
|
+
},
|
|
57
|
+
};
|
|
58
|
+
return React.createElement(ChartKit, { type: "d3", data: widgetData });
|
|
59
|
+
};
|
|
60
|
+
export const BasicDateTimeBarXChart = () => {
|
|
61
|
+
const { series } = prepareData('date');
|
|
62
|
+
const widgetData = {
|
|
63
|
+
series: {
|
|
64
|
+
data: series.map((s) => ({
|
|
65
|
+
type: 'bar-x',
|
|
66
|
+
data: s.data,
|
|
67
|
+
name: s.name,
|
|
68
|
+
})),
|
|
69
|
+
},
|
|
70
|
+
xAxis: {
|
|
71
|
+
type: 'datetime',
|
|
72
|
+
title: {
|
|
73
|
+
text: 'Release date',
|
|
74
|
+
},
|
|
75
|
+
},
|
|
76
|
+
};
|
|
77
|
+
return React.createElement(ChartKit, { type: "d3", data: widgetData });
|
|
78
|
+
};
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ChartKit } from '../../../../components/ChartKit';
|
|
3
|
+
import nintendoGames from '../nintendoGames';
|
|
4
|
+
import { groups } from 'd3';
|
|
5
|
+
function prepareData() {
|
|
6
|
+
const grouped = groups(nintendoGames, (d) => d.platform, (d) => (d.date ? new Date(d.date).getFullYear() : 'unknown'));
|
|
7
|
+
const categories = [];
|
|
8
|
+
const series = grouped.map(([platform, years]) => {
|
|
9
|
+
return {
|
|
10
|
+
name: platform,
|
|
11
|
+
data: years.map(([year, list]) => {
|
|
12
|
+
categories.push(String(year));
|
|
13
|
+
return {
|
|
14
|
+
x: String(year),
|
|
15
|
+
y: list.length,
|
|
16
|
+
};
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
return { categories, series };
|
|
21
|
+
}
|
|
22
|
+
export const GroupedColumns = () => {
|
|
23
|
+
const { series, categories } = prepareData();
|
|
24
|
+
const data = series.map((s) => {
|
|
25
|
+
return {
|
|
26
|
+
type: 'bar-x',
|
|
27
|
+
name: s.name,
|
|
28
|
+
data: s.data,
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
const widgetData = {
|
|
32
|
+
series: {
|
|
33
|
+
data: data,
|
|
34
|
+
},
|
|
35
|
+
xAxis: {
|
|
36
|
+
type: 'category',
|
|
37
|
+
categories: categories.sort(),
|
|
38
|
+
title: {
|
|
39
|
+
text: 'Release year',
|
|
40
|
+
},
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
return React.createElement(ChartKit, { type: "d3", data: widgetData });
|
|
44
|
+
};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ChartKit } from '../../../../components/ChartKit';
|
|
3
|
+
import nintendoGames from '../nintendoGames';
|
|
4
|
+
import { groups } from 'd3';
|
|
5
|
+
function prepareData() {
|
|
6
|
+
const grouped = groups(nintendoGames, (d) => d.platform, (d) => (d.date ? new Date(d.date).getFullYear() : 'unknown'));
|
|
7
|
+
const categories = [];
|
|
8
|
+
const series = grouped.map(([platform, years]) => {
|
|
9
|
+
return {
|
|
10
|
+
name: platform,
|
|
11
|
+
data: years.map(([year, list]) => {
|
|
12
|
+
categories.push(String(year));
|
|
13
|
+
return {
|
|
14
|
+
x: String(year),
|
|
15
|
+
y: list.length,
|
|
16
|
+
};
|
|
17
|
+
}),
|
|
18
|
+
};
|
|
19
|
+
});
|
|
20
|
+
return { categories, series };
|
|
21
|
+
}
|
|
22
|
+
export const StackedColumns = () => {
|
|
23
|
+
const { series, categories } = prepareData();
|
|
24
|
+
const data = series.map((s) => {
|
|
25
|
+
return {
|
|
26
|
+
type: 'bar-x',
|
|
27
|
+
stacking: 'normal',
|
|
28
|
+
name: s.name,
|
|
29
|
+
data: s.data,
|
|
30
|
+
};
|
|
31
|
+
});
|
|
32
|
+
const widgetData = {
|
|
33
|
+
series: {
|
|
34
|
+
data: data,
|
|
35
|
+
},
|
|
36
|
+
xAxis: {
|
|
37
|
+
type: 'category',
|
|
38
|
+
categories: categories.sort(),
|
|
39
|
+
title: {
|
|
40
|
+
text: 'Release year',
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
};
|
|
44
|
+
return React.createElement(ChartKit, { type: "d3", data: widgetData });
|
|
45
|
+
};
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
declare const _default: ({
|
|
2
|
+
meta_score: null;
|
|
3
|
+
title: string;
|
|
4
|
+
platform: string;
|
|
5
|
+
date: number;
|
|
6
|
+
user_score: null;
|
|
7
|
+
link: string;
|
|
8
|
+
esrb_rating: string;
|
|
9
|
+
developers: string;
|
|
10
|
+
genres: string;
|
|
11
|
+
} | {
|
|
12
|
+
meta_score: number;
|
|
13
|
+
title: string;
|
|
14
|
+
platform: string;
|
|
15
|
+
date: number;
|
|
16
|
+
user_score: number;
|
|
17
|
+
link: string;
|
|
18
|
+
esrb_rating: string;
|
|
19
|
+
developers: string;
|
|
20
|
+
genres: string;
|
|
21
|
+
} | {
|
|
22
|
+
meta_score: null;
|
|
23
|
+
title: string;
|
|
24
|
+
platform: string;
|
|
25
|
+
date: number;
|
|
26
|
+
user_score: number;
|
|
27
|
+
link: string;
|
|
28
|
+
esrb_rating: string;
|
|
29
|
+
developers: string;
|
|
30
|
+
genres: string;
|
|
31
|
+
} | {
|
|
32
|
+
meta_score: null;
|
|
33
|
+
title: string;
|
|
34
|
+
platform: string;
|
|
35
|
+
date: null;
|
|
36
|
+
user_score: null;
|
|
37
|
+
link: string;
|
|
38
|
+
esrb_rating: string;
|
|
39
|
+
developers: string;
|
|
40
|
+
genres: string;
|
|
41
|
+
} | {
|
|
42
|
+
meta_score: number;
|
|
43
|
+
title: string;
|
|
44
|
+
platform: string;
|
|
45
|
+
date: number;
|
|
46
|
+
user_score: null;
|
|
47
|
+
link: string;
|
|
48
|
+
esrb_rating: string;
|
|
49
|
+
developers: string;
|
|
50
|
+
genres: string;
|
|
51
|
+
} | {
|
|
52
|
+
meta_score: number;
|
|
53
|
+
title: string;
|
|
54
|
+
platform: string;
|
|
55
|
+
date: null;
|
|
56
|
+
user_score: number;
|
|
57
|
+
link: string;
|
|
58
|
+
esrb_rating: string;
|
|
59
|
+
developers: string;
|
|
60
|
+
genres: string;
|
|
61
|
+
})[];
|
|
62
|
+
export default _default;
|