@cashub/ui-elv 1.0.1 → 1.0.3
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/chart/BarChart.js +8 -2
- package/chart/DoughnutChart.js +2 -1
- package/chart/LineChart.js +2 -1
- package/chart/utils/customTooltip.js +3 -7
- package/chart/utils/customTooltipLifecyclePlugin.js +21 -0
- package/chart/utils/tooltipElement.js +25 -0
- package/chart/utils/xAxisLabelTooltipPlugin.js +107 -0
- package/datetimePicker/index.js +2 -37
- package/esm/Tab/Tab.js +21 -0
- package/esm/Tab/TabList.js +160 -0
- package/esm/Tab/TabPanel.js +42 -0
- package/esm/Tab/TabTab.js +98 -0
- package/esm/Tab/index.js +23 -0
- package/esm/Tab/subComponent/TabContext.js +3 -0
- package/esm/Tab/subComponent/TabListV2.js +18 -0
- package/esm/Tab/subComponent/TabPanelV2.js +45 -0
- package/esm/Tab/subComponent/TabTabV2.js +56 -0
- package/esm/VerticalTab/TabList.js +20 -0
- package/esm/VerticalTab/TabPanel.js +45 -0
- package/esm/VerticalTab/TabTab.js +63 -0
- package/esm/VerticalTab/VerticalTab.js +34 -0
- package/esm/VerticalTab/index.js +9 -0
- package/esm/VerticalTab/subComponent/TabContext.js +3 -0
- package/esm/alert/Alert.js +22 -0
- package/esm/alert/index.js +1 -0
- package/esm/animate/Collapse.js +65 -0
- package/esm/animate/Loader.js +51 -0
- package/esm/animate/NumberCounter.js +45 -0
- package/esm/animate/PulseRing.js +26 -0
- package/esm/animate/Spinner.js +11 -0
- package/esm/animate/index.js +5 -0
- package/esm/assets/css/autocomplete.css +16 -0
- package/esm/assets/css/font.css +4 -0
- package/esm/assets/css/global.css +2 -0
- package/esm/assets/font/helvetica/Helvetica.ttf +0 -0
- package/esm/assets/font/nanumGothic/NanumGothic-Bold.ttf +0 -0
- package/esm/assets/font/nanumGothic/NanumGothic-ExtraBold.ttf +0 -0
- package/esm/assets/font/nanumGothic/NanumGothic-Regular.ttf +0 -0
- package/esm/assets/icons/app-management.png +0 -0
- package/esm/assets/icons/burger-black.png +0 -0
- package/esm/assets/icons/burger-white.png +0 -0
- package/esm/assets/icons/burger.png +0 -0
- package/esm/assets/icons/file.svg +1 -0
- package/esm/assets/icons/map_icon1.png +0 -0
- package/esm/assets/icons/map_icon4.png +0 -0
- package/esm/assets/images/bg-aside.png +0 -0
- package/esm/assets/images/bg-chart-circle.png +0 -0
- package/esm/assets/images/bg-chart-triangle.png +0 -0
- package/esm/assets/images/cashub-logo-only.png +0 -0
- package/esm/assets/images/default-user.jpg +0 -0
- package/esm/assets/images/logo-cashub.png +0 -0
- package/esm/assets/images/map.png +0 -0
- package/esm/assets/images/qrcode.png +0 -0
- package/esm/backdrop/BaseBackdrop.js +11 -0
- package/esm/backdrop/LoadingBackdrop.js +10 -0
- package/esm/backdrop/ModalBackdrop.js +8 -0
- package/esm/backdrop/index.js +3 -0
- package/esm/badge/Badge.js +19 -0
- package/esm/badge/BadgeDot.js +11 -0
- package/esm/badge/BadgeFill.js +42 -0
- package/esm/badge/BadgeFillTriangle.js +138 -0
- package/esm/badge/BadgeWithText.js +24 -0
- package/esm/badge/index.js +5 -0
- package/esm/billing/BarChart.js +45 -0
- package/esm/billing/Grid.js +38 -0
- package/esm/billing/Header2.js +19 -0
- package/esm/billing/Header3.js +31 -0
- package/esm/billing/Paragraph.js +27 -0
- package/esm/billing/ParagraphGroup.js +16 -0
- package/esm/billing/ParagraphText.js +20 -0
- package/esm/billing/Section.js +44 -0
- package/esm/billing/SectionBody.js +11 -0
- package/esm/billing/SectionHeader.js +20 -0
- package/esm/billing/__stories__/BarChart.stories.js_bak +46 -0
- package/esm/billing/__stories__/Grid.stories.js_bak +57 -0
- package/esm/billing/__stories__/Header2.stories.js_bak +62 -0
- package/esm/billing/__stories__/Header3.stories.js_bak +69 -0
- package/esm/billing/__stories__/Paragraph.stories.js_bak +84 -0
- package/esm/billing/__stories__/ParagraphGroup.stories.js_bak +68 -0
- package/esm/billing/__stories__/ParagraphText.stories.js_bak +64 -0
- package/esm/billing/__stories__/Section.stories.js_bak +115 -0
- package/esm/billing/__stories__/SectionBody.stories.js_bak +62 -0
- package/esm/billing/__stories__/SectionHeader.stories.js-bak +68 -0
- package/esm/breadcrumb/Breadcrumb.js +71 -0
- package/esm/breadcrumb/index.js +1 -0
- package/esm/button/Button.js +145 -0
- package/esm/button/ButtonGroup.js +54 -0
- package/esm/button/IconButton.js +64 -0
- package/esm/button/ScrollToTopButton.js +47 -0
- package/esm/button/index.js +4 -0
- package/esm/callout/Callout.js +45 -0
- package/esm/callout/index.js +1 -0
- package/esm/chart/BarChart.js +147 -0
- package/esm/chart/DoughnutChart.js +110 -0
- package/esm/chart/LineChart.js +140 -0
- package/esm/chart/SingleBarChart.js +35 -0
- package/esm/chart/index.js +5 -0
- package/esm/chart/utils/centerTextPlugin.js +56 -0
- package/esm/chart/utils/customTooltip.js +84 -0
- package/esm/chart/utils/customTooltipLifecyclePlugin.js +16 -0
- package/esm/chart/utils/htmlLegendPlugin.js +83 -0
- package/esm/chart/utils/index.js +3 -0
- package/esm/chart/utils/padEmptyChartBar.js +47 -0
- package/esm/chart/utils/tooltipElement.js +17 -0
- package/esm/chart/utils/xAxisLabelTooltipPlugin.js +101 -0
- package/esm/chart/utils/yAxisTopTitlePlugin.js +43 -0
- package/esm/container/FlexContainer.js +33 -0
- package/esm/container/index.js +1 -0
- package/esm/cropper/Cropper.js +47 -0
- package/esm/cropper/CropperModalHandler.js +34 -0
- package/esm/cropper/index.js +2 -0
- package/esm/cropper/subComponent/CropImageModal.js +72 -0
- package/{datetimePicker/DatetimePicker.js → esm/datetimePicker/DatetimePickerV3.js} +63 -31
- package/esm/datetimePicker/TimeInput.js +49 -0
- package/esm/datetimePicker/TimePickerStyle.js +58 -0
- package/esm/datetimePicker/TimePickerV2.js +199 -0
- package/esm/datetimePicker/accordion/Month.js +245 -0
- package/esm/datetimePicker/accordion/Year.js +275 -0
- package/esm/datetimePicker/index.js +4 -0
- package/esm/datetimePicker/provider/constant.js +38 -0
- package/esm/datetimePicker/subComponent/DateTimePickerContext.js +3 -0
- package/esm/datetimePicker/utils/GMTDate.js +9 -0
- package/esm/datetimePicker/utils/pad.js +7 -0
- package/esm/datetimePicker/utils/toUTC0.js +7 -0
- package/esm/descriptionList/DescriptionDetail.js +21 -0
- package/esm/descriptionList/DescriptionList.js +18 -0
- package/esm/descriptionList/DescriptionTerm.js +7 -0
- package/esm/descriptionList/index.js +3 -0
- package/esm/divider/Divider.js +24 -0
- package/esm/divider/index.js +1 -0
- package/esm/dropdown/Dropdown.js +48 -0
- package/esm/dropdown/DropdownButtonOption.js +36 -0
- package/esm/dropdown/DropdownContent.js +83 -0
- package/esm/dropdown/DropdownDivOption.js +19 -0
- package/esm/dropdown/DropdownItem.js +19 -0
- package/esm/dropdown/DropdownLinkOption.js +17 -0
- package/esm/dropdown/DropdownToggle.js +31 -0
- package/esm/dropdown/index.js +11 -0
- package/esm/dropdown/subComponent/DropdownContext.js +3 -0
- package/esm/dropzone/FileDropzone.js +472 -0
- package/esm/dropzone/ImageDropzone.js +327 -0
- package/esm/dropzone/index.js +2 -0
- package/esm/dropzone/subComponent/Message.js +19 -0
- package/esm/figure/IconFigure.js +35 -0
- package/esm/figure/ImageFigure.js +31 -0
- package/esm/figure/index.js +2 -0
- package/esm/file/HiddenFileInput.js +8 -0
- package/esm/file/index.js +1 -0
- package/esm/form/Checkbox.js +157 -0
- package/esm/form/Fieldset.js +11 -0
- package/esm/form/FormItem.js +15 -0
- package/esm/form/Input.js +59 -0
- package/esm/form/Label.js +54 -0
- package/esm/form/MutedText.js +14 -0
- package/esm/form/PasswordInput.js +40 -0
- package/esm/form/RadioButton.js +94 -0
- package/esm/form/SearchSelect.js +174 -0
- package/esm/form/Searchbox.js +91 -0
- package/esm/form/Slider.js +39 -0
- package/esm/form/SwitchButton.js +97 -0
- package/esm/form/Textarea.js +34 -0
- package/esm/form/TreeView.js +66 -0
- package/esm/form/index.js +14 -0
- package/esm/grid/Column.js +39 -0
- package/esm/grid/Grid.js +28 -0
- package/esm/grid/index.js +2 -0
- package/esm/heading/Heading1.js +14 -0
- package/esm/heading/Heading2.js +21 -0
- package/esm/heading/Heading3.js +42 -0
- package/esm/heading/index.js +3 -0
- package/esm/helmet/Helmet.js +17 -0
- package/esm/helmet/index.js +2 -0
- package/esm/iconbox/ApplicationIconBox.js +74 -0
- package/esm/iconbox/IconBox.js +60 -0
- package/esm/iconbox/IconBoxV2.js +63 -0
- package/esm/iconbox/index.js +3 -0
- package/esm/iconbox/subComponent/IconBoxFigure.js +43 -0
- package/esm/iconbox/subComponent/IconBoxImage.js +35 -0
- package/esm/image/ImageFluid.js +10 -0
- package/esm/image/UploadImage.js +243 -0
- package/esm/image/index.js +2 -0
- package/esm/index.js +47 -0
- package/esm/keyframe/Pulse.js +15 -0
- package/esm/keyframe/Spin.js +7 -0
- package/esm/layout/Aside.js +39 -0
- package/esm/layout/AsideHeader.jsx +27 -0
- package/esm/layout/Backdrop.js +16 -0
- package/esm/layout/Container.js +30 -0
- package/esm/layout/Footer.js +36 -0
- package/esm/layout/Header.jsx +55 -0
- package/esm/layout/Layout.jsx +84 -0
- package/esm/layout/Logo.jsx +17 -0
- package/esm/layout/MenuIcon.jsx +27 -0
- package/esm/layout/Sidebar.jsx +271 -0
- package/esm/layout/index.js +1 -0
- package/esm/link/LinkSpan.js +62 -0
- package/esm/link/index.js +1 -0
- package/esm/map/GoogleMap.js +439 -0
- package/esm/map/GoogleReverseGeolocation.js +193 -0
- package/esm/map/LeafletMap.js +224 -0
- package/esm/map/LeafletReverseGeolocation.js +94 -0
- package/esm/map/index.js +4 -0
- package/esm/map/subComponent/BasicLeafletMap.js +27 -0
- package/esm/map/subComponent/GoogleMapContainer.js +22 -0
- package/esm/map/subComponent/GoogleMapPopup.js +103 -0
- package/esm/map/subComponent/GoogleMapWrapper.js +34 -0
- package/esm/map/subComponent/LeafletDrawControl.js +116 -0
- package/esm/map/subComponent/LeafletMapContainer.js +166 -0
- package/esm/map/subComponent/MapSearchBoxControl.js +47 -0
- package/esm/modal/StateModal.js +169 -0
- package/esm/modal/TitleModal.js +241 -0
- package/esm/modal/index.js +2 -0
- package/esm/page/Disclaimer.js +121 -0
- package/esm/page/index.js +1 -0
- package/esm/paginate/Paginate.js +129 -0
- package/esm/paginate/index.js +1 -0
- package/esm/popover/Popover.js +82 -0
- package/esm/popover/index.js +1 -0
- package/esm/qrcode/QRCode.js +51 -0
- package/esm/qrcode/QRCodeContainter.js +27 -0
- package/esm/qrcode/index.js +2 -0
- package/esm/ribbon/Ribbon.js +35 -0
- package/esm/ribbon/index.js +1 -0
- package/esm/section/Section.js +126 -0
- package/esm/section/SectionBody.js +43 -0
- package/esm/section/SectionHeader.js +61 -0
- package/esm/section/SectionToolbar.js +11 -0
- package/esm/section/SectionToolbarItem.js +10 -0
- package/esm/section/index.js +5 -0
- package/esm/select/InputSelect.js +263 -0
- package/esm/select/Select.js +811 -0
- package/esm/select/index.js +2 -0
- package/esm/select/subComponent/Checkbox.js +40 -0
- package/esm/select/subComponent/Footer.js +6 -0
- package/esm/select/subComponent/ListBox.js +23 -0
- package/esm/select/subComponent/Option.js +37 -0
- package/esm/select/subComponent/OptionGroup.js +16 -0
- package/esm/select/subComponent/Options.js +25 -0
- package/esm/select/subComponent/SearchBox.js +51 -0
- package/esm/select/subComponent/SelectedMultipleCount.js +32 -0
- package/esm/select/subComponent/SelectedMultipleTags.js +47 -0
- package/esm/select/subComponent/SelectedMultipleText.js +63 -0
- package/esm/select/subComponent/SelectedSingle.js +10 -0
- package/esm/styles/GlobalStyle.js +328 -0
- package/esm/styles/config/breakpoint.style.js +7 -0
- package/esm/styles/config/header.style.js +4 -0
- package/esm/styles/config/sidebar.style.js +11 -0
- package/esm/styles/index.js +2 -0
- package/esm/styles/mixin/backgroundColor.js +38 -0
- package/esm/styles/mixin/borderColor.js +31 -0
- package/esm/styles/mixin/color.js +31 -0
- package/esm/styles/mixin/colorOnBackground.js +31 -0
- package/esm/styles/mixin/inputPlaceholder.js +24 -0
- package/esm/styles/mixin/media.js +15 -0
- package/esm/styles/mixin/rounded.js +24 -0
- package/esm/styles/mixin/scrollbar.js +26 -0
- package/esm/styles/theme/dark.theme.js +91 -0
- package/esm/styles/theme/light.theme.js +91 -0
- package/esm/styles/theme/white.theme.js +91 -0
- package/esm/styles/themes.js +9 -0
- package/esm/table/GridTable.js +329 -0
- package/esm/table/ImageBox.js +38 -0
- package/esm/table/InfiniteGridTable.js +396 -0
- package/esm/table/PermissionTable.js +57 -0
- package/esm/table/SimpleGridTable.js +136 -0
- package/esm/table/Table.js +559 -0
- package/esm/table/__mock__/columns.js +64 -0
- package/esm/table/__mock__/data.js +530 -0
- package/esm/table/hooks/index.js +2 -0
- package/esm/table/hooks/useCalculateDataRange.js +22 -0
- package/esm/table/hooks/useGenerateSort.js +32 -0
- package/esm/table/index.js +6 -0
- package/esm/table/subComponent/BaseTableHeadCell.js +54 -0
- package/esm/table/subComponent/GridTableFooter.js +17 -0
- package/esm/table/subComponent/GridTableHeadCell.js +13 -0
- package/esm/table/subComponent/Resizer.js +70 -0
- package/esm/table/subComponent/TableFooter.js +24 -0
- package/esm/table/subComponent/TableFooterInfo.js +6 -0
- package/esm/table/subComponent/TableFooterPager.js +26 -0
- package/esm/table/subComponent/TableHeadCell.js +12 -0
- package/esm/table/subComponent/TableSort.js +31 -0
- package/esm/tagify/TagifyStyle.js +54 -0
- package/esm/tagify/Tags.js +49 -0
- package/esm/tagify/index.js +3 -0
- package/esm/tagify/templates/getCreateButtonTemplate.js +12 -0
- package/esm/text/Paragraph.js +79 -0
- package/esm/text/index.js +1 -0
- package/esm/timeline/Timeline.js +132 -0
- package/esm/timeline/index.js +1 -0
- package/esm/toast/CustomToastContainer.js +38 -0
- package/esm/toast/MessageContainer.js +44 -0
- package/esm/toast/index.js +3 -0
- package/esm/toast/show.js +29 -0
- package/esm/toast/style.css +1 -0
- package/esm/tooltip/Tooltip.js +133 -0
- package/esm/tooltip/index.js +1 -0
- package/esm/treeView/TreeViewV2.js +32 -0
- package/esm/treeView/TreeflexStyle.js +43 -0
- package/esm/treeView/index.js +2 -0
- package/esm/wizard/Wizard.js +244 -0
- package/esm/wizard/index.js +1 -0
- package/index.js +0 -12
- package/layout/Sidebar.jsx +1 -1
- package/package.json +5 -4
- package/datetimePicker/DatePicker.js +0 -363
- package/datetimePicker/DatePickerV2.js +0 -407
- package/datetimePicker/DatetimePickerV2.js +0 -395
- package/datetimePicker/TimePicker.js +0 -317
- package/datetimePicker/hooks/index.js +0 -27
- package/datetimePicker/hooks/useChangeNumber.js +0 -42
- package/datetimePicker/hooks/useDecrease.js +0 -38
- package/datetimePicker/hooks/useIncrease.js +0 -38
- package/datetimePicker/subComponent/Accordion.js +0 -373
- package/datetimePicker/subComponent/CustomTimeInput.js +0 -47
- package/jsoneditor/JsonEditor.js +0 -142
- package/jsoneditor/index.js +0 -13
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { useContext, useMemo } from 'react';
|
|
2
|
+
import { ThemeContext } from 'styled-components';
|
|
3
|
+
import { Line, defaults } from 'react-chartjs-2';
|
|
4
|
+
import customTooltip from './utils/customTooltip';
|
|
5
|
+
import customTooltipLifecyclePlugin from './utils/customTooltipLifecyclePlugin';
|
|
6
|
+
import yAxisTopTitlePlugin from './utils/yAxisTopTitlePlugin';
|
|
7
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
+
const LineChart = _ref => {
|
|
9
|
+
let {
|
|
10
|
+
height = 300,
|
|
11
|
+
data,
|
|
12
|
+
options = {},
|
|
13
|
+
...props
|
|
14
|
+
} = _ref;
|
|
15
|
+
const theme = useContext(ThemeContext);
|
|
16
|
+
|
|
17
|
+
// fix: read value from theme
|
|
18
|
+
defaults.font.family = theme.fontFamily;
|
|
19
|
+
defaults.font.size = 16;
|
|
20
|
+
defaults.color = theme.fontOnBg;
|
|
21
|
+
defaults.plugins.tooltip.external = customTooltip(theme);
|
|
22
|
+
const customOptions = useMemo(() => {
|
|
23
|
+
const {
|
|
24
|
+
yAxisTopTitle
|
|
25
|
+
} = options;
|
|
26
|
+
return {
|
|
27
|
+
suggestedMax: options.suggestedMax ? options.suggestedMax : 10,
|
|
28
|
+
tooltipTitlePrefix: '',
|
|
29
|
+
tooltipLabelPrefix: '',
|
|
30
|
+
tooltipLabelPostfix: '',
|
|
31
|
+
showLegend: options.showLegend === undefined ? false : options.showLegend,
|
|
32
|
+
yAxisTopTitle: yAxisTopTitle ? yAxisTopTitle : ''
|
|
33
|
+
};
|
|
34
|
+
}, [options]);
|
|
35
|
+
if (options.tooltips) {
|
|
36
|
+
const tooltipsOptions = options.tooltips;
|
|
37
|
+
customOptions.tooltipTitlePrefix = tooltipsOptions.titlePrefix || '';
|
|
38
|
+
customOptions.tooltipLabelPrefix = tooltipsOptions.labelPrefix || '';
|
|
39
|
+
customOptions.tooltipLabelPostfix = tooltipsOptions.labelPostfix || '';
|
|
40
|
+
}
|
|
41
|
+
const defaultOptions = useMemo(() => {
|
|
42
|
+
return {
|
|
43
|
+
responsive: true,
|
|
44
|
+
maintainAspectRatio: false,
|
|
45
|
+
aspectRatio: 1,
|
|
46
|
+
interaction: {
|
|
47
|
+
mode: 'nearest',
|
|
48
|
+
intersect: false
|
|
49
|
+
},
|
|
50
|
+
plugins: {
|
|
51
|
+
legend: {
|
|
52
|
+
display: customOptions.showLegend
|
|
53
|
+
},
|
|
54
|
+
tooltip: {
|
|
55
|
+
enabled: false,
|
|
56
|
+
intersect: false,
|
|
57
|
+
filter(context) {
|
|
58
|
+
return context.label !== 'null';
|
|
59
|
+
},
|
|
60
|
+
callbacks: {
|
|
61
|
+
title(context) {
|
|
62
|
+
const content = context[0] ? context[0].label.match(/(.{1,20})/g) : '';
|
|
63
|
+
return `${customOptions.tooltipTitlePrefix}${content}`;
|
|
64
|
+
},
|
|
65
|
+
label(context) {
|
|
66
|
+
const datasetLabel = context.dataset.label || '';
|
|
67
|
+
const tooltipLabel = context.dataset.tooltipLabels?.[context.dataIndex];
|
|
68
|
+
if (tooltipLabel !== undefined) {
|
|
69
|
+
return datasetLabel ? `${datasetLabel}: ${tooltipLabel}` : `${tooltipLabel}`;
|
|
70
|
+
}
|
|
71
|
+
const content = context.dataset.data[context.dataIndex].toString();
|
|
72
|
+
return datasetLabel ? `${datasetLabel}: ${customOptions.tooltipLabelPrefix}${content}${customOptions.tooltipLabelPostfix}` : `${customOptions.tooltipLabelPrefix}${content}${customOptions.tooltipLabelPostfix}`;
|
|
73
|
+
},
|
|
74
|
+
labelColor(context) {
|
|
75
|
+
const {
|
|
76
|
+
borderColor
|
|
77
|
+
} = context.dataset;
|
|
78
|
+
return {
|
|
79
|
+
borderColor,
|
|
80
|
+
backgroundColor: borderColor
|
|
81
|
+
};
|
|
82
|
+
},
|
|
83
|
+
labelTextColor(context) {
|
|
84
|
+
const {
|
|
85
|
+
color
|
|
86
|
+
} = context.dataset;
|
|
87
|
+
if (!color) {
|
|
88
|
+
return theme.fontOnPrimary;
|
|
89
|
+
}
|
|
90
|
+
if (color && Array.isArray(color)) {
|
|
91
|
+
return color[context.dataIndex % color.length];
|
|
92
|
+
}
|
|
93
|
+
return color;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
yAxisTopTitle: {
|
|
98
|
+
title: customOptions.yAxisTopTitle
|
|
99
|
+
}
|
|
100
|
+
},
|
|
101
|
+
scales: {
|
|
102
|
+
x: {
|
|
103
|
+
grid: {
|
|
104
|
+
display: false,
|
|
105
|
+
drawBorder: false
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
y: {
|
|
109
|
+
beginAtZero: true,
|
|
110
|
+
suggestedMax: customOptions.suggestedMax,
|
|
111
|
+
grid: {
|
|
112
|
+
display: false,
|
|
113
|
+
drawBorder: false
|
|
114
|
+
},
|
|
115
|
+
ticks: {
|
|
116
|
+
callback(value) {
|
|
117
|
+
if (value % 1 === 0) {
|
|
118
|
+
return value;
|
|
119
|
+
}
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
},
|
|
125
|
+
layout: {
|
|
126
|
+
padding: {
|
|
127
|
+
top: 32
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
}, [customOptions, theme.fontOnPrimary]);
|
|
132
|
+
return /*#__PURE__*/_jsx(Line, {
|
|
133
|
+
height: height,
|
|
134
|
+
data: data,
|
|
135
|
+
options: defaultOptions,
|
|
136
|
+
plugins: [yAxisTopTitlePlugin, customTooltipLifecyclePlugin],
|
|
137
|
+
...props
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
export default LineChart;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import backgroundColor from '../styles/mixin/backgroundColor';
|
|
3
|
+
const SingleBarChart = styled.div.attrs(() => ({
|
|
4
|
+
primary: true
|
|
5
|
+
}))`
|
|
6
|
+
position: relative;
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 1rem;
|
|
9
|
+
border-radius: var(--border-radius);
|
|
10
|
+
background: var(--color-background3);
|
|
11
|
+
|
|
12
|
+
&::before {
|
|
13
|
+
position: absolute;
|
|
14
|
+
content: '';
|
|
15
|
+
width: ${_ref => {
|
|
16
|
+
let {
|
|
17
|
+
percentage
|
|
18
|
+
} = _ref;
|
|
19
|
+
return percentage;
|
|
20
|
+
}}%;
|
|
21
|
+
border-radius: var(--border-radius);
|
|
22
|
+
top: 0;
|
|
23
|
+
bottom: 0;
|
|
24
|
+
|
|
25
|
+
${backgroundColor}
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
${_ref2 => {
|
|
29
|
+
let {
|
|
30
|
+
marginTop
|
|
31
|
+
} = _ref2;
|
|
32
|
+
return marginTop && 'margin-top: var(--spacing-s)';
|
|
33
|
+
}}
|
|
34
|
+
`;
|
|
35
|
+
export default SingleBarChart;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { defaults } from 'react-chartjs-2';
|
|
2
|
+
const centerTextPlugin = {
|
|
3
|
+
id: 'centerText',
|
|
4
|
+
beforeDraw: chart => {
|
|
5
|
+
const {
|
|
6
|
+
options,
|
|
7
|
+
data
|
|
8
|
+
} = chart.config;
|
|
9
|
+
const config = options.plugins.centerText;
|
|
10
|
+
if (!config || !config.display) {
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
const {
|
|
14
|
+
ctx,
|
|
15
|
+
chartArea: {
|
|
16
|
+
top,
|
|
17
|
+
width,
|
|
18
|
+
height
|
|
19
|
+
}
|
|
20
|
+
} = chart;
|
|
21
|
+
ctx.save();
|
|
22
|
+
|
|
23
|
+
// calculate center position
|
|
24
|
+
const centerX = width / 2;
|
|
25
|
+
const centerY = height / 2 + top;
|
|
26
|
+
|
|
27
|
+
// font settings
|
|
28
|
+
const {
|
|
29
|
+
font,
|
|
30
|
+
color
|
|
31
|
+
} = defaults;
|
|
32
|
+
const {
|
|
33
|
+
family,
|
|
34
|
+
size,
|
|
35
|
+
lineHeight
|
|
36
|
+
} = font;
|
|
37
|
+
const offset = size * lineHeight / 2;
|
|
38
|
+
ctx.textAlign = 'center';
|
|
39
|
+
ctx.textBaseline = 'middle';
|
|
40
|
+
ctx.fillStyle = color;
|
|
41
|
+
const {
|
|
42
|
+
title
|
|
43
|
+
} = config;
|
|
44
|
+
if (title) {
|
|
45
|
+
ctx.font = `bold ${size}px ${family}`;
|
|
46
|
+
ctx.fillText(title, centerX, centerY - offset);
|
|
47
|
+
}
|
|
48
|
+
const total = data.datasets[0].data.reduce((total, current) => {
|
|
49
|
+
return total + current;
|
|
50
|
+
}, 0);
|
|
51
|
+
ctx.font = `${size}px ${family}`;
|
|
52
|
+
ctx.fillText(total.toLocaleString(), centerX, centerY + (title ? offset : 0));
|
|
53
|
+
ctx.restore();
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
export default centerTextPlugin;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { CUSTOM_TOOLTIP_ID, getOrCreateTooltipEl } from './tooltipElement';
|
|
2
|
+
const customTooltip = theme => {
|
|
3
|
+
// optimize: render in react way
|
|
4
|
+
return function (context) {
|
|
5
|
+
// Tooltip Element
|
|
6
|
+
const tooltipEl = getOrCreateTooltipEl(CUSTOM_TOOLTIP_ID);
|
|
7
|
+
if (!tooltipEl.querySelector('table')) {
|
|
8
|
+
tooltipEl.innerHTML = '<table></table>';
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Hide tooltip, if no tooltip or no data
|
|
12
|
+
const tooltipModel = context.tooltip;
|
|
13
|
+
if (!tooltipModel || !tooltipModel.dataPoints || !tooltipModel.dataPoints[0] || tooltipModel.opacity === 0) {
|
|
14
|
+
tooltipEl.style.display = 'none';
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Set caret Position
|
|
19
|
+
tooltipEl.classList.remove('above', 'below', 'no-transform');
|
|
20
|
+
if (tooltipModel.yAlign) {
|
|
21
|
+
tooltipEl.classList.add(tooltipModel.yAlign);
|
|
22
|
+
} else {
|
|
23
|
+
tooltipEl.classList.add('no-transform');
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// Set Text
|
|
27
|
+
if (tooltipModel.body) {
|
|
28
|
+
const titleLines = tooltipModel.title || [];
|
|
29
|
+
const bodyLines = tooltipModel.body.map(bodyItem => {
|
|
30
|
+
return bodyItem.lines || [];
|
|
31
|
+
});
|
|
32
|
+
let innerHtml = '<thead>';
|
|
33
|
+
titleLines.forEach(title => {
|
|
34
|
+
innerHtml += `<tr><th>${title}</th></tr>`;
|
|
35
|
+
});
|
|
36
|
+
innerHtml += '</thead><tbody>';
|
|
37
|
+
bodyLines.forEach(body => {
|
|
38
|
+
if (Array.isArray(body)) {
|
|
39
|
+
body.forEach(line => {
|
|
40
|
+
innerHtml += `<tr><td>${line}</td></tr>`;
|
|
41
|
+
});
|
|
42
|
+
} else {
|
|
43
|
+
innerHtml += `<tr><td>${body}</td></tr>`;
|
|
44
|
+
}
|
|
45
|
+
});
|
|
46
|
+
innerHtml += '</tbody>';
|
|
47
|
+
const tableRoot = tooltipEl.querySelector('table');
|
|
48
|
+
tableRoot.innerHTML = innerHtml;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
// `this` will be the overall tooltip
|
|
52
|
+
const position = context.chart.canvas.getBoundingClientRect();
|
|
53
|
+
|
|
54
|
+
// Display, position, and set styles for font
|
|
55
|
+
tooltipEl.style.fontFamily = theme.fontFamily;
|
|
56
|
+
tooltipEl.style.fontSize = theme.fontBody1;
|
|
57
|
+
tooltipEl.style.display = 'block';
|
|
58
|
+
tooltipEl.style.position = 'absolute';
|
|
59
|
+
tooltipEl.style.boxShadow = theme.boxShadow;
|
|
60
|
+
[tooltipEl.style.color] = tooltipModel.labelTextColors;
|
|
61
|
+
tooltipEl.style.background = tooltipModel.labelColors[0].backgroundColor;
|
|
62
|
+
tooltipEl.style.borderRadius = theme.borderRadius;
|
|
63
|
+
tooltipEl.style.textAlign = 'center';
|
|
64
|
+
tooltipEl.style.padding = `${theme.spacerXS} ${theme.spacerS}`;
|
|
65
|
+
tooltipEl.style.pointerEvents = 'none';
|
|
66
|
+
|
|
67
|
+
// determine position is left or right
|
|
68
|
+
if (tooltipModel.caretX + tooltipEl.offsetWidth <= this._chart.width) {
|
|
69
|
+
tooltipEl.style.borderTopLeftRadius = 0;
|
|
70
|
+
tooltipEl.style.left = `${position.left + window.pageXOffset + tooltipModel.caretX + 8}px`;
|
|
71
|
+
} else {
|
|
72
|
+
tooltipEl.style.borderTopRightRadius = 0;
|
|
73
|
+
tooltipEl.style.left = `${position.left + window.pageXOffset + tooltipModel.caretX - tooltipModel.width - 16 * 2}px`;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// determine position is top or bottom
|
|
77
|
+
if (tooltipModel.caretY + tooltipEl.offsetHeight <= this._chart.height) {
|
|
78
|
+
tooltipEl.style.top = `${position.top + window.pageYOffset + tooltipModel.caretY + 8}px`;
|
|
79
|
+
} else {
|
|
80
|
+
tooltipEl.style.top = `${position.top + window.pageYOffset + tooltipModel.caretY - tooltipModel.width - 16 * 2}px`;
|
|
81
|
+
}
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
export default customTooltip;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CUSTOM_TOOLTIP_ID, hideTooltipEl } from './tooltipElement';
|
|
2
|
+
|
|
3
|
+
// customTooltip.js renders #chartjs-tooltip outside React's tree (appended to
|
|
4
|
+
// document.body), so it needs an explicit hook to hide it when the chart's
|
|
5
|
+
// container resizes or the chart instance is destroyed - otherwise the last
|
|
6
|
+
// rendered tooltip is left floating, detached from the (moved/gone) chart.
|
|
7
|
+
const customTooltipLifecyclePlugin = {
|
|
8
|
+
id: 'customTooltipLifecycle',
|
|
9
|
+
resize() {
|
|
10
|
+
hideTooltipEl(CUSTOM_TOOLTIP_ID);
|
|
11
|
+
},
|
|
12
|
+
afterDestroy() {
|
|
13
|
+
hideTooltipEl(CUSTOM_TOOLTIP_ID);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
export default customTooltipLifecyclePlugin;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { defaults } from 'react-chartjs-2';
|
|
2
|
+
const htmlLegendPlugin = {
|
|
3
|
+
id: 'htmlLegend',
|
|
4
|
+
afterUpdate(chart, args, options) {
|
|
5
|
+
const ul = getOrCreateLegendList(chart, options.containerID);
|
|
6
|
+
|
|
7
|
+
// Remove old legend items
|
|
8
|
+
while (ul.firstChild) {
|
|
9
|
+
ul.firstChild.remove();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
// Reuse the built-in legendItems generator
|
|
13
|
+
const items = chart.options.plugins.legend.labels.generateLabels(chart);
|
|
14
|
+
items.forEach(item => {
|
|
15
|
+
const li = document.createElement('li');
|
|
16
|
+
li.style.alignItems = 'center';
|
|
17
|
+
li.style.cursor = 'pointer';
|
|
18
|
+
li.style.display = 'flex';
|
|
19
|
+
li.style.flexDirection = 'row';
|
|
20
|
+
li.style.marginLeft = '16px';
|
|
21
|
+
li.style.marginTop = '16px';
|
|
22
|
+
li.style.color = defaults.color;
|
|
23
|
+
const [dataset] = chart.data.datasets;
|
|
24
|
+
const description = dataset.descriptions ? dataset.descriptions[item.index] : '';
|
|
25
|
+
if (description) {
|
|
26
|
+
li.setAttribute('data-tooltip', description);
|
|
27
|
+
li.classList.add('custom-legend-tooltip');
|
|
28
|
+
}
|
|
29
|
+
li.onclick = () => {
|
|
30
|
+
const {
|
|
31
|
+
type
|
|
32
|
+
} = chart.config;
|
|
33
|
+
if (type === 'pie' || type === 'doughnut') {
|
|
34
|
+
// Pie and doughnut charts only have a single dataset and visibility is per item
|
|
35
|
+
chart.toggleDataVisibility(item.index);
|
|
36
|
+
} else {
|
|
37
|
+
chart.setDatasetVisibility(item.datasetIndex, !chart.isDatasetVisible(item.datasetIndex));
|
|
38
|
+
}
|
|
39
|
+
chart.update();
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
// Color box
|
|
43
|
+
const boxSpan = document.createElement('span');
|
|
44
|
+
boxSpan.style.background = item.fillStyle;
|
|
45
|
+
boxSpan.style.borderColor = item.strokeStyle;
|
|
46
|
+
boxSpan.style.borderWidth = `${item.lineWidth}px`;
|
|
47
|
+
boxSpan.style.borderStyle = 'solid';
|
|
48
|
+
boxSpan.style.display = 'inline-block';
|
|
49
|
+
boxSpan.style.height = '16px';
|
|
50
|
+
boxSpan.style.marginRight = '8px';
|
|
51
|
+
boxSpan.style.width = '32px';
|
|
52
|
+
|
|
53
|
+
// Text
|
|
54
|
+
const textContainer = document.createElement('p');
|
|
55
|
+
textContainer.style.color = item.fontColor;
|
|
56
|
+
textContainer.style.margin = 0;
|
|
57
|
+
textContainer.style.padding = 0;
|
|
58
|
+
textContainer.style.wordBreak = 'break-all';
|
|
59
|
+
textContainer.style.textDecoration = item.hidden ? 'line-through' : '';
|
|
60
|
+
const text = document.createTextNode(item.text);
|
|
61
|
+
textContainer.appendChild(text);
|
|
62
|
+
li.appendChild(boxSpan);
|
|
63
|
+
li.appendChild(textContainer);
|
|
64
|
+
ul.appendChild(li);
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
const getOrCreateLegendList = (chart, id) => {
|
|
69
|
+
const legendContainer = document.getElementById(id);
|
|
70
|
+
let listContainer = legendContainer.querySelector('ul');
|
|
71
|
+
if (!listContainer) {
|
|
72
|
+
listContainer = document.createElement('ul');
|
|
73
|
+
listContainer.style.display = 'flex';
|
|
74
|
+
listContainer.style.flexDirection = 'row';
|
|
75
|
+
listContainer.style.flexWrap = 'wrap';
|
|
76
|
+
listContainer.style.justifyContent = 'center';
|
|
77
|
+
listContainer.style.margin = 0;
|
|
78
|
+
listContainer.style.padding = 0;
|
|
79
|
+
legendContainer.appendChild(listContainer);
|
|
80
|
+
}
|
|
81
|
+
return listContainer;
|
|
82
|
+
};
|
|
83
|
+
export default htmlLegendPlugin;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// make chart bar seem like align left by pad empty bar at the end
|
|
2
|
+
const padEmptyChartBar = {
|
|
3
|
+
id: 'padEmptyChartBar',
|
|
4
|
+
length: -1,
|
|
5
|
+
// pad empty chart bar when data less than max bar number
|
|
6
|
+
beforeUpdate(chart) {
|
|
7
|
+
this.length = -1;
|
|
8
|
+
const {
|
|
9
|
+
data,
|
|
10
|
+
options
|
|
11
|
+
} = chart.config._config;
|
|
12
|
+
const validLabels = data.labels.filter(label => label !== null);
|
|
13
|
+
const {
|
|
14
|
+
maxBarNumber
|
|
15
|
+
} = options.plugins.padEmptyChartBar;
|
|
16
|
+
for (let index = validLabels.length; index < maxBarNumber; index += 1) {
|
|
17
|
+
this.length = this.length === -1 ? index : this.length;
|
|
18
|
+
data.labels[index] = null;
|
|
19
|
+
const [datasets] = data.datasets;
|
|
20
|
+
if (datasets) {
|
|
21
|
+
datasets.data[index] = 0;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
// prevent padded empty chart bar to be drawn
|
|
26
|
+
afterUpdate(chart) {
|
|
27
|
+
const {
|
|
28
|
+
data,
|
|
29
|
+
options
|
|
30
|
+
} = chart.config._config;
|
|
31
|
+
const {
|
|
32
|
+
maxBarNumber
|
|
33
|
+
} = options.plugins.padEmptyChartBar;
|
|
34
|
+
if (this.length === -1) {
|
|
35
|
+
// restore draw function
|
|
36
|
+
for (let index = 0; index < maxBarNumber; index += 1) {
|
|
37
|
+
// delete data.datasets[0]._meta[data.index].data[i].draw;
|
|
38
|
+
}
|
|
39
|
+
} else {
|
|
40
|
+
// prevents new charts to be drawn
|
|
41
|
+
for (let index = this.length; index < data.maxBarNumber; index += 1) {
|
|
42
|
+
data.datasets[0]._meta[data.index].data[index].draw = () => {};
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
export default padEmptyChartBar;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export const CUSTOM_TOOLTIP_ID = 'chartjs-tooltip';
|
|
2
|
+
export const AXIS_TOOLTIP_ID = 'chartjs-axis-tooltip';
|
|
3
|
+
export const getOrCreateTooltipEl = id => {
|
|
4
|
+
let tooltipEl = document.getElementById(id);
|
|
5
|
+
if (!tooltipEl) {
|
|
6
|
+
tooltipEl = document.createElement('div');
|
|
7
|
+
tooltipEl.id = id;
|
|
8
|
+
document.body.appendChild(tooltipEl);
|
|
9
|
+
}
|
|
10
|
+
return tooltipEl;
|
|
11
|
+
};
|
|
12
|
+
export const hideTooltipEl = id => {
|
|
13
|
+
const tooltipEl = document.getElementById(id);
|
|
14
|
+
if (tooltipEl) {
|
|
15
|
+
tooltipEl.style.display = 'none';
|
|
16
|
+
}
|
|
17
|
+
};
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { AXIS_TOOLTIP_ID, getOrCreateTooltipEl, hideTooltipEl } from './tooltipElement';
|
|
2
|
+
const hideTooltip = () => hideTooltipEl(AXIS_TOOLTIP_ID);
|
|
3
|
+
const getTooltipEl = () => {
|
|
4
|
+
const tooltipEl = getOrCreateTooltipEl(AXIS_TOOLTIP_ID);
|
|
5
|
+
tooltipEl.style.position = 'absolute';
|
|
6
|
+
tooltipEl.style.pointerEvents = 'none';
|
|
7
|
+
tooltipEl.style.zIndex = 80;
|
|
8
|
+
tooltipEl.style.maxWidth = '50vw';
|
|
9
|
+
tooltipEl.style.wordBreak = 'break-word';
|
|
10
|
+
tooltipEl.style.whiteSpace = 'nowrap';
|
|
11
|
+
tooltipEl.style.textAlign = 'left';
|
|
12
|
+
tooltipEl.style.border = '1px solid var(--border-color)';
|
|
13
|
+
tooltipEl.style.color = 'var(--font-on-background)';
|
|
14
|
+
tooltipEl.style.background = 'var(--color-background2)';
|
|
15
|
+
tooltipEl.style.boxShadow = 'var(--box-shadow)';
|
|
16
|
+
tooltipEl.style.borderRadius = 'calc(var(--border-radius) / 2)';
|
|
17
|
+
tooltipEl.style.padding = 'var(--spacing-xs)';
|
|
18
|
+
tooltipEl.style.fontSize = 'var(--font-body1)';
|
|
19
|
+
return tooltipEl;
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
// approximate hit-box per rendered tick: stable public getPixelForTick() + chartArea,
|
|
23
|
+
// not Chart.js's private _labelItems/_computeLabelItems (undocumented, version-fragile).
|
|
24
|
+
//
|
|
25
|
+
// Ticks are matched via xScale.ticks (the array Chart.js actually renders) rather than
|
|
26
|
+
// chart.data.labels directly, because ticks.autoSkip (on by default) drops entries when
|
|
27
|
+
// labels don't all fit - exactly the case this feature targets. Each rendered tick's
|
|
28
|
+
// `.value` is the original index into chart.data.labels, which getPixelForTick(i) does
|
|
29
|
+
// NOT return (it returns a pixel, and its `i` argument is a position in the possibly-
|
|
30
|
+
// skipped ticks array, not a label index) - so the original label index must be read
|
|
31
|
+
// back off ticks[i].value, not off the loop counter.
|
|
32
|
+
const findHoveredTickIndex = (chart, x, y) => {
|
|
33
|
+
const xScale = chart.scales.x;
|
|
34
|
+
if (!xScale) {
|
|
35
|
+
return -1;
|
|
36
|
+
}
|
|
37
|
+
const {
|
|
38
|
+
ticks
|
|
39
|
+
} = xScale;
|
|
40
|
+
if (!ticks || ticks.length === 0) {
|
|
41
|
+
return -1;
|
|
42
|
+
}
|
|
43
|
+
const {
|
|
44
|
+
chartArea
|
|
45
|
+
} = chart;
|
|
46
|
+
if (y < chartArea.bottom || y > xScale.bottom || x < chartArea.left || x > chartArea.right) {
|
|
47
|
+
return -1;
|
|
48
|
+
}
|
|
49
|
+
const halfStep = ticks.length > 1 ? Math.abs(xScale.getPixelForTick(1) - xScale.getPixelForTick(0)) / 2 : (xScale.right - xScale.left) / 2;
|
|
50
|
+
for (let i = 0; i < ticks.length; i += 1) {
|
|
51
|
+
const tickPixel = xScale.getPixelForTick(i);
|
|
52
|
+
if (tickPixel !== null && Math.abs(x - tickPixel) <= halfStep) {
|
|
53
|
+
return ticks[i].value;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
return -1;
|
|
57
|
+
};
|
|
58
|
+
const xAxisLabelTooltipPlugin = {
|
|
59
|
+
id: 'xAxisLabelTooltip',
|
|
60
|
+
afterEvent(chart, args) {
|
|
61
|
+
const config = chart.config.options.plugins.xAxisLabelTooltip;
|
|
62
|
+
if (!config || !config.enabled) {
|
|
63
|
+
hideTooltip();
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const {
|
|
67
|
+
event
|
|
68
|
+
} = args;
|
|
69
|
+
if (event.type === 'mouseout') {
|
|
70
|
+
hideTooltip();
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (event.type !== 'mousemove') {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const index = findHoveredTickIndex(chart, event.x, event.y);
|
|
77
|
+
const label = index === -1 ? undefined : chart.data.labels[index];
|
|
78
|
+
if (typeof label !== 'string' || !label) {
|
|
79
|
+
hideTooltip();
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
const tooltipEl = getTooltipEl();
|
|
83
|
+
tooltipEl.textContent = label;
|
|
84
|
+
tooltipEl.style.display = 'block';
|
|
85
|
+
const canvasRect = chart.canvas.getBoundingClientRect();
|
|
86
|
+
// index here is the original label index (see findHoveredTickIndex), so the pixel
|
|
87
|
+
// must come from getPixelForValue(index), not getPixelForTick(index) - the latter
|
|
88
|
+
// expects a position in the (possibly autoSkip-reduced) ticks array, not a label index.
|
|
89
|
+
const tickX = chart.scales.x.getPixelForValue(index);
|
|
90
|
+
tooltipEl.style.transform = 'translateX(-50%)';
|
|
91
|
+
tooltipEl.style.left = `${canvasRect.left + window.pageXOffset + tickX}px`;
|
|
92
|
+
tooltipEl.style.top = `${canvasRect.top + window.pageYOffset + chart.chartArea.bottom + 8}px`;
|
|
93
|
+
},
|
|
94
|
+
resize() {
|
|
95
|
+
hideTooltip();
|
|
96
|
+
},
|
|
97
|
+
afterDestroy() {
|
|
98
|
+
hideTooltip();
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
export default xAxisLabelTooltipPlugin;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { defaults } from 'react-chartjs-2';
|
|
2
|
+
const yAxisTopTitlePlugin = {
|
|
3
|
+
id: 'yAxisTopTitle',
|
|
4
|
+
afterDraw(chart) {
|
|
5
|
+
const {
|
|
6
|
+
options
|
|
7
|
+
} = chart.config;
|
|
8
|
+
const config = options.plugins.yAxisTopTitle;
|
|
9
|
+
if (!config || !config.title) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const {
|
|
13
|
+
title
|
|
14
|
+
} = config;
|
|
15
|
+
const {
|
|
16
|
+
ctx,
|
|
17
|
+
chartArea,
|
|
18
|
+
scales
|
|
19
|
+
} = chart;
|
|
20
|
+
const yScale = scales.y;
|
|
21
|
+
if (!yScale) {
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
ctx.save();
|
|
25
|
+
const {
|
|
26
|
+
font,
|
|
27
|
+
color
|
|
28
|
+
} = defaults;
|
|
29
|
+
const {
|
|
30
|
+
family,
|
|
31
|
+
size
|
|
32
|
+
} = font;
|
|
33
|
+
ctx.font = `bold ${size}px ${family}`;
|
|
34
|
+
ctx.fillStyle = color;
|
|
35
|
+
ctx.textAlign = 'left';
|
|
36
|
+
ctx.textBaseline = 'middle';
|
|
37
|
+
const x = yScale.left;
|
|
38
|
+
const y = chartArea.top - 24;
|
|
39
|
+
ctx.fillText(title, x, y);
|
|
40
|
+
ctx.restore();
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
export default yAxisTopTitlePlugin;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
const FlexContainer = styled.div`
|
|
3
|
+
display: flex;
|
|
4
|
+
|
|
5
|
+
${_ref => {
|
|
6
|
+
let {
|
|
7
|
+
marginBottom
|
|
8
|
+
} = _ref;
|
|
9
|
+
return marginBottom && 'margin-bottom: var(--spacing-l)';
|
|
10
|
+
}};
|
|
11
|
+
|
|
12
|
+
${_ref2 => {
|
|
13
|
+
let {
|
|
14
|
+
wrap
|
|
15
|
+
} = _ref2;
|
|
16
|
+
return wrap && 'flex-wrap: wrap';
|
|
17
|
+
}};
|
|
18
|
+
|
|
19
|
+
${_ref3 => {
|
|
20
|
+
let {
|
|
21
|
+
alignCenter
|
|
22
|
+
} = _ref3;
|
|
23
|
+
return alignCenter && 'align-items: center;';
|
|
24
|
+
}}
|
|
25
|
+
|
|
26
|
+
${_ref4 => {
|
|
27
|
+
let {
|
|
28
|
+
spaceBetween
|
|
29
|
+
} = _ref4;
|
|
30
|
+
return spaceBetween && 'justify-content: space-between;';
|
|
31
|
+
}}
|
|
32
|
+
`;
|
|
33
|
+
export default FlexContainer;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default as FlexContainer } from './FlexContainer';
|