@semcore/d3-chart 3.18.1 → 3.18.2
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/CHANGELOG.md +7 -1
- package/README.md +1 -1
- package/lib/cjs/Area.js +9 -9
- package/lib/cjs/Axis.js +14 -14
- package/lib/cjs/Bar.js +8 -8
- package/lib/cjs/Bubble.js +10 -10
- package/lib/cjs/Donut.js +7 -7
- package/lib/cjs/Dots.js +10 -10
- package/lib/cjs/HorizontalBar.js +8 -8
- package/lib/cjs/Hover.js +3 -3
- package/lib/cjs/Line.js +13 -11
- package/lib/cjs/Line.js.map +1 -1
- package/lib/cjs/Plot.js +3 -3
- package/lib/cjs/Radar.js +17 -17
- package/lib/cjs/RadialTree.js +10 -10
- package/lib/cjs/ReferenceLine.js +9 -9
- package/lib/cjs/ScatterPlot.js +8 -8
- package/lib/cjs/ScatterPlot.js.map +1 -1
- package/lib/cjs/Tooltip.js +8 -8
- package/lib/cjs/Venn.js +7 -7
- package/lib/cjs/a11y/PlotA11yModule.js +2 -2
- package/lib/cjs/a11y/PlotA11yView.js +2 -2
- package/lib/cjs/component/Chart/AbstractChart.js +420 -0
- package/lib/cjs/component/Chart/AbstractChart.js.map +1 -0
- package/lib/cjs/component/Chart/AbstractChart.type.js +2 -0
- package/lib/cjs/component/Chart/AbstractChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/AreaChart.js +160 -0
- package/lib/cjs/component/Chart/AreaChart.js.map +1 -0
- package/lib/cjs/component/Chart/AreaChart.type.js +2 -0
- package/lib/cjs/component/Chart/AreaChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/BarChart.js +253 -0
- package/lib/cjs/component/Chart/BarChart.js.map +1 -0
- package/lib/cjs/component/Chart/BarChart.type.js +2 -0
- package/lib/cjs/component/Chart/BarChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/BubbleChart.js +145 -0
- package/lib/cjs/component/Chart/BubbleChart.js.map +1 -0
- package/lib/cjs/component/Chart/BubbleChart.type.js +2 -0
- package/lib/cjs/component/Chart/BubbleChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/DonutChart.js +117 -0
- package/lib/cjs/component/Chart/DonutChart.js.map +1 -0
- package/lib/cjs/component/Chart/DonutChart.type.js +2 -0
- package/lib/cjs/component/Chart/DonutChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/HistogramChart.js +189 -0
- package/lib/cjs/component/Chart/HistogramChart.js.map +1 -0
- package/lib/cjs/component/Chart/HistogramChart.type.js +2 -0
- package/lib/cjs/component/Chart/HistogramChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/LineChart.js +147 -0
- package/lib/cjs/component/Chart/LineChart.js.map +1 -0
- package/lib/cjs/component/Chart/LineChart.type.js +2 -0
- package/lib/cjs/component/Chart/LineChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/RadarChart.js +121 -0
- package/lib/cjs/component/Chart/RadarChart.js.map +1 -0
- package/lib/cjs/component/Chart/RadarChart.type.js +2 -0
- package/lib/cjs/component/Chart/RadarChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/ScatterPlotChart.js +159 -0
- package/lib/cjs/component/Chart/ScatterPlotChart.js.map +1 -0
- package/lib/cjs/component/Chart/ScatterPlotChart.type.js +2 -0
- package/lib/cjs/component/Chart/ScatterPlotChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/VennChart.js +144 -0
- package/lib/cjs/component/Chart/VennChart.js.map +1 -0
- package/lib/cjs/component/Chart/VennChart.type.js +2 -0
- package/lib/cjs/component/Chart/VennChart.type.js.map +1 -0
- package/lib/cjs/component/Chart/index.js +28 -0
- package/lib/cjs/component/Chart/index.js.map +1 -0
- package/lib/cjs/component/ChartLegend/BaseLegend.type.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendFlex/LegendFlex.js +4 -4
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js +20 -17
- package/lib/cjs/component/ChartLegend/LegendItem/LegendItem.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendTable/LegendTable.js +6 -7
- package/lib/cjs/component/ChartLegend/LegendTable/LegendTable.js.map +1 -1
- package/lib/cjs/component/ChartLegend/LegendTable/legend-table.shadow.css +5 -2
- package/lib/cjs/index.js +7 -0
- package/lib/cjs/index.js.map +1 -1
- package/lib/cjs/style/donut.shadow.css +3 -0
- package/lib/cjs/types/Line.d.js.map +1 -1
- package/lib/cjs/types/index.d.js +130 -1
- package/lib/cjs/types/index.d.js.map +1 -1
- package/lib/es6/Area.js +9 -9
- package/lib/es6/Axis.js +14 -14
- package/lib/es6/Bar.js +8 -8
- package/lib/es6/Bubble.js +10 -10
- package/lib/es6/Donut.js +7 -7
- package/lib/es6/Dots.js +10 -10
- package/lib/es6/HorizontalBar.js +8 -8
- package/lib/es6/Hover.js +3 -3
- package/lib/es6/Line.js +13 -11
- package/lib/es6/Line.js.map +1 -1
- package/lib/es6/Plot.js +3 -3
- package/lib/es6/Radar.js +17 -17
- package/lib/es6/RadialTree.js +10 -10
- package/lib/es6/ReferenceLine.js +9 -9
- package/lib/es6/ScatterPlot.js +8 -8
- package/lib/es6/ScatterPlot.js.map +1 -1
- package/lib/es6/Tooltip.js +8 -8
- package/lib/es6/Venn.js +7 -7
- package/lib/es6/a11y/PlotA11yModule.js +2 -2
- package/lib/es6/a11y/PlotA11yView.js +2 -2
- package/lib/es6/component/Chart/AbstractChart.js +412 -0
- package/lib/es6/component/Chart/AbstractChart.js.map +1 -0
- package/lib/es6/component/Chart/AbstractChart.type.js +2 -0
- package/lib/es6/component/Chart/AbstractChart.type.js.map +1 -0
- package/lib/es6/component/Chart/AreaChart.js +152 -0
- package/lib/es6/component/Chart/AreaChart.js.map +1 -0
- package/lib/es6/component/Chart/AreaChart.type.js +2 -0
- package/lib/es6/component/Chart/AreaChart.type.js.map +1 -0
- package/lib/es6/component/Chart/BarChart.js +245 -0
- package/lib/es6/component/Chart/BarChart.js.map +1 -0
- package/lib/es6/component/Chart/BarChart.type.js +2 -0
- package/lib/es6/component/Chart/BarChart.type.js.map +1 -0
- package/lib/es6/component/Chart/BubbleChart.js +137 -0
- package/lib/es6/component/Chart/BubbleChart.js.map +1 -0
- package/lib/es6/component/Chart/BubbleChart.type.js +2 -0
- package/lib/es6/component/Chart/BubbleChart.type.js.map +1 -0
- package/lib/es6/component/Chart/DonutChart.js +109 -0
- package/lib/es6/component/Chart/DonutChart.js.map +1 -0
- package/lib/es6/component/Chart/DonutChart.type.js +2 -0
- package/lib/es6/component/Chart/DonutChart.type.js.map +1 -0
- package/lib/es6/component/Chart/HistogramChart.js +181 -0
- package/lib/es6/component/Chart/HistogramChart.js.map +1 -0
- package/lib/es6/component/Chart/HistogramChart.type.js +2 -0
- package/lib/es6/component/Chart/HistogramChart.type.js.map +1 -0
- package/lib/es6/component/Chart/LineChart.js +139 -0
- package/lib/es6/component/Chart/LineChart.js.map +1 -0
- package/lib/es6/component/Chart/LineChart.type.js +2 -0
- package/lib/es6/component/Chart/LineChart.type.js.map +1 -0
- package/lib/es6/component/Chart/RadarChart.js +113 -0
- package/lib/es6/component/Chart/RadarChart.js.map +1 -0
- package/lib/es6/component/Chart/RadarChart.type.js +2 -0
- package/lib/es6/component/Chart/RadarChart.type.js.map +1 -0
- package/lib/es6/component/Chart/ScatterPlotChart.js +151 -0
- package/lib/es6/component/Chart/ScatterPlotChart.js.map +1 -0
- package/lib/es6/component/Chart/ScatterPlotChart.type.js +2 -0
- package/lib/es6/component/Chart/ScatterPlotChart.type.js.map +1 -0
- package/lib/es6/component/Chart/VennChart.js +136 -0
- package/lib/es6/component/Chart/VennChart.js.map +1 -0
- package/lib/es6/component/Chart/VennChart.type.js +2 -0
- package/lib/es6/component/Chart/VennChart.type.js.map +1 -0
- package/lib/es6/component/Chart/index.js +21 -0
- package/lib/es6/component/Chart/index.js.map +1 -0
- package/lib/es6/component/ChartLegend/BaseLegend.type.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendFlex/LegendFlex.js +4 -4
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js +20 -17
- package/lib/es6/component/ChartLegend/LegendItem/LegendItem.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendTable/LegendTable.js +6 -7
- package/lib/es6/component/ChartLegend/LegendTable/LegendTable.js.map +1 -1
- package/lib/es6/component/ChartLegend/LegendTable/legend-table.shadow.css +5 -2
- package/lib/es6/index.js +1 -0
- package/lib/es6/index.js.map +1 -1
- package/lib/es6/style/donut.shadow.css +3 -0
- package/lib/es6/types/Line.d.js.map +1 -1
- package/lib/es6/types/index.d.js +12 -0
- package/lib/es6/types/index.d.js.map +1 -1
- package/lib/types/Line.d.ts +7 -2
- package/lib/types/component/Chart/AbstractChart.d.ts +50 -0
- package/lib/types/component/Chart/AbstractChart.type.d.ts +161 -0
- package/lib/types/component/Chart/AreaChart.d.ts +2 -0
- package/lib/types/component/Chart/AreaChart.type.d.ts +16 -0
- package/lib/types/component/Chart/BarChart.d.ts +2 -0
- package/lib/types/component/Chart/BarChart.type.d.ts +19 -0
- package/lib/types/component/Chart/BubbleChart.d.ts +2 -0
- package/lib/types/component/Chart/BubbleChart.type.d.ts +17 -0
- package/lib/types/component/Chart/DonutChart.d.ts +2 -0
- package/lib/types/component/Chart/DonutChart.type.d.ts +15 -0
- package/lib/types/component/Chart/HistogramChart.d.ts +2 -0
- package/lib/types/component/Chart/HistogramChart.type.d.ts +11 -0
- package/lib/types/component/Chart/LineChart.d.ts +2 -0
- package/lib/types/component/Chart/LineChart.type.d.ts +24 -0
- package/lib/types/component/Chart/RadarChart.d.ts +2 -0
- package/lib/types/component/Chart/RadarChart.type.d.ts +14 -0
- package/lib/types/component/Chart/ScatterPlotChart.d.ts +2 -0
- package/lib/types/component/Chart/ScatterPlotChart.type.d.ts +13 -0
- package/lib/types/component/Chart/VennChart.d.ts +2 -0
- package/lib/types/component/Chart/VennChart.type.d.ts +11 -0
- package/lib/types/component/Chart/index.d.ts +12 -0
- package/lib/types/component/ChartLegend/BaseLegend.type.d.ts +2 -2
- package/lib/types/index.d.ts +13 -0
- package/package.json +2 -2
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AbstractChart.type.js","names":[],"sources":["../../../../src/component/Chart/AbstractChart.type.ts"],"sourcesContent":["import React from 'react';\nimport { FlexProps } from '@semcore/flex-box';\nimport { LegendItemKey } from '../ChartLegend/LegendItem/LegendItem.type';\nimport Icon from '@semcore/icon';\nimport { BaseChartLegendProps } from '../ChartLegend/BaseLegend.type';\nimport { TrendProps } from '../ChartLegend/LegendFlex/LegendFlex.type';\n\nexport type BaseLegendProps = BaseChartLegendProps & {\n /**\n * Disable hover (for transition items legend of each not hovered)\n */\n disableHoverItems?: boolean;\n /**\n * Disable selectable of data items by checkboxes in Legend\n */\n disableSelectItems?: boolean;\n} & (\n | (TrendProps & {\n /**\n * How to render Legend - Flex view. Just list of legend items\n */\n legendType?: never | 'Flex';\n /**\n * Config for Legend items\n */\n legendMap?: LegendDataMap<'Flex'>;\n })\n | {\n /**\n * How to render Legend - Table view. Table of legend items with some additional information in columns\n */\n legendType: 'Table';\n /**\n * Config for Legend items\n */\n legendMap?: LegendDataMap<'Table'>;\n }\n );\n\nexport type ObjectData = Record<string, unknown>;\nexport type ListData = ObjectData[];\n\nexport type BaseChartProps<T extends ListData | ObjectData> = FlexProps & {\n /**\n * Chart data. For all charts except Donut(Pie), Radar and Venn should be an Array\n */\n data: T;\n /**\n * Width of plot\n */\n plotWidth: number;\n /**\n * Height of plot\n */\n plotHeight: number;\n /**\n * Margin (for Y axis points) from left side of chart container to Y axis\n */\n marginY?: number;\n /**\n * Margin (for X axis points) from bottom of chart container to X axis\n */\n marginX?: number;\n /**\n * invert axis and show horizontal charts (only for Bars!)\n */\n invertAxis?: boolean;\n\n /**\n * Show X axis\n * @default true (for charts with axis: Area, Line, Bar, ScatterPlot, ...)\n */\n showXAxis?: boolean;\n /**\n * Show Y axis\n * @default true (for charts with axis: Area, Line, Bar, ScatterPlot, ...)\n */\n showYAxis?: boolean;\n /**\n * Map with colors for data items\n */\n colorMap?: Record<string, string>;\n /**\n * Show tooltip's.\n * @default true\n */\n showTooltip?: boolean;\n /**\n * Show sum of values for selected point in tooltip\n */\n showTotalInTooltip?: boolean;\n /**\n * Scale for xAxis (see more in d3-scale)\n */\n xScale?: unknown;\n /**\n * Scale for yAxis (see more in d3-scale)\n */\n yScale?: unknown;\n /**\n * Count of ticks for X axis\n */\n xTicksCount?: number;\n /**\n * Count of ticks for Y axis\n */\n yTicksCount?: number;\n /**\n * Group key for all array-based charts (for get keys of items for legend except that group key)\n */\n groupKey?: string;\n /**\n * function for format axis item text\n */\n axisXValueFormatter?: (value: unknown) => string;\n axisYValueFormatter?: (value: unknown) => string;\n /**\n * Function for format text for tooltip\n */\n tooltipValueFormatter?: (value?: unknown) => string;\n} /**\n * By default, we show the Legend for all charts with more the one data item.\n * For hide the Legend, you should set showLegend prop to `false`.\n */ & (\n | {\n /**\n * Don't show legend\n */\n showLegend?: false;\n legendProps?: never;\n }\n | {\n /**\n * By default (if showLegend don't set), for one data item on chart,\n * Legend component will be hide, and show for more then 1 data item.\n * If set `true` - Legend component will show always.\n */\n showLegend?: true;\n /**\n * Props for Legend\n */\n legendProps?: Partial<BaseLegendProps>;\n }\n );\n\ntype LegendDataMap<T extends 'Flex' | 'Table'> = Record<\n LegendItemKey,\n {\n /**\n * Custom label for legend item (by default use keys from data item object)\n */\n label?: string;\n /**\n * Additional text after label\n */\n additionalInfo?: string;\n /**\n * Count after label\n */\n count?: number;\n /**\n * Custom Icon\n */\n icon?: typeof Icon;\n /**\n * Flag for uncheck some items by default\n */\n defaultChecked?: boolean;\n } & (T extends 'Table' ? { columns?: React.ReactNode[] } : { columns?: never })\n>;\n"],"mappings":""}
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.AreaChart = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
10
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
11
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
12
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
13
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
14
|
+
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
15
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
16
|
+
var _react = _interopRequireDefault(require("react"));
|
|
17
|
+
var _core = _interopRequireDefault(require("@semcore/core"));
|
|
18
|
+
var _d3Scale = require("d3-scale");
|
|
19
|
+
var _ = require("../..");
|
|
20
|
+
var _AbstractChart2 = require("./AbstractChart");
|
|
21
|
+
var _flexBox = require("@semcore/flex-box");
|
|
22
|
+
var _typography = require("@semcore/typography");
|
|
23
|
+
// @ts-ignore
|
|
24
|
+
var AreaChartComponent = /*#__PURE__*/function (_AbstractChart) {
|
|
25
|
+
(0, _inherits2["default"])(AreaChartComponent, _AbstractChart);
|
|
26
|
+
var _super = (0, _createSuper2["default"])(AreaChartComponent);
|
|
27
|
+
function AreaChartComponent() {
|
|
28
|
+
(0, _classCallCheck2["default"])(this, AreaChartComponent);
|
|
29
|
+
return _super.apply(this, arguments);
|
|
30
|
+
}
|
|
31
|
+
(0, _createClass2["default"])(AreaChartComponent, [{
|
|
32
|
+
key: "xScale",
|
|
33
|
+
get: function get() {
|
|
34
|
+
var _this$asProps = this.asProps,
|
|
35
|
+
xScale = _this$asProps.xScale,
|
|
36
|
+
_this$asProps$marginY = _this$asProps.marginY,
|
|
37
|
+
marginY = _this$asProps$marginY === void 0 ? 40 : _this$asProps$marginY,
|
|
38
|
+
plotWidth = _this$asProps.plotWidth,
|
|
39
|
+
data = _this$asProps.data,
|
|
40
|
+
groupKey = _this$asProps.groupKey;
|
|
41
|
+
if (xScale) {
|
|
42
|
+
return xScale;
|
|
43
|
+
}
|
|
44
|
+
var testItem = data[0][groupKey];
|
|
45
|
+
var range = [marginY, plotWidth - this.plotPadding];
|
|
46
|
+
var domain = (0, _.minMax)(data, groupKey);
|
|
47
|
+
if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {
|
|
48
|
+
return (0, _d3Scale.scaleTime)(domain, range);
|
|
49
|
+
}
|
|
50
|
+
return (0, _d3Scale.scaleLinear)(domain, range);
|
|
51
|
+
}
|
|
52
|
+
}, {
|
|
53
|
+
key: "yScale",
|
|
54
|
+
get: function get() {
|
|
55
|
+
var _this$asProps2 = this.asProps,
|
|
56
|
+
yScale = _this$asProps2.yScale,
|
|
57
|
+
_this$asProps2$margin = _this$asProps2.marginX,
|
|
58
|
+
marginX = _this$asProps2$margin === void 0 ? 24 : _this$asProps2$margin,
|
|
59
|
+
plotHeight = _this$asProps2.plotHeight,
|
|
60
|
+
stacked = _this$asProps2.stacked,
|
|
61
|
+
data = _this$asProps2.data,
|
|
62
|
+
groupKey = _this$asProps2.groupKey;
|
|
63
|
+
if (yScale) {
|
|
64
|
+
return yScale;
|
|
65
|
+
}
|
|
66
|
+
var flatValues = (0, _get2["default"])((0, _getPrototypeOf2["default"])(AreaChartComponent.prototype), "flatValues", this);
|
|
67
|
+
var min = Math.min.apply(Math, (0, _toConsumableArray2["default"])(flatValues));
|
|
68
|
+
var max = stacked ? (0, _get2["default"])((0, _getPrototypeOf2["default"])(AreaChartComponent.prototype), "maxStackedValue", this) : Math.max.apply(Math, (0, _toConsumableArray2["default"])(flatValues));
|
|
69
|
+
return (0, _d3Scale.scaleLinear)().range([plotHeight - marginX, this.plotPadding]).domain([min, max]);
|
|
70
|
+
}
|
|
71
|
+
}, {
|
|
72
|
+
key: "renderChart",
|
|
73
|
+
value: function renderChart() {
|
|
74
|
+
var _this$asProps3 = this.asProps,
|
|
75
|
+
groupKey = _this$asProps3.groupKey,
|
|
76
|
+
curve = _this$asProps3.curve,
|
|
77
|
+
showDots = _this$asProps3.showDots,
|
|
78
|
+
stacked = _this$asProps3.stacked;
|
|
79
|
+
var _this$state = this.state,
|
|
80
|
+
dataDefinitions = _this$state.dataDefinitions,
|
|
81
|
+
highlightedLine = _this$state.highlightedLine;
|
|
82
|
+
if (stacked) {
|
|
83
|
+
return /*#__PURE__*/_react["default"].createElement(_.StackedArea, {
|
|
84
|
+
x: groupKey
|
|
85
|
+
}, dataDefinitions.map(function (item, index) {
|
|
86
|
+
return item.checked && /*#__PURE__*/_react["default"].createElement(_.StackedArea.Area, {
|
|
87
|
+
x: groupKey,
|
|
88
|
+
y: item.id,
|
|
89
|
+
key: item.id,
|
|
90
|
+
color: item.color,
|
|
91
|
+
transparent: highlightedLine !== -1 && highlightedLine !== index,
|
|
92
|
+
curve: curve
|
|
93
|
+
}, showDots && /*#__PURE__*/_react["default"].createElement(_.StackedArea.Area.Dots, {
|
|
94
|
+
display: true
|
|
95
|
+
}));
|
|
96
|
+
}));
|
|
97
|
+
}
|
|
98
|
+
return dataDefinitions.map(function (item, index) {
|
|
99
|
+
return item.checked && /*#__PURE__*/_react["default"].createElement(_.Area, {
|
|
100
|
+
x: groupKey,
|
|
101
|
+
y: item.id,
|
|
102
|
+
key: item.id,
|
|
103
|
+
color: item.color,
|
|
104
|
+
transparent: highlightedLine !== -1 && highlightedLine !== index,
|
|
105
|
+
curve: curve
|
|
106
|
+
}, showDots && /*#__PURE__*/_react["default"].createElement(_.Area.Dots, {
|
|
107
|
+
display: true
|
|
108
|
+
}));
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
}, {
|
|
112
|
+
key: "renderTooltip",
|
|
113
|
+
value: function renderTooltip() {
|
|
114
|
+
var _this = this;
|
|
115
|
+
var _this$asProps4 = this.asProps,
|
|
116
|
+
data = _this$asProps4.data,
|
|
117
|
+
groupKey = _this$asProps4.groupKey,
|
|
118
|
+
showTotalInTooltip = _this$asProps4.showTotalInTooltip,
|
|
119
|
+
showTooltip = _this$asProps4.showTooltip;
|
|
120
|
+
var dataDefinitions = this.state.dataDefinitions;
|
|
121
|
+
if (!showTooltip) {
|
|
122
|
+
return null;
|
|
123
|
+
}
|
|
124
|
+
return /*#__PURE__*/_react["default"].createElement(_.HoverLine.Tooltip, {
|
|
125
|
+
x: groupKey,
|
|
126
|
+
wMin: 100
|
|
127
|
+
}, function (_ref) {
|
|
128
|
+
var _dataItem$groupKey;
|
|
129
|
+
var xIndex = _ref.xIndex;
|
|
130
|
+
var dataItem = data[xIndex];
|
|
131
|
+
var total = _this.totalValue(dataItem);
|
|
132
|
+
return {
|
|
133
|
+
children: /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_.HoverLine.Tooltip.Title, null, (_dataItem$groupKey = dataItem[groupKey]) === null || _dataItem$groupKey === void 0 ? void 0 : _dataItem$groupKey.toString()), dataDefinitions.map(function (item) {
|
|
134
|
+
return item.checked && /*#__PURE__*/_react["default"].createElement(_flexBox.Flex, {
|
|
135
|
+
justifyContent: "space-between",
|
|
136
|
+
key: item.id
|
|
137
|
+
}, /*#__PURE__*/_react["default"].createElement(_.HoverLine.Tooltip.Dot, {
|
|
138
|
+
mr: 4,
|
|
139
|
+
color: item.color
|
|
140
|
+
}, item.label), /*#__PURE__*/_react["default"].createElement(_typography.Text, {
|
|
141
|
+
bold: true
|
|
142
|
+
}, _this.tooltipValueFormatter(dataItem[item.id])));
|
|
143
|
+
}), showTotalInTooltip === true && /*#__PURE__*/_react["default"].createElement(_flexBox.Flex, {
|
|
144
|
+
mt: 2,
|
|
145
|
+
justifyContent: "space-between"
|
|
146
|
+
}, /*#__PURE__*/_react["default"].createElement(_flexBox.Box, {
|
|
147
|
+
mr: 4
|
|
148
|
+
}, "Total"), /*#__PURE__*/_react["default"].createElement(_typography.Text, {
|
|
149
|
+
bold: true
|
|
150
|
+
}, total)))
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}]);
|
|
155
|
+
return AreaChartComponent;
|
|
156
|
+
}(_AbstractChart2.AbstractChart);
|
|
157
|
+
(0, _defineProperty2["default"])(AreaChartComponent, "displayName", 'Chart.Area');
|
|
158
|
+
var AreaChart = (0, _core["default"])(AreaChartComponent);
|
|
159
|
+
exports.AreaChart = AreaChart;
|
|
160
|
+
//# sourceMappingURL=AreaChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AreaChart.js","names":["_react","_interopRequireDefault","require","_core","_d3Scale","_","_AbstractChart2","_flexBox","_typography","AreaChartComponent","_AbstractChart","_inherits2","_super","_createSuper2","_classCallCheck2","apply","arguments","_createClass2","key","get","_this$asProps","asProps","xScale","_this$asProps$marginY","marginY","plotWidth","data","groupKey","testItem","range","plotPadding","domain","minMax","Date","Number","isNaN","getMilliseconds","scaleTime","scaleLinear","_this$asProps2","yScale","_this$asProps2$margin","marginX","plotHeight","stacked","flatValues","_get2","_getPrototypeOf2","prototype","min","Math","_toConsumableArray2","max","value","renderChart","_this$asProps3","curve","showDots","_this$state","state","dataDefinitions","highlightedLine","createElement","StackedArea","x","map","item","index","checked","Area","y","id","color","transparent","Dots","display","renderTooltip","_this","_this$asProps4","showTotalInTooltip","showTooltip","HoverLine","Tooltip","wMin","_ref","_dataItem$groupKey","xIndex","dataItem","total","totalValue","children","Fragment","Title","toString","Flex","justifyContent","Dot","mr","label","Text","bold","tooltipValueFormatter","mt","Box","AbstractChart","_defineProperty2","AreaChart","createComponent","exports"],"sources":["../../../../src/component/Chart/AreaChart.tsx"],"sourcesContent":["import React from 'react';\nimport createComponent from '@semcore/core';\nimport { ScaleLinear, scaleLinear, scaleTime } from 'd3-scale';\n// @ts-ignore\nimport { Area, minMax, HoverLine, StackedArea } from '../..';\nimport { AbstractChart } from './AbstractChart';\nimport { AreaChartData, AreaChartProps, AreaChartType } from './AreaChart.type';\nimport { Flex, Box } from '@semcore/flex-box';\nimport { Text } from '@semcore/typography';\n\nclass AreaChartComponent extends AbstractChart<AreaChartData, AreaChartProps> {\n static displayName = 'Chart.Area';\n\n get xScale() {\n const { xScale, marginY = 40, plotWidth, data, groupKey } = this.asProps;\n\n if (xScale) {\n return xScale;\n }\n\n const testItem = data[0][groupKey];\n const range = [marginY, plotWidth - this.plotPadding];\n const domain = minMax(data, groupKey);\n\n if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {\n return scaleTime(domain, range);\n }\n\n return scaleLinear(domain, range);\n }\n\n get yScale(): ScaleLinear<any, any> {\n const { yScale, marginX = 24, plotHeight, stacked, data, groupKey } = this.asProps;\n\n if (yScale) {\n return yScale;\n }\n\n const flatValues = super.flatValues;\n const min = Math.min(...flatValues);\n const max = stacked ? super.maxStackedValue : Math.max(...flatValues);\n\n return scaleLinear()\n .range([plotHeight - marginX, this.plotPadding])\n .domain([min, max]);\n }\n\n renderChart() {\n const { groupKey, curve, showDots, stacked } = this.asProps;\n const { dataDefinitions, highlightedLine } = this.state;\n\n if (stacked) {\n return (\n <StackedArea x={groupKey}>\n {dataDefinitions.map((item, index) => {\n return (\n item.checked && (\n <StackedArea.Area\n x={groupKey}\n y={item.id}\n key={item.id}\n color={item.color}\n transparent={highlightedLine !== -1 && highlightedLine !== index}\n curve={curve}\n >\n {showDots && <StackedArea.Area.Dots display />}\n </StackedArea.Area>\n )\n );\n })}\n </StackedArea>\n );\n }\n\n return dataDefinitions.map((item, index) => {\n return (\n item.checked && (\n <Area\n x={groupKey}\n y={item.id}\n key={item.id}\n color={item.color}\n transparent={highlightedLine !== -1 && highlightedLine !== index}\n curve={curve}\n >\n {showDots && <Area.Dots display />}\n </Area>\n )\n );\n });\n }\n\n renderTooltip() {\n const { data, groupKey, showTotalInTooltip, showTooltip } = this.asProps;\n const { dataDefinitions } = this.state;\n\n if (!showTooltip) {\n return null;\n }\n\n return (\n <HoverLine.Tooltip x={groupKey} wMin={100}>\n {({ xIndex }: any) => {\n const dataItem = data[xIndex];\n const total = this.totalValue(dataItem);\n\n return {\n children: (\n <>\n <HoverLine.Tooltip.Title>{dataItem[groupKey]?.toString()}</HoverLine.Tooltip.Title>\n\n {dataDefinitions.map((item) => {\n return (\n item.checked && (\n <Flex justifyContent='space-between' key={item.id}>\n <HoverLine.Tooltip.Dot mr={4} color={item.color}>\n {item.label}\n </HoverLine.Tooltip.Dot>\n <Text bold>{this.tooltipValueFormatter(dataItem[item.id])}</Text>\n </Flex>\n )\n );\n })}\n\n {showTotalInTooltip === true && (\n <Flex mt={2} justifyContent='space-between'>\n <Box mr={4}>Total</Box>\n <Text bold>{total}</Text>\n </Flex>\n )}\n </>\n ),\n };\n }}\n </HoverLine.Tooltip>\n );\n }\n}\n\nexport const AreaChart: AreaChartType = createComponent(AreaChartComponent);\n"],"mappings":";;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AACA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,CAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AAEA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AALA;AAAA,IAOMO,kBAAkB,0BAAAC,cAAA;EAAA,IAAAC,UAAA,aAAAF,kBAAA,EAAAC,cAAA;EAAA,IAAAE,MAAA,OAAAC,aAAA,aAAAJ,kBAAA;EAAA,SAAAA,mBAAA;IAAA,IAAAK,gBAAA,mBAAAL,kBAAA;IAAA,OAAAG,MAAA,CAAAG,KAAA,OAAAC,SAAA;EAAA;EAAA,IAAAC,aAAA,aAAAR,kBAAA;IAAAS,GAAA;IAAAC,GAAA,EAGtB,SAAAA,IAAA,E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CAACd,QAAQ,CAACrB,IAAI,CAACK,EAAE,CAAC,CAAC,CAAQ,CAEpE;UAEL,CAAC,CAAC,EAEDQ,kBAAkB,KAAK,IAAI,iBAC1B/E,MAAA,YAAA8D,aAAA,CAACvD,QAAA,CAAAuF,IAAI;YAACQ,EAAE,EAAE,CAAE;YAACP,cAAc,EAAC;UAAe,gBACzC/F,MAAA,YAAA8D,aAAA,CAACvD,QAAA,CAAAgG,GAAG;YAACN,EAAE,EAAE;UAAE,GAAC,OAAK,CAAM,eACvBjG,MAAA,YAAA8D,aAAA,CAACtD,WAAA,CAAA2F,IAAI;YAACC,IAAI;UAAA,GAAEZ,KAAK,CAAQ,CAE5B;QAGP,CAAC;MACH,CAAC,CACiB;IAExB;EAAC;EAAA,OAAA/E,kBAAA;AAAA,EA9H8B+F,6BAAa;AAAA,IAAAC,gBAAA,aAAxChG,kBAAkB,iBACD,YAAY;AAgI5B,IAAMiG,SAAwB,GAAG,IAAAC,gBAAe,EAAClG,kBAAkB,CAAC;AAACmG,OAAA,CAAAF,SAAA,GAAAA,SAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AreaChart.type.js","names":[],"sources":["../../../../src/component/Chart/AreaChart.type.ts"],"sourcesContent":["import { Intergalactic } from '@semcore/core';\nimport { Flex } from '@semcore/flex-box';\nimport { interpolateValue } from '../../utils';\nimport { ScaleLinear, ScaleTime } from 'd3-scale';\nimport { CurveFactory } from 'd3-shape';\nimport { BaseChartProps } from './AbstractChart.type';\n\nexport type AreaChartData = Array<Record<string, number | typeof interpolateValue | Date>>;\n\nexport type AreaChartProps = BaseChartProps<AreaChartData> & {\n groupKey: string;\n xScale?: ScaleLinear<any, any> | ScaleTime<any, any>;\n yScale?: ScaleLinear<any, any>;\n showDots?: boolean;\n curve?: CurveFactory;\n stacked?: boolean;\n};\n\nexport type AreaChartType = Intergalactic.Component<typeof Flex, AreaChartProps>;\n"],"mappings":""}
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.BarChart = void 0;
|
|
8
|
+
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
9
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
12
|
+
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
13
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
14
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
+
var _createSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/createSuper"));
|
|
16
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
17
|
+
var _react = _interopRequireDefault(require("react"));
|
|
18
|
+
var _core = _interopRequireDefault(require("@semcore/core"));
|
|
19
|
+
var _d3Scale = require("d3-scale");
|
|
20
|
+
var _ = require("../..");
|
|
21
|
+
var _AbstractChart2 = require("./AbstractChart");
|
|
22
|
+
var _flexBox = require("@semcore/flex-box");
|
|
23
|
+
var _typography = require("@semcore/typography");
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
var BarChartComponent = /*#__PURE__*/function (_AbstractChart) {
|
|
26
|
+
(0, _inherits2["default"])(BarChartComponent, _AbstractChart);
|
|
27
|
+
var _super = (0, _createSuper2["default"])(BarChartComponent);
|
|
28
|
+
function BarChartComponent() {
|
|
29
|
+
(0, _classCallCheck2["default"])(this, BarChartComponent);
|
|
30
|
+
return _super.apply(this, arguments);
|
|
31
|
+
}
|
|
32
|
+
(0, _createClass2["default"])(BarChartComponent, [{
|
|
33
|
+
key: "xScale",
|
|
34
|
+
get: function get() {
|
|
35
|
+
var _this$asProps = this.asProps,
|
|
36
|
+
xScale = _this$asProps.xScale,
|
|
37
|
+
invertAxis = _this$asProps.invertAxis;
|
|
38
|
+
if (xScale) {
|
|
39
|
+
return xScale;
|
|
40
|
+
}
|
|
41
|
+
return invertAxis ? this.valueScale : this.categoryScale;
|
|
42
|
+
}
|
|
43
|
+
}, {
|
|
44
|
+
key: "yScale",
|
|
45
|
+
get: function get() {
|
|
46
|
+
var _this$asProps2 = this.asProps,
|
|
47
|
+
yScale = _this$asProps2.yScale,
|
|
48
|
+
invertAxis = _this$asProps2.invertAxis;
|
|
49
|
+
if (yScale) {
|
|
50
|
+
return yScale;
|
|
51
|
+
}
|
|
52
|
+
return invertAxis ? this.categoryScale : this.valueScale;
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
key: "defaultLegendProps",
|
|
56
|
+
value: function defaultLegendProps() {
|
|
57
|
+
if (this.props.trend !== undefined) {
|
|
58
|
+
return {
|
|
59
|
+
withTrend: true
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
return {};
|
|
63
|
+
}
|
|
64
|
+
}, {
|
|
65
|
+
key: "renderTrend",
|
|
66
|
+
value: function renderTrend(key) {
|
|
67
|
+
var _this$asProps3 = this.asProps,
|
|
68
|
+
groupKey = _this$asProps3.groupKey,
|
|
69
|
+
_this$asProps3$type = _this$asProps3.type,
|
|
70
|
+
type = _this$asProps3$type === void 0 ? 'group' : _this$asProps3$type,
|
|
71
|
+
invertAxis = _this$asProps3.invertAxis,
|
|
72
|
+
trend = _this$asProps3.trend;
|
|
73
|
+
var withTrend = this.state.withTrend;
|
|
74
|
+
var trendItem = trend === null || trend === void 0 ? void 0 : trend[key];
|
|
75
|
+
if (withTrend && trendItem) {
|
|
76
|
+
return /*#__PURE__*/_react["default"].createElement(_.Line, {
|
|
77
|
+
data: trendItem,
|
|
78
|
+
key: "".concat(key, "_").concat(groupKey),
|
|
79
|
+
x: invertAxis ? 'y' : 'x',
|
|
80
|
+
y: invertAxis ? 'x' : 'y',
|
|
81
|
+
color: 'wall',
|
|
82
|
+
style: {
|
|
83
|
+
strokeWidth: 3,
|
|
84
|
+
strokeDasharray: 5
|
|
85
|
+
}
|
|
86
|
+
}, /*#__PURE__*/_react["default"].createElement(_.Line.Dots, {
|
|
87
|
+
data: trendItem,
|
|
88
|
+
display: true
|
|
89
|
+
}));
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
}, {
|
|
94
|
+
key: "renderChart",
|
|
95
|
+
value: function renderChart() {
|
|
96
|
+
var _this = this;
|
|
97
|
+
var _this$asProps4 = this.asProps,
|
|
98
|
+
groupKey = _this$asProps4.groupKey,
|
|
99
|
+
_this$asProps4$type = _this$asProps4.type,
|
|
100
|
+
type = _this$asProps4$type === void 0 ? 'group' : _this$asProps4$type,
|
|
101
|
+
invertAxis = _this$asProps4.invertAxis;
|
|
102
|
+
var _this$state = this.state,
|
|
103
|
+
dataDefinitions = _this$state.dataDefinitions,
|
|
104
|
+
highlightedLine = _this$state.highlightedLine;
|
|
105
|
+
if (dataDefinitions.length === 1) {
|
|
106
|
+
var item = dataDefinitions[0];
|
|
107
|
+
var BarComponent = invertAxis ? _.GroupBar.HorizontalBar : _.GroupBar.Bar;
|
|
108
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(BarComponent, {
|
|
109
|
+
x: invertAxis ? item.id : groupKey,
|
|
110
|
+
y: invertAxis ? groupKey : item.id,
|
|
111
|
+
key: item.id,
|
|
112
|
+
color: item.color
|
|
113
|
+
}), this.renderTrend(item.id));
|
|
114
|
+
}
|
|
115
|
+
if (type === 'group') {
|
|
116
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_.GroupBar, {
|
|
117
|
+
x: invertAxis ? undefined : groupKey,
|
|
118
|
+
y: invertAxis ? groupKey : undefined
|
|
119
|
+
}, dataDefinitions.map(function (item, index) {
|
|
120
|
+
var BarComponent = invertAxis ? _.GroupBar.HorizontalBar : _.GroupBar.Bar;
|
|
121
|
+
var commonBarComponentProps = {
|
|
122
|
+
color: item.color,
|
|
123
|
+
transparent: highlightedLine !== -1 && highlightedLine !== index
|
|
124
|
+
};
|
|
125
|
+
if (invertAxis) {
|
|
126
|
+
commonBarComponentProps.x = item.id;
|
|
127
|
+
} else {
|
|
128
|
+
commonBarComponentProps.y = item.id;
|
|
129
|
+
}
|
|
130
|
+
return item.checked && /*#__PURE__*/_react["default"].createElement(BarComponent, (0, _extends2["default"])({
|
|
131
|
+
key: item.id
|
|
132
|
+
}, commonBarComponentProps));
|
|
133
|
+
})), dataDefinitions.map(function (item) {
|
|
134
|
+
return item.checked && _this.renderTrend(item.id);
|
|
135
|
+
}));
|
|
136
|
+
}
|
|
137
|
+
if (type === 'stack') {
|
|
138
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_.StackBar, {
|
|
139
|
+
x: invertAxis ? undefined : groupKey,
|
|
140
|
+
y: invertAxis ? groupKey : undefined
|
|
141
|
+
}, dataDefinitions.map(function (item, index) {
|
|
142
|
+
var BarComponent = invertAxis ? _.StackBar.HorizontalBar : _.StackBar.Bar;
|
|
143
|
+
var commonBarComponentProps = {
|
|
144
|
+
color: item.color,
|
|
145
|
+
transparent: highlightedLine !== -1 && highlightedLine !== index
|
|
146
|
+
};
|
|
147
|
+
if (invertAxis) {
|
|
148
|
+
commonBarComponentProps.x = item.id;
|
|
149
|
+
} else {
|
|
150
|
+
commonBarComponentProps.y = item.id;
|
|
151
|
+
}
|
|
152
|
+
return item.checked && /*#__PURE__*/_react["default"].createElement(BarComponent, (0, _extends2["default"])({
|
|
153
|
+
key: item.id
|
|
154
|
+
}, commonBarComponentProps));
|
|
155
|
+
})), dataDefinitions.map(function (item) {
|
|
156
|
+
return item.checked && _this.renderTrend(item.id);
|
|
157
|
+
}));
|
|
158
|
+
}
|
|
159
|
+
return null;
|
|
160
|
+
}
|
|
161
|
+
}, {
|
|
162
|
+
key: "renderTooltip",
|
|
163
|
+
value: function renderTooltip() {
|
|
164
|
+
var _this2 = this;
|
|
165
|
+
var _this$asProps5 = this.asProps,
|
|
166
|
+
data = _this$asProps5.data,
|
|
167
|
+
groupKey = _this$asProps5.groupKey,
|
|
168
|
+
showTotalInTooltip = _this$asProps5.showTotalInTooltip,
|
|
169
|
+
showTooltip = _this$asProps5.showTooltip,
|
|
170
|
+
invertAxis = _this$asProps5.invertAxis;
|
|
171
|
+
var dataDefinitions = this.state.dataDefinitions;
|
|
172
|
+
if (!showTooltip) {
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
return /*#__PURE__*/_react["default"].createElement(_.HoverRect.Tooltip, {
|
|
176
|
+
x: invertAxis ? undefined : groupKey,
|
|
177
|
+
y: invertAxis ? groupKey : undefined,
|
|
178
|
+
wMin: 100
|
|
179
|
+
}, function (_ref) {
|
|
180
|
+
var _dataItem$groupKey;
|
|
181
|
+
var xIndex = _ref.xIndex,
|
|
182
|
+
yIndex = _ref.yIndex;
|
|
183
|
+
var index = invertAxis ? yIndex : xIndex;
|
|
184
|
+
var dataItem = data[index];
|
|
185
|
+
var total = _this2.totalValue(dataItem);
|
|
186
|
+
return {
|
|
187
|
+
children: /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_.HoverRect.Tooltip.Title, null, (_dataItem$groupKey = dataItem[groupKey]) === null || _dataItem$groupKey === void 0 ? void 0 : _dataItem$groupKey.toString()), dataDefinitions.map(function (item) {
|
|
188
|
+
return item.checked && /*#__PURE__*/_react["default"].createElement(_flexBox.Flex, {
|
|
189
|
+
justifyContent: "space-between",
|
|
190
|
+
key: item.id
|
|
191
|
+
}, /*#__PURE__*/_react["default"].createElement(_.HoverRect.Tooltip.Dot, {
|
|
192
|
+
mr: 4,
|
|
193
|
+
color: item.color
|
|
194
|
+
}, item.label), /*#__PURE__*/_react["default"].createElement(_typography.Text, {
|
|
195
|
+
bold: true
|
|
196
|
+
}, _this2.tooltipValueFormatter(dataItem[item.id])));
|
|
197
|
+
}), showTotalInTooltip === true && /*#__PURE__*/_react["default"].createElement(_flexBox.Flex, {
|
|
198
|
+
mt: 2,
|
|
199
|
+
justifyContent: "space-between"
|
|
200
|
+
}, /*#__PURE__*/_react["default"].createElement(_flexBox.Box, {
|
|
201
|
+
mr: 4
|
|
202
|
+
}, "Total"), /*#__PURE__*/_react["default"].createElement(_typography.Text, {
|
|
203
|
+
bold: true
|
|
204
|
+
}, total)))
|
|
205
|
+
};
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
}, {
|
|
209
|
+
key: "categoryScale",
|
|
210
|
+
get: function get() {
|
|
211
|
+
var _this$asProps6 = this.asProps,
|
|
212
|
+
_this$asProps6$margin = _this$asProps6.marginY,
|
|
213
|
+
marginY = _this$asProps6$margin === void 0 ? 40 : _this$asProps6$margin,
|
|
214
|
+
_this$asProps6$margin2 = _this$asProps6.marginX,
|
|
215
|
+
marginX = _this$asProps6$margin2 === void 0 ? 24 : _this$asProps6$margin2,
|
|
216
|
+
plotWidth = _this$asProps6.plotWidth,
|
|
217
|
+
plotHeight = _this$asProps6.plotHeight,
|
|
218
|
+
invertAxis = _this$asProps6.invertAxis,
|
|
219
|
+
data = _this$asProps6.data,
|
|
220
|
+
groupKey = _this$asProps6.groupKey;
|
|
221
|
+
var testItem = data[0][groupKey];
|
|
222
|
+
var range = invertAxis ? [plotHeight - marginX, this.plotPadding] : [marginY, plotWidth - this.plotPadding];
|
|
223
|
+
if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {
|
|
224
|
+
var _domain = (0, _.minMax)(data, groupKey);
|
|
225
|
+
return (0, _d3Scale.scaleTime)(_domain, range);
|
|
226
|
+
}
|
|
227
|
+
var domain = data.map(function (item) {
|
|
228
|
+
return item[groupKey];
|
|
229
|
+
});
|
|
230
|
+
return (0, _d3Scale.scaleBand)(domain, range).paddingInner(0.4).paddingOuter(0.2);
|
|
231
|
+
}
|
|
232
|
+
}, {
|
|
233
|
+
key: "valueScale",
|
|
234
|
+
get: function get() {
|
|
235
|
+
var _this$asProps7 = this.asProps,
|
|
236
|
+
_this$asProps7$margin = _this$asProps7.marginY,
|
|
237
|
+
marginY = _this$asProps7$margin === void 0 ? 40 : _this$asProps7$margin,
|
|
238
|
+
_this$asProps7$margin2 = _this$asProps7.marginX,
|
|
239
|
+
marginX = _this$asProps7$margin2 === void 0 ? 24 : _this$asProps7$margin2,
|
|
240
|
+
plotWidth = _this$asProps7.plotWidth,
|
|
241
|
+
plotHeight = _this$asProps7.plotHeight,
|
|
242
|
+
invertAxis = _this$asProps7.invertAxis,
|
|
243
|
+
type = _this$asProps7.type;
|
|
244
|
+
var max = type === 'stack' ? (0, _get2["default"])((0, _getPrototypeOf2["default"])(BarChartComponent.prototype), "maxStackedValue", this) : Math.max.apply(Math, (0, _toConsumableArray2["default"])((0, _get2["default"])((0, _getPrototypeOf2["default"])(BarChartComponent.prototype), "flatValues", this)));
|
|
245
|
+
return (0, _d3Scale.scaleLinear)().range(invertAxis ? [marginY, plotWidth - this.plotPadding] : [plotHeight - marginX, this.plotPadding]).domain([0, max]);
|
|
246
|
+
}
|
|
247
|
+
}]);
|
|
248
|
+
return BarChartComponent;
|
|
249
|
+
}(_AbstractChart2.AbstractChart);
|
|
250
|
+
(0, _defineProperty2["default"])(BarChartComponent, "displayName", 'Chart.Bar');
|
|
251
|
+
var BarChart = (0, _core["default"])(BarChartComponent);
|
|
252
|
+
exports.BarChart = BarChart;
|
|
253
|
+
//# sourceMappingURL=BarChart.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BarChart.js","names":["_react","_interopRequireDefault","require","_core","_d3Scale","_","_AbstractChart2","_flexBox","_typography","BarChartComponent","_AbstractChart","_inherits2","_super","_createSuper2","_classCallCheck2","apply","arguments","_createClass2","key","get","_this$asProps","asProps","xScale","invertAxis","valueScale","categoryScale","_this$asProps2","yScale","value","defaultLegendProps","props","trend","undefined","withTrend","renderTrend","_this$asProps3","groupKey","_this$asProps3$type","type","state","trendItem","createElement","Line","data","concat","x","y","color","style","strokeWidth","strokeDasharray","Dots","display","renderChart","_this","_this$asProps4","_this$asProps4$type","_this$state","dataDefinitions","highlightedLine","length","item","BarComponent","GroupBar","HorizontalBar","Bar","Fragment","id","map","index","commonBarComponentProps","transparent","checked","_extends2","StackBar","renderTooltip","_this2","_this$asProps5","showTotalInTooltip","showTooltip","HoverRect","Tooltip","wMin","_ref","_dataItem$groupKey","xIndex","yIndex","dataItem","total","totalValue","children","Title","toString","Flex","justifyContent","Dot","mr","label","Text","bold","tooltipValueFormatter","mt","Box","_this$asProps6","_this$asProps6$margin","marginY","_this$asProps6$margin2","marginX","plotWidth","plotHeight","testItem","range","plotPadding","Date","Number","isNaN","getMilliseconds","domain","minMax","scaleTime","scaleBand","paddingInner","paddingOuter","_this$asProps7","_this$asProps7$margin","_this$asProps7$margin2","max","_get2","_getPrototypeOf2","prototype","Math","_toConsumableArray2","scaleLinear","AbstractChart","_defineProperty2","BarChart","createComponent","exports"],"sources":["../../../../src/component/Chart/BarChart.tsx"],"sourcesContent":["import React from 'react';\nimport createComponent from '@semcore/core';\nimport { BaseLegendProps } from './AbstractChart.type';\nimport { BarChartData, BarChartProps, BarChartType } from './BarChart.type';\nimport { scaleBand, scaleLinear, scaleTime } from 'd3-scale';\n// @ts-ignore\nimport { minMax, GroupBar, HoverRect, StackBar, Line } from '../..';\nimport { AbstractChart } from './AbstractChart';\nimport { BarProps } from '../../types';\nimport { Box, Flex } from '@semcore/flex-box';\nimport { Text } from '@semcore/typography';\nimport { LegendItemKey } from '../ChartLegend/LegendItem/LegendItem.type';\n\nclass BarChartComponent extends AbstractChart<BarChartData, BarChartProps> {\n static displayName = 'Chart.Bar';\n\n get xScale() {\n const { xScale, invertAxis } = this.asProps;\n\n if (xScale) {\n return xScale;\n }\n\n return invertAxis ? this.valueScale : this.categoryScale;\n }\n\n get yScale() {\n const { yScale, invertAxis } = this.asProps;\n\n if (yScale) {\n return yScale;\n }\n\n return invertAxis ? this.categoryScale : this.valueScale;\n }\n\n protected defaultLegendProps(): Partial<BaseLegendProps> {\n if (this.props.trend !== undefined) {\n return { withTrend: true };\n }\n\n return {};\n }\n\n renderTrend(key: LegendItemKey) {\n const { groupKey, type = 'group', invertAxis, trend } = this.asProps;\n const { withTrend } = this.state;\n const trendItem = trend?.[key];\n\n if (withTrend && trendItem) {\n return (\n <Line\n data={trendItem}\n key={`${key}_${groupKey}`}\n x={invertAxis ? 'y' : 'x'}\n y={invertAxis ? 'x' : 'y'}\n color={'wall'}\n style={{ strokeWidth: 3, strokeDasharray: 5 }}\n >\n <Line.Dots data={trendItem} display />\n </Line>\n );\n }\n\n return null;\n }\n\n renderChart() {\n const { groupKey, type = 'group', invertAxis } = this.asProps;\n const { dataDefinitions, highlightedLine } = this.state;\n\n if (dataDefinitions.length === 1) {\n const item = dataDefinitions[0];\n const BarComponent = invertAxis ? GroupBar.HorizontalBar : GroupBar.Bar;\n\n return (\n <>\n <BarComponent\n x={invertAxis ? item.id : groupKey}\n y={invertAxis ? groupKey : item.id}\n key={item.id}\n color={item.color}\n />\n {this.renderTrend(item.id)}\n </>\n );\n }\n\n if (type === 'group') {\n return (\n <>\n <GroupBar x={invertAxis ? undefined : groupKey} y={invertAxis ? groupKey : undefined}>\n {dataDefinitions.map((item, index) => {\n const BarComponent = invertAxis ? GroupBar.HorizontalBar : GroupBar.Bar;\n\n const commonBarComponentProps: BarProps = {\n color: item.color,\n transparent: highlightedLine !== -1 && highlightedLine !== index,\n };\n\n if (invertAxis) {\n commonBarComponentProps.x = item.id;\n } else {\n commonBarComponentProps.y = item.id;\n }\n\n return item.checked && <BarComponent key={item.id} {...commonBarComponentProps} />;\n })}\n </GroupBar>\n {dataDefinitions.map((item) => item.checked && this.renderTrend(item.id))}\n </>\n );\n }\n\n if (type === 'stack') {\n return (\n <>\n <StackBar x={invertAxis ? undefined : groupKey} y={invertAxis ? groupKey : undefined}>\n {dataDefinitions.map((item, index) => {\n const BarComponent = invertAxis ? StackBar.HorizontalBar : StackBar.Bar;\n\n const commonBarComponentProps: BarProps = {\n color: item.color,\n transparent: highlightedLine !== -1 && highlightedLine !== index,\n };\n\n if (invertAxis) {\n commonBarComponentProps.x = item.id;\n } else {\n commonBarComponentProps.y = item.id;\n }\n\n return item.checked && <BarComponent key={item.id} {...commonBarComponentProps} />;\n })}\n </StackBar>\n {dataDefinitions.map((item) => item.checked && this.renderTrend(item.id))}\n </>\n );\n }\n\n return null;\n }\n\n renderTooltip(): React.ReactNode {\n const { data, groupKey, showTotalInTooltip, showTooltip, invertAxis } = this.asProps;\n const { dataDefinitions } = this.state;\n\n if (!showTooltip) {\n return null;\n }\n\n return (\n <HoverRect.Tooltip\n x={invertAxis ? undefined : groupKey}\n y={invertAxis ? groupKey : undefined}\n wMin={100}\n >\n {({ xIndex, yIndex }: any) => {\n const index = invertAxis ? yIndex : xIndex;\n const dataItem = data[index];\n const total = this.totalValue(dataItem);\n\n return {\n children: (\n <>\n <HoverRect.Tooltip.Title>{dataItem[groupKey]?.toString()}</HoverRect.Tooltip.Title>\n\n {dataDefinitions.map((item) => {\n return (\n item.checked && (\n <Flex justifyContent='space-between' key={item.id}>\n <HoverRect.Tooltip.Dot mr={4} color={item.color}>\n {item.label}\n </HoverRect.Tooltip.Dot>\n <Text bold>{this.tooltipValueFormatter(dataItem[item.id])}</Text>\n </Flex>\n )\n );\n })}\n\n {showTotalInTooltip === true && (\n <Flex mt={2} justifyContent='space-between'>\n <Box mr={4}>Total</Box>\n <Text bold>{total}</Text>\n </Flex>\n )}\n </>\n ),\n };\n }}\n </HoverRect.Tooltip>\n );\n }\n\n private get categoryScale() {\n const {\n marginY = 40,\n marginX = 24,\n plotWidth,\n plotHeight,\n invertAxis,\n data,\n groupKey,\n } = this.asProps;\n\n const testItem = data[0][groupKey];\n const range = invertAxis\n ? [plotHeight - marginX, this.plotPadding]\n : [marginY, plotWidth - this.plotPadding];\n\n if (testItem instanceof Date && !Number.isNaN(testItem.getMilliseconds())) {\n const domain = minMax(data, groupKey);\n\n return scaleTime(domain, range);\n }\n\n const domain = data.map((item) => item[groupKey]);\n\n return scaleBand(domain, range).paddingInner(0.4).paddingOuter(0.2);\n }\n\n private get valueScale() {\n const { marginY = 40, marginX = 24, plotWidth, plotHeight, invertAxis, type } = this.asProps;\n\n const max = type === 'stack' ? super.maxStackedValue : Math.max(...super.flatValues);\n\n return scaleLinear()\n .range(\n invertAxis\n ? [marginY, plotWidth - this.plotPadding]\n : [plotHeight - marginX, this.plotPadding],\n )\n .domain([0, max]);\n }\n}\n\nexport const BarChart: BarChartType = createComponent(BarChartComponent);\n"],"mappings":";;;;;;;;;;;;;;;;AAAA,IAAAA,MAAA,GAAAC,sBAAA,CAAAC,OAAA;AACA,IAAAC,KAAA,GAAAF,sBAAA,CAAAC,OAAA;AAGA,IAAAE,QAAA,GAAAF,OAAA;AAEA,IAAAG,CAAA,GAAAH,OAAA;AACA,IAAAI,eAAA,GAAAJ,OAAA;AAEA,IAAAK,QAAA,GAAAL,OAAA;AACA,IAAAM,WAAA,GAAAN,OAAA;AALA;AAAA,IAQMO,iBAAiB,0BAAAC,cAAA;EAAA,IAAAC,UAAA,aAAAF,iBAAA,EAAAC,cAAA;EAAA,IAAAE,MAAA,OAAAC,aAAA,aAAAJ,iBAAA;EAAA,SAAAA,kBAAA;IAAA,IAAAK,gBAAA,mBAAAL,iBAAA;IAAA,OAAAG,MAAA,CAAAG,KAAA,OAAAC,SAAA;EAAA;EAAA,IAAAC,aAAA,aAAAR,iBAAA;IAAAS,GAAA;IAAAC,GAAA,EAGrB,SAAAA,IAAA,EAAa;MACX,IAAAC,aAAA,GAA+B,IAAI,CAACC,OAAO;Q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sBAAA;QAAEjB,SAAS,GAAAe,cAAA,CAATf,SAAS;QAAEC,UAAU,GAAAc,cAAA,CAAVd,UAAU;QAAEtF,UAAU,GAAAoG,cAAA,CAAVpG,UAAU;QAAEe,IAAI,GAAAqF,cAAA,CAAJrF,IAAI;MAE3E,IAAMwF,GAAG,GAAGxF,IAAI,KAAK,OAAO,OAAAyF,KAAA,iBAAAC,gBAAA,aAAAvH,iBAAA,CAAAwH,SAAA,8BAA2BC,IAAI,CAACJ,GAAG,CAAA/G,KAAA,CAARmH,IAAI,MAAAC,mBAAA,iBAAAJ,KAAA,iBAAAC,gBAAA,aAAAvH,iBAAA,CAAAwH,SAAA,wBAAyB;MAEpF,OAAO,IAAAG,oBAAW,GAAE,CACjBrB,KAAK,CACJxF,UAAU,GACN,CAACkF,OAAO,EAAEG,SAAS,GAAG,IAAI,CAACI,WAAW,CAAC,GACvC,CAACH,UAAU,GAAGF,OAAO,EAAE,IAAI,CAACK,WAAW,CAAC,CAC7C,CACAK,MAAM,CAAC,CAAC,CAAC,EAAES,GAAG,CAAC,CAAC;IACrB;EAAC;EAAA,OAAArH,iBAAA;AAAA,EA5N6B4H,6BAAa;AAAA,IAAAC,gBAAA,aAAvC7H,iBAAiB,iBACA,WAAW;AA8N3B,IAAM8H,QAAsB,GAAG,IAAAC,gBAAe,EAAC/H,iBAAiB,CAAC;AAACgI,OAAA,CAAAF,QAAA,GAAAA,QAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BarChart.type.js","names":[],"sources":["../../../../src/component/Chart/BarChart.type.ts"],"sourcesContent":["import { Intergalactic } from '@semcore/core';\nimport { Flex } from '@semcore/flex-box';\nimport { ScaleBand, ScaleLinear, ScaleTime } from 'd3-scale';\nimport { BaseChartProps } from './AbstractChart.type';\nimport { LegendItemKey } from '../ChartLegend/LegendItem/LegendItem.type';\n\ntype TrendItem = {\n x: number;\n y: number;\n};\n\nexport type BarChartData = Array<Record<string, string | number | Date>>;\n\nexport type BarChartProps = BaseChartProps<BarChartData> & {\n groupKey: string;\n xScale?: ScaleBand<any> | ScaleTime<any, any>;\n yScale?: ScaleLinear<any, any>;\n type?: 'stack' | 'group';\n trend?: Record<LegendItemKey, TrendItem[]>;\n};\n\nexport type BarChartType = Intergalactic.Component<typeof Flex, BarChartProps>;\n"],"mappings":""}
|