@gravity-ui/chartkit 4.13.0 → 4.15.0
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/constants/index.d.ts +1 -0
- package/build/constants/index.js +1 -0
- package/build/constants/widget-data.d.ts +27 -0
- package/build/constants/widget-data.js +29 -0
- package/build/i18n/keysets/en.json +6 -1
- package/build/i18n/keysets/ru.json +6 -1
- package/build/libs/chartkit-error/chartkit-error.d.ts +1 -0
- package/build/libs/chartkit-error/chartkit-error.js +1 -0
- package/build/plugins/d3/examples/ExampleWrapper.d.ts +7 -0
- package/build/plugins/d3/examples/ExampleWrapper.js +5 -0
- package/build/plugins/d3/examples/area/Basic.d.ts +2 -0
- package/build/plugins/d3/examples/area/Basic.js +34 -0
- package/build/plugins/d3/examples/area/StackedArea.d.ts +2 -0
- package/build/plugins/d3/examples/area/StackedArea.js +47 -0
- package/build/plugins/d3/examples/bar-x/Basic.js +19 -9
- package/build/plugins/d3/examples/bar-x/DataLabels.js +4 -2
- package/build/plugins/d3/examples/bar-x/GroupedColumns.js +4 -2
- package/build/plugins/d3/examples/bar-x/StackedColumns.js +4 -2
- package/build/plugins/d3/examples/bar-y/Basic.js +4 -2
- package/build/plugins/d3/examples/bar-y/GroupedColumns.js +4 -2
- package/build/plugins/d3/examples/bar-y/StackedColumns.js +4 -2
- package/build/plugins/d3/examples/combined/LineAndBarX.js +5 -3
- package/build/plugins/d3/examples/line/Basic.js +4 -2
- package/build/plugins/d3/examples/line/DataLabels.js +4 -2
- package/build/plugins/d3/examples/line/LineWithMarkers.js +4 -2
- package/build/plugins/d3/examples/line/Shapes.d.ts +2 -0
- package/build/plugins/d3/examples/line/Shapes.js +93 -0
- package/build/plugins/d3/examples/pie/Basic.js +4 -2
- package/build/plugins/d3/examples/pie/Donut.js +4 -2
- package/build/plugins/d3/examples/scatter/Basic.js +4 -2
- package/build/plugins/d3/renderer/D3Widget.js +27 -23
- package/build/plugins/d3/renderer/components/Legend.js +4 -0
- package/build/plugins/d3/renderer/components/Tooltip/DefaultContent.js +1 -0
- package/build/plugins/d3/renderer/components/Tooltip/TooltipTriggerArea.js +1 -1
- package/build/plugins/d3/renderer/constants/defaults/axis.d.ts +2 -0
- package/build/plugins/d3/renderer/constants/defaults/axis.js +1 -0
- package/build/plugins/d3/renderer/constants/defaults/series-options.js +16 -4
- package/build/plugins/d3/renderer/hooks/useAxisScales/index.js +3 -2
- package/build/plugins/d3/renderer/hooks/useChartOptions/y-axis.js +2 -1
- package/build/plugins/d3/renderer/hooks/useSeries/constants.d.ts +2 -1
- package/build/plugins/d3/renderer/hooks/useSeries/constants.js +5 -0
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-area.d.ts +19 -0
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-area.js +66 -0
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-bar-x.js +2 -7
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-bar-y.js +2 -7
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-line-series.d.ts +2 -0
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-line-series.js +13 -6
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-pie.d.ts +2 -1
- package/build/plugins/d3/renderer/hooks/useSeries/prepare-pie.js +11 -1
- package/build/plugins/d3/renderer/hooks/useSeries/prepareSeries.js +10 -1
- package/build/plugins/d3/renderer/hooks/useSeries/types.d.ts +50 -7
- package/build/plugins/d3/renderer/hooks/useSeries/utils.d.ts +2 -1
- package/build/plugins/d3/renderer/hooks/useSeries/utils.js +10 -0
- package/build/plugins/d3/renderer/hooks/useShapes/area/index.d.ts +11 -0
- package/build/plugins/d3/renderer/hooks/useShapes/area/index.js +137 -0
- package/build/plugins/d3/renderer/hooks/useShapes/area/prepare-data.d.ts +11 -0
- package/build/plugins/d3/renderer/hooks/useShapes/area/prepare-data.js +114 -0
- package/build/plugins/d3/renderer/hooks/useShapes/area/types.d.ts +27 -0
- package/build/plugins/d3/renderer/hooks/useShapes/area/types.js +1 -0
- package/build/plugins/d3/renderer/hooks/useShapes/index.d.ts +2 -1
- package/build/plugins/d3/renderer/hooks/useShapes/index.js +16 -0
- package/build/plugins/d3/renderer/hooks/useShapes/line/index.js +9 -65
- package/build/plugins/d3/renderer/hooks/useShapes/line/prepare-data.js +5 -2
- package/build/plugins/d3/renderer/hooks/useShapes/line/types.d.ts +3 -0
- package/build/plugins/d3/renderer/hooks/useShapes/marker.d.ts +12 -0
- package/build/plugins/d3/renderer/hooks/useShapes/marker.js +70 -0
- package/build/plugins/d3/renderer/hooks/useShapes/pie/index.d.ts +3 -2
- package/build/plugins/d3/renderer/hooks/useShapes/pie/index.js +28 -0
- package/build/plugins/d3/renderer/hooks/useShapes/pie/prepare-data.js +9 -3
- package/build/plugins/d3/renderer/hooks/useShapes/pie/types.d.ts +5 -0
- package/build/plugins/d3/renderer/hooks/useShapes/scatter/index.js +1 -1
- package/build/plugins/d3/renderer/hooks/useShapes/utils.d.ts +2 -0
- package/build/plugins/d3/renderer/hooks/useShapes/utils.js +17 -0
- package/build/plugins/d3/renderer/utils/index.d.ts +1 -1
- package/build/plugins/d3/renderer/utils/index.js +16 -9
- package/build/plugins/d3/renderer/validation/__mocks__/index.d.ts +3 -0
- package/build/plugins/d3/renderer/validation/__mocks__/index.js +44 -0
- package/build/plugins/d3/renderer/validation/index.d.ts +2 -0
- package/build/plugins/d3/renderer/validation/index.js +139 -0
- package/build/plugins/highcharts/renderer/helpers/config/config.js +0 -3
- package/build/types/widget-data/area.d.ts +58 -0
- package/build/types/widget-data/area.js +1 -0
- package/build/types/widget-data/bar-x.d.ts +2 -1
- package/build/types/widget-data/bar-y.d.ts +2 -1
- package/build/types/widget-data/halo.d.ts +9 -0
- package/build/types/widget-data/halo.js +1 -0
- package/build/types/widget-data/index.d.ts +2 -0
- package/build/types/widget-data/index.js +2 -0
- package/build/types/widget-data/line.d.ts +9 -4
- package/build/types/widget-data/pie.d.ts +2 -1
- package/build/types/widget-data/scatter.d.ts +2 -1
- package/build/types/widget-data/series.d.ts +40 -9
- package/build/types/widget-data/tooltip.d.ts +10 -1
- package/package.json +7 -2
package/build/constants/index.js
CHANGED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const SeriesType: {
|
|
2
|
+
readonly Area: "area";
|
|
3
|
+
readonly BarX: "bar-x";
|
|
4
|
+
readonly BarY: "bar-y";
|
|
5
|
+
readonly Line: "line";
|
|
6
|
+
readonly Pie: "pie";
|
|
7
|
+
readonly Scatter: "scatter";
|
|
8
|
+
};
|
|
9
|
+
export declare enum DashStyle {
|
|
10
|
+
Dash = "Dash",
|
|
11
|
+
DashDot = "DashDot",
|
|
12
|
+
Dot = "Dot",
|
|
13
|
+
LongDash = "LongDash",
|
|
14
|
+
LongDashDot = "LongDashDot",
|
|
15
|
+
LongDashDotDot = "LongDashDotDot",
|
|
16
|
+
ShortDash = "ShortDash",
|
|
17
|
+
ShortDashDot = "ShortDashDot",
|
|
18
|
+
ShortDashDotDot = "ShortDashDotDot",
|
|
19
|
+
ShortDot = "ShortDot",
|
|
20
|
+
Solid = "Solid"
|
|
21
|
+
}
|
|
22
|
+
export declare enum LineCap {
|
|
23
|
+
Butt = "butt",
|
|
24
|
+
Round = "round",
|
|
25
|
+
Square = "square",
|
|
26
|
+
None = "none"
|
|
27
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
export const SeriesType = {
|
|
2
|
+
Area: 'area',
|
|
3
|
+
BarX: 'bar-x',
|
|
4
|
+
BarY: 'bar-y',
|
|
5
|
+
Line: 'line',
|
|
6
|
+
Pie: 'pie',
|
|
7
|
+
Scatter: 'scatter',
|
|
8
|
+
};
|
|
9
|
+
export var DashStyle;
|
|
10
|
+
(function (DashStyle) {
|
|
11
|
+
DashStyle["Dash"] = "Dash";
|
|
12
|
+
DashStyle["DashDot"] = "DashDot";
|
|
13
|
+
DashStyle["Dot"] = "Dot";
|
|
14
|
+
DashStyle["LongDash"] = "LongDash";
|
|
15
|
+
DashStyle["LongDashDot"] = "LongDashDot";
|
|
16
|
+
DashStyle["LongDashDotDot"] = "LongDashDotDot";
|
|
17
|
+
DashStyle["ShortDash"] = "ShortDash";
|
|
18
|
+
DashStyle["ShortDashDot"] = "ShortDashDot";
|
|
19
|
+
DashStyle["ShortDashDotDot"] = "ShortDashDotDot";
|
|
20
|
+
DashStyle["ShortDot"] = "ShortDot";
|
|
21
|
+
DashStyle["Solid"] = "Solid";
|
|
22
|
+
})(DashStyle || (DashStyle = {}));
|
|
23
|
+
export var LineCap;
|
|
24
|
+
(function (LineCap) {
|
|
25
|
+
LineCap["Butt"] = "butt";
|
|
26
|
+
LineCap["Round"] = "round";
|
|
27
|
+
LineCap["Square"] = "square";
|
|
28
|
+
LineCap["None"] = "none";
|
|
29
|
+
})(LineCap || (LineCap = {}));
|
|
@@ -28,7 +28,12 @@
|
|
|
28
28
|
"error": {
|
|
29
29
|
"label_no-data": "No data",
|
|
30
30
|
"label_unknown-plugin": "Unknown plugin type \"{{type}}\"",
|
|
31
|
-
"label_unknown-error": "Unknown error"
|
|
31
|
+
"label_unknown-error": "Unknown error",
|
|
32
|
+
"label_invalid-axis-category-data-point": "It seems you are trying to use inappropriate data type for \"{{key}}\" value in series \"{{seriesName}}\" for axis with type \"category\". Strings and numbers are allowed.",
|
|
33
|
+
"label_invalid-axis-datetime-data-point": "It seems you are trying to use inappropriate data type for \"{{key}}\" value in series \"{{seriesName}}\" for axis with type \"datetime\". Only numbers are allowed.",
|
|
34
|
+
"label_invalid-axis-linear-data-point": "It seems you are trying to use inappropriate data type for \"{{key}}\" value in series \"{{seriesName}}\" for axis with type \"linear\". Numbers and nulls are allowed.",
|
|
35
|
+
"label_invalid-pie-data-value": "It seems you are trying to use inappropriate data type for \"value\" value. Only numbers are allowed.",
|
|
36
|
+
"label_invalid-series-type": "It seems you haven't defined \"series.type\" property, or defined it incorrectly. Available values: [{{types}}]."
|
|
32
37
|
},
|
|
33
38
|
"highcharts": {
|
|
34
39
|
"reset-zoom-title": "Reset zoom",
|
|
@@ -30,7 +30,12 @@
|
|
|
30
30
|
"error": {
|
|
31
31
|
"label_no-data": "Нет данных",
|
|
32
32
|
"label_unknown-plugin": "Неизвестный тип плагина \"{{type}}\"",
|
|
33
|
-
"label_unknown-error": "Неизвестная ошибка"
|
|
33
|
+
"label_unknown-error": "Неизвестная ошибка",
|
|
34
|
+
"label_invalid-axis-category-data-point": "Похоже, что вы пытаетесь использовать недопустимый тип данных для значения \"{{key}}\" в серии \"{{seriesName}}\" для оси с типом \"category\". Допускается использование строк и чисел.",
|
|
35
|
+
"label_invalid-axis-datetime-data-point": "Похоже, что вы пытаетесь использовать недопустимый тип данных для значения \"{{key}}\" в серии \"{{seriesName}}\" для оси с типом \"datetime\". Допускается только использование чисел.",
|
|
36
|
+
"label_invalid-axis-linear-data-point": "Похоже, что вы пытаетесь использовать недопустимый тип данных для значения \"{{key}}\" в серии \"{{seriesName}}\" для оси с типом \"linear\". Допускается использование чисел и значений null.",
|
|
37
|
+
"label_invalid-pie-data-value": "Похоже, что вы пытаетесь использовать недопустимый тип данных для значения \"value\". Допускается только использование чисел.",
|
|
38
|
+
"label_invalid-series-type": "Похоже, что вы не указали значение \"series.type\" или указали его неверно. Доступные значения: [{{types}}]."
|
|
34
39
|
},
|
|
35
40
|
"highcharts": {
|
|
36
41
|
"reset-zoom-title": "Сбросить увеличение",
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ChartKit } from '../../../../components/ChartKit';
|
|
3
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
4
|
+
import nintendoGames from '../nintendoGames';
|
|
5
|
+
function prepareData() {
|
|
6
|
+
const games = nintendoGames.filter((d) => {
|
|
7
|
+
return d.date && d.user_score && d.genres.includes('Puzzle');
|
|
8
|
+
});
|
|
9
|
+
return [
|
|
10
|
+
{
|
|
11
|
+
name: 'User score',
|
|
12
|
+
type: 'area',
|
|
13
|
+
data: games.map((d) => {
|
|
14
|
+
return {
|
|
15
|
+
x: Number(d.date),
|
|
16
|
+
y: Number(d.user_score),
|
|
17
|
+
};
|
|
18
|
+
}),
|
|
19
|
+
},
|
|
20
|
+
];
|
|
21
|
+
}
|
|
22
|
+
export const Basic = () => {
|
|
23
|
+
const series = prepareData();
|
|
24
|
+
const widgetData = {
|
|
25
|
+
series: {
|
|
26
|
+
data: series,
|
|
27
|
+
},
|
|
28
|
+
xAxis: {
|
|
29
|
+
type: 'datetime',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
return (React.createElement(ExampleWrapper, null,
|
|
33
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
34
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { groups } from 'd3';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
5
|
+
import nintendoGames from '../nintendoGames';
|
|
6
|
+
const years = Array.from(new Set(nintendoGames.map((d) => d.date ? String(new Date(d.date).getFullYear()) : 'unknown'))).sort();
|
|
7
|
+
function prepareData() {
|
|
8
|
+
const grouped = groups(nintendoGames, (d) => d.platform, (d) => (d.date ? String(new Date(d.date).getFullYear()) : 'unknown'));
|
|
9
|
+
const series = grouped.map(([platform, gamesByYear]) => {
|
|
10
|
+
const platformGames = Object.fromEntries(gamesByYear) || {};
|
|
11
|
+
return {
|
|
12
|
+
name: platform,
|
|
13
|
+
data: years.reduce((acc, year) => {
|
|
14
|
+
if (year in platformGames) {
|
|
15
|
+
acc.push({
|
|
16
|
+
x: year,
|
|
17
|
+
y: platformGames[year].length,
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
return acc;
|
|
21
|
+
}, []),
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
return { series };
|
|
25
|
+
}
|
|
26
|
+
export const StackedArea = () => {
|
|
27
|
+
const { series } = prepareData();
|
|
28
|
+
const data = series.map((s) => {
|
|
29
|
+
return {
|
|
30
|
+
type: 'area',
|
|
31
|
+
stacking: 'normal',
|
|
32
|
+
name: s.name,
|
|
33
|
+
data: s.data,
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
const widgetData = {
|
|
37
|
+
series: {
|
|
38
|
+
data: data,
|
|
39
|
+
},
|
|
40
|
+
xAxis: {
|
|
41
|
+
type: 'category',
|
|
42
|
+
categories: years,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
return (React.createElement(ExampleWrapper, null,
|
|
46
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
47
|
+
};
|
|
@@ -1,15 +1,22 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { groups } from 'd3';
|
|
2
3
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
3
5
|
import nintendoGames from '../nintendoGames';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
+
function prepareData({ field, filterNulls } = {
|
|
7
|
+
field: 'platform',
|
|
8
|
+
}) {
|
|
6
9
|
const gamesByPlatform = groups(nintendoGames, (item) => item[field]);
|
|
7
|
-
|
|
10
|
+
let resultData = gamesByPlatform;
|
|
11
|
+
if (filterNulls) {
|
|
12
|
+
resultData = gamesByPlatform.filter(([value]) => typeof value === 'number');
|
|
13
|
+
}
|
|
14
|
+
const data = resultData.map(([value, games]) => ({
|
|
8
15
|
x: value,
|
|
9
16
|
y: games.length,
|
|
10
17
|
}));
|
|
11
18
|
return {
|
|
12
|
-
categories:
|
|
19
|
+
categories: resultData.map(([key]) => key),
|
|
13
20
|
series: [
|
|
14
21
|
{
|
|
15
22
|
data,
|
|
@@ -37,10 +44,11 @@ export const BasicBarXChart = () => {
|
|
|
37
44
|
},
|
|
38
45
|
yAxis: [{ title: { text: 'Number of games released' } }],
|
|
39
46
|
};
|
|
40
|
-
return React.createElement(
|
|
47
|
+
return (React.createElement(ExampleWrapper, null,
|
|
48
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
41
49
|
};
|
|
42
50
|
export const BasicLinearBarXChart = () => {
|
|
43
|
-
const { series } = prepareData('meta_score');
|
|
51
|
+
const { series } = prepareData({ field: 'meta_score' });
|
|
44
52
|
const widgetData = {
|
|
45
53
|
series: {
|
|
46
54
|
data: series.map((s) => ({
|
|
@@ -55,10 +63,11 @@ export const BasicLinearBarXChart = () => {
|
|
|
55
63
|
},
|
|
56
64
|
},
|
|
57
65
|
};
|
|
58
|
-
return React.createElement(
|
|
66
|
+
return (React.createElement(ExampleWrapper, null,
|
|
67
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
59
68
|
};
|
|
60
69
|
export const BasicDateTimeBarXChart = () => {
|
|
61
|
-
const { series } = prepareData('date');
|
|
70
|
+
const { series } = prepareData({ field: 'date', filterNulls: true });
|
|
62
71
|
const widgetData = {
|
|
63
72
|
series: {
|
|
64
73
|
data: series.map((s) => ({
|
|
@@ -74,5 +83,6 @@ export const BasicDateTimeBarXChart = () => {
|
|
|
74
83
|
},
|
|
75
84
|
},
|
|
76
85
|
};
|
|
77
|
-
return React.createElement(
|
|
86
|
+
return (React.createElement(ExampleWrapper, null,
|
|
87
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
78
88
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { groups, sort } from 'd3';
|
|
2
3
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
3
5
|
import nintendoGames from '../nintendoGames';
|
|
4
|
-
import { groups, sort } from 'd3';
|
|
5
6
|
const years = Array.from(new Set(nintendoGames.map((g) => g.date ? new Date(g.date).getFullYear().toString() : 'unknown')));
|
|
6
7
|
function prepareData() {
|
|
7
8
|
const games = sort(nintendoGames.filter((d) => {
|
|
@@ -42,5 +43,6 @@ export const DataLabels = () => {
|
|
|
42
43
|
ticks: { pixelInterval: 200 },
|
|
43
44
|
},
|
|
44
45
|
};
|
|
45
|
-
return React.createElement(
|
|
46
|
+
return (React.createElement(ExampleWrapper, null,
|
|
47
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
46
48
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { groups } from 'd3';
|
|
2
3
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
3
5
|
import nintendoGames from '../nintendoGames';
|
|
4
|
-
import { groups } from 'd3';
|
|
5
6
|
function prepareData() {
|
|
6
7
|
const displayedYears = [2015, 2016, 2017, 2018, 2019];
|
|
7
8
|
const games = nintendoGames.filter((ng) => displayedYears.includes(new Date(ng.date).getFullYear()));
|
|
@@ -42,5 +43,6 @@ export const GroupedColumns = () => {
|
|
|
42
43
|
},
|
|
43
44
|
},
|
|
44
45
|
};
|
|
45
|
-
return React.createElement(
|
|
46
|
+
return (React.createElement(ExampleWrapper, null,
|
|
47
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
46
48
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { groups } from 'd3';
|
|
2
3
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
3
5
|
import nintendoGames from '../nintendoGames';
|
|
4
|
-
import { groups } from 'd3';
|
|
5
6
|
function prepareData() {
|
|
6
7
|
const grouped = groups(nintendoGames, (d) => d.platform, (d) => (d.date ? new Date(d.date).getFullYear() : 'unknown'));
|
|
7
8
|
const categories = [];
|
|
@@ -41,5 +42,6 @@ export const StackedColumns = () => {
|
|
|
41
42
|
},
|
|
42
43
|
},
|
|
43
44
|
};
|
|
44
|
-
return React.createElement(
|
|
45
|
+
return (React.createElement(ExampleWrapper, null,
|
|
46
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
45
47
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { groups } from 'd3';
|
|
2
3
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
3
5
|
import nintendoGames from '../nintendoGames';
|
|
4
|
-
import { groups } from 'd3';
|
|
5
6
|
function prepareData(field = 'platform') {
|
|
6
7
|
const gamesByPlatform = groups(nintendoGames, (item) => item[field]);
|
|
7
8
|
const data = gamesByPlatform.map(([value, games]) => ({
|
|
@@ -39,5 +40,6 @@ export const Basic = () => {
|
|
|
39
40
|
},
|
|
40
41
|
],
|
|
41
42
|
};
|
|
42
|
-
return React.createElement(
|
|
43
|
+
return (React.createElement(ExampleWrapper, null,
|
|
44
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
43
45
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { groups } from 'd3';
|
|
2
3
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
3
5
|
import nintendoGames from '../nintendoGames';
|
|
4
|
-
import { groups } from 'd3';
|
|
5
6
|
function prepareData() {
|
|
6
7
|
const displayedYears = [2015, 2016, 2017, 2018, 2019];
|
|
7
8
|
const games = nintendoGames.filter((ng) => displayedYears.includes(new Date(ng.date).getFullYear()));
|
|
@@ -44,5 +45,6 @@ export const GroupedColumns = () => {
|
|
|
44
45
|
},
|
|
45
46
|
],
|
|
46
47
|
};
|
|
47
|
-
return React.createElement(
|
|
48
|
+
return (React.createElement(ExampleWrapper, null,
|
|
49
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
48
50
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { groups } from 'd3';
|
|
2
3
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
3
5
|
import nintendoGames from '../nintendoGames';
|
|
4
|
-
import { groups } from 'd3';
|
|
5
6
|
function prepareData() {
|
|
6
7
|
const grouped = groups(nintendoGames, (d) => d.platform, (d) => (d.date ? new Date(d.date).getFullYear() : 'unknown'));
|
|
7
8
|
const categories = [];
|
|
@@ -43,5 +44,6 @@ export const StackedColumns = () => {
|
|
|
43
44
|
},
|
|
44
45
|
],
|
|
45
46
|
};
|
|
46
|
-
return React.createElement(
|
|
47
|
+
return (React.createElement(ExampleWrapper, null,
|
|
48
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
47
49
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ChartKit } from '../../../../components/ChartKit';
|
|
3
|
-
import nintendoGames from '../../examples/nintendoGames';
|
|
4
2
|
import { groups, max, min, median } from 'd3';
|
|
3
|
+
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
5
|
+
import nintendoGames from '../nintendoGames';
|
|
5
6
|
export const LineAndBarXCombinedChart = () => {
|
|
6
7
|
const gamesByPlatform = groups(nintendoGames, (item) => item.platform || 'unknown');
|
|
7
8
|
const widgetData = {
|
|
@@ -57,5 +58,6 @@ export const LineAndBarXCombinedChart = () => {
|
|
|
57
58
|
},
|
|
58
59
|
],
|
|
59
60
|
};
|
|
60
|
-
return React.createElement(
|
|
61
|
+
return (React.createElement(ExampleWrapper, null,
|
|
62
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
61
63
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { dateTime } from '@gravity-ui/date-utils';
|
|
2
3
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
3
5
|
import nintendoGames from '../nintendoGames';
|
|
4
|
-
import { dateTime } from '@gravity-ui/date-utils';
|
|
5
6
|
function prepareData() {
|
|
6
7
|
const dataset = nintendoGames.filter((d) => d.date && d.user_score);
|
|
7
8
|
const data = dataset.map((d) => ({
|
|
@@ -62,5 +63,6 @@ export const Basic = () => {
|
|
|
62
63
|
},
|
|
63
64
|
},
|
|
64
65
|
};
|
|
65
|
-
return React.createElement(
|
|
66
|
+
return (React.createElement(ExampleWrapper, null,
|
|
67
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
66
68
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { dateTime } from '@gravity-ui/date-utils';
|
|
2
3
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
3
5
|
import nintendoGames from '../nintendoGames';
|
|
4
|
-
import { dateTime } from '@gravity-ui/date-utils';
|
|
5
6
|
function prepareData() {
|
|
6
7
|
const games = nintendoGames.filter((d) => {
|
|
7
8
|
return d.date && d.user_score;
|
|
@@ -85,5 +86,6 @@ export const DataLabels = () => {
|
|
|
85
86
|
},
|
|
86
87
|
},
|
|
87
88
|
};
|
|
88
|
-
return React.createElement(
|
|
89
|
+
return (React.createElement(ExampleWrapper, null,
|
|
90
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
89
91
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { dateTime } from '@gravity-ui/date-utils';
|
|
2
3
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
3
5
|
import nintendoGames from '../nintendoGames';
|
|
4
|
-
import { dateTime } from '@gravity-ui/date-utils';
|
|
5
6
|
function prepareData() {
|
|
6
7
|
const dataset = nintendoGames.filter((d) => d.date && d.user_score && new Date(d.date) > new Date(2022, 0, 1));
|
|
7
8
|
const data = dataset.map((d) => ({
|
|
@@ -63,5 +64,6 @@ export const LineWithMarkers = () => {
|
|
|
63
64
|
},
|
|
64
65
|
},
|
|
65
66
|
};
|
|
66
|
-
return React.createElement(
|
|
67
|
+
return (React.createElement(ExampleWrapper, null,
|
|
68
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
67
69
|
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { ChartKit } from '../../../../components/ChartKit';
|
|
3
|
+
import { DashStyle } from '../../../../constants';
|
|
4
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
5
|
+
import nintendoGames from '../nintendoGames';
|
|
6
|
+
const SHAPES = {
|
|
7
|
+
[DashStyle.Solid]: 1,
|
|
8
|
+
[DashStyle.Dash]: 2,
|
|
9
|
+
[DashStyle.Dot]: 3,
|
|
10
|
+
[DashStyle.ShortDashDot]: 4,
|
|
11
|
+
[DashStyle.LongDash]: 5,
|
|
12
|
+
[DashStyle.LongDashDot]: 6,
|
|
13
|
+
[DashStyle.ShortDot]: 7,
|
|
14
|
+
[DashStyle.LongDashDotDot]: 8,
|
|
15
|
+
[DashStyle.ShortDash]: 9,
|
|
16
|
+
[DashStyle.DashDot]: 10,
|
|
17
|
+
[DashStyle.ShortDashDotDot]: 11,
|
|
18
|
+
};
|
|
19
|
+
const selectShapes = () => Object.values(DashStyle);
|
|
20
|
+
const getShapesOrder = () => selectShapes().sort((a, b) => SHAPES[a] - SHAPES[b]);
|
|
21
|
+
const SHAPES_IN_ORDER = getShapesOrder();
|
|
22
|
+
function prepareData() {
|
|
23
|
+
const games = nintendoGames.filter((d) => {
|
|
24
|
+
return d.date && d.user_score;
|
|
25
|
+
});
|
|
26
|
+
const byGenre = (genre) => {
|
|
27
|
+
return games
|
|
28
|
+
.filter((d) => d.genres.includes(genre))
|
|
29
|
+
.map((d) => {
|
|
30
|
+
return {
|
|
31
|
+
x: d.date,
|
|
32
|
+
y: d.user_score,
|
|
33
|
+
label: d.title,
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
return {
|
|
38
|
+
series: {
|
|
39
|
+
options: {
|
|
40
|
+
line: {
|
|
41
|
+
lineWidth: 2,
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
data: [
|
|
45
|
+
{
|
|
46
|
+
name: '3D',
|
|
47
|
+
type: 'line',
|
|
48
|
+
data: byGenre('3D'),
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
name: '2D',
|
|
52
|
+
type: 'line',
|
|
53
|
+
data: byGenre('2D'),
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
name: 'Strategy',
|
|
57
|
+
type: 'line',
|
|
58
|
+
data: byGenre('Strategy'),
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: 'Shooter',
|
|
62
|
+
type: 'line',
|
|
63
|
+
data: byGenre('Shooter'),
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
},
|
|
67
|
+
xAxis: {
|
|
68
|
+
type: 'datetime',
|
|
69
|
+
title: {
|
|
70
|
+
text: 'Release date',
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
yAxis: [
|
|
74
|
+
{
|
|
75
|
+
title: { text: 'User score' },
|
|
76
|
+
labels: {
|
|
77
|
+
enabled: true,
|
|
78
|
+
},
|
|
79
|
+
ticks: {
|
|
80
|
+
pixelInterval: 120,
|
|
81
|
+
},
|
|
82
|
+
},
|
|
83
|
+
],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
export const LinesWithShapes = () => {
|
|
87
|
+
const data = prepareData();
|
|
88
|
+
data.series.data.forEach((graph, i) => {
|
|
89
|
+
graph.dashStyle = SHAPES_IN_ORDER[i % SHAPES_IN_ORDER.length];
|
|
90
|
+
});
|
|
91
|
+
return (React.createElement(ExampleWrapper, null,
|
|
92
|
+
React.createElement(ChartKit, { type: "d3", data: data })));
|
|
93
|
+
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { groups } from 'd3';
|
|
2
3
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
3
5
|
import nintendoGames from '../nintendoGames';
|
|
4
|
-
import { groups } from 'd3';
|
|
5
6
|
function prepareData() {
|
|
6
7
|
const gamesByPlatform = groups(nintendoGames, (item) => item.platform);
|
|
7
8
|
return gamesByPlatform.map(([platform, games]) => ({
|
|
@@ -26,5 +27,6 @@ export const BasicPie = () => {
|
|
|
26
27
|
style: { fontSize: '12px', fontWeight: 'normal' },
|
|
27
28
|
},
|
|
28
29
|
};
|
|
29
|
-
return React.createElement(
|
|
30
|
+
return (React.createElement(ExampleWrapper, null,
|
|
31
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
30
32
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { groups } from 'd3';
|
|
2
3
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
3
5
|
import nintendoGames from '../nintendoGames';
|
|
4
|
-
import { groups } from 'd3';
|
|
5
6
|
function prepareData() {
|
|
6
7
|
const gamesByPlatform = groups(nintendoGames, (d) => d.esrb_rating || 'unknown');
|
|
7
8
|
return gamesByPlatform.map(([value, games]) => ({
|
|
@@ -27,5 +28,6 @@ export const Donut = () => {
|
|
|
27
28
|
style: { fontSize: '12px', fontWeight: 'normal' },
|
|
28
29
|
},
|
|
29
30
|
};
|
|
30
|
-
return React.createElement(
|
|
31
|
+
return (React.createElement(ExampleWrapper, null,
|
|
32
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
31
33
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
+
import { dateTime } from '@gravity-ui/date-utils';
|
|
2
3
|
import { ChartKit } from '../../../../components/ChartKit';
|
|
4
|
+
import { ExampleWrapper } from '../ExampleWrapper';
|
|
3
5
|
import nintendoGames from '../nintendoGames';
|
|
4
|
-
import { dateTime } from '@gravity-ui/date-utils';
|
|
5
6
|
function prepareData() {
|
|
6
7
|
const dataset = nintendoGames.filter((d) => d.date && d.user_score);
|
|
7
8
|
const data = dataset.map((d) => ({
|
|
@@ -62,5 +63,6 @@ export const Basic = () => {
|
|
|
62
63
|
},
|
|
63
64
|
},
|
|
64
65
|
};
|
|
65
|
-
return React.createElement(
|
|
66
|
+
return (React.createElement(ExampleWrapper, null,
|
|
67
|
+
React.createElement(ChartKit, { type: "d3", data: widgetData })));
|
|
66
68
|
};
|