@evergis/charts 2.0.94 → 2.0.96
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/LICENSE +20 -20
- package/README.md +13 -13
- package/dist/charts/BarChart/drawTooltip/index.d.ts +1 -1
- package/dist/charts/BarChart/drawTooltip/types.d.ts +1 -1
- package/dist/charts/BarChart/types.d.ts +2 -0
- package/dist/charts.cjs.development.js +24 -3
- package/dist/charts.cjs.development.js.map +1 -1
- package/dist/charts.cjs.production.min.js +1 -1
- package/dist/charts.cjs.production.min.js.map +1 -1
- package/dist/charts.esm.js +24 -3
- package/dist/charts.esm.js.map +1 -1
- package/package.json +2 -2
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2020 Kirill Protasov
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Kirill Protasov
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
21
|
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
# @evergis/charts
|
|
2
|
-
|
|
3
|
-
## Важно
|
|
4
|
-
|
|
5
|
-
- Стилизовать графики необходимо импортируя названия классов из библиотеки.
|
|
6
|
-
|
|
7
|
-
`import { calendarChartClassNames } from "@evergis/charts"`
|
|
8
|
-
|
|
9
|
-
## Документация зависимостей
|
|
10
|
-
|
|
11
|
-
- [d3](https://github.com/d3/d3/blob/master/API.md)
|
|
12
|
-
- [styled-components](https://styled-components.com/docs)
|
|
13
|
-
- [storybook](https://storybook.js.org/docs/react/writing-docs/docs-page)
|
|
1
|
+
# @evergis/charts
|
|
2
|
+
|
|
3
|
+
## Важно
|
|
4
|
+
|
|
5
|
+
- Стилизовать графики необходимо импортируя названия классов из библиотеки.
|
|
6
|
+
|
|
7
|
+
`import { calendarChartClassNames } from "@evergis/charts"`
|
|
8
|
+
|
|
9
|
+
## Документация зависимостей
|
|
10
|
+
|
|
11
|
+
- [d3](https://github.com/d3/d3/blob/master/API.md)
|
|
12
|
+
- [styled-components](https://styled-components.com/docs)
|
|
13
|
+
- [storybook](https://storybook.js.org/docs/react/writing-docs/docs-page)
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { DrawTooltipProps } from './types';
|
|
2
|
-
export declare const drawTooltip: ({ svg, node, data, marshalledData, xScale, yScale, renderTooltip, labelPosition, marginTop, renderLabel, barWidth, barPadding, dynamicTooltipEnable, tooltipY, tooltipBind, lineData, formatTooltipValue, formatTooltipName, tooltipYDomain, setTooltipPosition, onLabelItem, isBarTooltip, bars, tooltipRoot, tooltipClassName, }: DrawTooltipProps) => void;
|
|
2
|
+
export declare const drawTooltip: ({ svg, node, data, marshalledData, xScale, yScale, renderTooltip, labelPosition, marginTop, renderLabel, barWidth, barPadding, dynamicTooltipEnable, tooltipY, tooltipBind, lineData, formatTooltipValue, formatTooltipName, tooltipYDomain, setTooltipPosition, onLabelItem, isBarTooltip, bars, tooltipRoot, tooltipClassName, onBarClick, onBarHover, }: DrawTooltipProps) => void;
|
|
@@ -10,4 +10,4 @@ export declare type DrawTooltipProps = {
|
|
|
10
10
|
marginTop: number;
|
|
11
11
|
barWidth: number;
|
|
12
12
|
bars: d3.Selection<SVGGElement, BarChartMarshalledGroup[], SVGGElement, unknown>;
|
|
13
|
-
} & Pick<BarChartProps, 'renderTooltip' | 'labelPosition' | 'renderLabel' | 'dynamicTooltipEnable' | 'tooltipY' | 'tooltipBind' | 'lineData' | 'formatTooltipValue' | 'formatTooltipName' | 'tooltipYDomain' | 'data' | 'barPadding' | 'setTooltipPosition' | 'onLabelItem' | 'isBarTooltip' | 'tooltipRoot' | 'tooltipClassName'>;
|
|
13
|
+
} & Pick<BarChartProps, 'renderTooltip' | 'labelPosition' | 'renderLabel' | 'dynamicTooltipEnable' | 'tooltipY' | 'tooltipBind' | 'lineData' | 'formatTooltipValue' | 'formatTooltipName' | 'tooltipYDomain' | 'data' | 'barPadding' | 'setTooltipPosition' | 'onLabelItem' | 'isBarTooltip' | 'tooltipRoot' | 'tooltipClassName' | 'onBarClick' | 'onBarHover'>;
|
|
@@ -113,6 +113,8 @@ export declare type BarChartProps = {
|
|
|
113
113
|
tooltipClassName?: string;
|
|
114
114
|
selectable?: boolean;
|
|
115
115
|
onSelect?: (value: [number, number]) => void;
|
|
116
|
+
onBarClick?: (group: BarChartMarshalledGroup) => void;
|
|
117
|
+
onBarHover?: (group?: BarChartMarshalledGroup) => void;
|
|
116
118
|
};
|
|
117
119
|
export declare type BarChartMergedData = (BarChartMarshalledGroup & BarChartLineData & {
|
|
118
120
|
groupName: string;
|
|
@@ -2309,7 +2309,9 @@ const drawTooltip$2 = _ref => {
|
|
|
2309
2309
|
isBarTooltip,
|
|
2310
2310
|
bars,
|
|
2311
2311
|
tooltipRoot,
|
|
2312
|
-
tooltipClassName
|
|
2312
|
+
tooltipClassName,
|
|
2313
|
+
onBarClick,
|
|
2314
|
+
onBarHover
|
|
2313
2315
|
} = _ref;
|
|
2314
2316
|
d3.select(node).select("." + barChartClassNames.barChartMouseContainer).remove();
|
|
2315
2317
|
const xScaleBandDomain = xScale.domain();
|
|
@@ -2513,6 +2515,21 @@ const drawTooltip$2 = _ref => {
|
|
|
2513
2515
|
const container = d3.select(node).append('div').attr('class', barChartClassNames.barChartMouseContainer);
|
|
2514
2516
|
const labelContainer = container.append('div').attr('class', barChartClassNames.barChartLabelContainer).style('position', 'absolute').style('top', y2 + "px");
|
|
2515
2517
|
|
|
2518
|
+
const isMouseWithin = (e, callback) => {
|
|
2519
|
+
const [rectrX, rectrY] = d3.pointer(e, mouseRect);
|
|
2520
|
+
const [nodeX, nodeY] = d3.pointer(e, node);
|
|
2521
|
+
const x = rectrX - (rectrX - nodeX);
|
|
2522
|
+
const y = rectrY - nodeY;
|
|
2523
|
+
const currIndex = groups.findIndex(value => x <= value);
|
|
2524
|
+
const dataItem = marshalledData[currIndex][0];
|
|
2525
|
+
|
|
2526
|
+
if (dataItem.height >= y1 - y) {
|
|
2527
|
+
callback(dataItem);
|
|
2528
|
+
}
|
|
2529
|
+
};
|
|
2530
|
+
|
|
2531
|
+
mouseGlobal.on("click", e => isMouseWithin(e, dataItem => onBarClick && onBarClick(dataItem))).on("mousemove", e => isMouseWithin(e, dataItem => onBarHover && onBarHover(dataItem))).on("mouseleave", () => onBarHover && onBarHover(undefined));
|
|
2532
|
+
|
|
2516
2533
|
if (labelPosition) {
|
|
2517
2534
|
const concatedData = lineData ? marshalledData.map((stack, index) => stack.concat(lineData.map(_ref6 => {
|
|
2518
2535
|
let {
|
|
@@ -2646,7 +2663,9 @@ const draw$4 = (node, props) => {
|
|
|
2646
2663
|
isBarTooltip,
|
|
2647
2664
|
xScaleItemWidth,
|
|
2648
2665
|
tooltipRoot,
|
|
2649
|
-
tooltipClassName
|
|
2666
|
+
tooltipClassName,
|
|
2667
|
+
onBarClick,
|
|
2668
|
+
onBarHover
|
|
2650
2669
|
} = props;
|
|
2651
2670
|
|
|
2652
2671
|
if (node !== null && data.length) {
|
|
@@ -2817,7 +2836,9 @@ const draw$4 = (node, props) => {
|
|
|
2817
2836
|
isBarTooltip,
|
|
2818
2837
|
bars: groups,
|
|
2819
2838
|
tooltipRoot,
|
|
2820
|
-
tooltipClassName
|
|
2839
|
+
tooltipClassName,
|
|
2840
|
+
onBarClick,
|
|
2841
|
+
onBarHover
|
|
2821
2842
|
});
|
|
2822
2843
|
}
|
|
2823
2844
|
|