@evergis/charts 2.0.108 → 2.0.111

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 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,5 +1,6 @@
1
1
  export declare const lineChartClassNames: {
2
2
  lineChartYScaleGlobal: string;
3
+ lineChartYScaleRight: string;
3
4
  lineChartXScaleGlobal: string;
4
5
  lineChartLinesGlobal: string;
5
6
  lineChartLine: string;
@@ -50,6 +50,7 @@ export declare type LineChartProps = {
50
50
  tooltipClassName?: string;
51
51
  xScaleItemWidth?: number;
52
52
  dotSnapping?: boolean;
53
+ rightAxis?: number[];
53
54
  };
54
55
  export declare type LineChartDot = {
55
56
  radius?: number;
@@ -1329,6 +1329,7 @@ const stackedData = data => {
1329
1329
  var _templateObject$8, _templateObject2$2;
1330
1330
  const lineChartClassNames = {
1331
1331
  lineChartYScaleGlobal: 'lineChartYScaleGlobal',
1332
+ lineChartYScaleRight: 'lineChartYScaleRight',
1332
1333
  lineChartXScaleGlobal: 'lineChartXScaleGlobal',
1333
1334
  lineChartLinesGlobal: 'lineChartLinesGlobal',
1334
1335
  lineChartLine: 'lineChartLine',
@@ -1662,7 +1663,8 @@ const draw$3 = (node, props) => {
1662
1663
  tooltipClassName,
1663
1664
  xScaleItemWidth,
1664
1665
  areaCurve,
1665
- dotSnapping
1666
+ dotSnapping,
1667
+ rightAxis
1666
1668
  } = props;
1667
1669
 
1668
1670
  if (node !== null && chartData.length) {
@@ -1689,7 +1691,8 @@ const draw$3 = (node, props) => {
1689
1691
  return d3.max(values);
1690
1692
  });
1691
1693
  const svg = appendSvg(node, width, height || 0);
1692
- const yScale = d3.scaleLinear().domain([min || 0, max || 0]).range([height - marginTop - marginBottom - (xAxisPadding || 0), marginTop]).nice();
1694
+ const yRange = [height - marginTop - marginBottom - (xAxisPadding || 0), marginTop];
1695
+ const yScale = d3.scaleLinear().domain([min || 0, max || 0]).range(yRange).nice();
1693
1696
  customYScale && customYScale(yScale);
1694
1697
  const yTicksCountDefault = 8;
1695
1698
  const yAxisLeft = d3.axisLeft(yScale).ticks(yTicksCountDefault);
@@ -1700,15 +1703,29 @@ const draw$3 = (node, props) => {
1700
1703
  width: yAxisWidth
1701
1704
  } = computeDimensions(yAxis);
1702
1705
  yAxis.attr('transform', "translate(" + (marginLeft + yAxisWidth) + ", 0)");
1706
+ let yAxisRightWidth = 0;
1707
+
1708
+ if (rightAxis) {
1709
+ const rightAxisMin = d3.min(rightAxis);
1710
+ const rightAxisMax = d3.max(rightAxis);
1711
+ const yRightScale = d3.scaleLinear().domain([rightAxisMin || 0, rightAxisMax || 0]).range(yRange).nice();
1712
+ const yAxisRightTicks = d3.axisRight(yRightScale).ticks(yTicksCountDefault);
1713
+ const yAxisRight = svg.append('g').attr('class', lineChartClassNames.lineChartYScaleGlobal + " " + lineChartClassNames.lineChartYScaleRight).call(yAxisRightTicks).call(customYAxisSelection ? customYAxisSelection : none);
1714
+ ({
1715
+ width: yAxisRightWidth
1716
+ } = computeDimensions(yAxisRight));
1717
+ yAxisRight.attr('transform', "translate(" + (width - yAxisRightWidth) + ", 0)");
1718
+ }
1703
1719
  /** xScale **/
1704
1720
 
1721
+
1705
1722
  const lastIndex = labels && labels.length ? labels.length - 1 : data.reduce((acc, _ref3) => {
1706
1723
  let {
1707
1724
  values
1708
1725
  } = _ref3;
1709
1726
  return Math.max(acc, values.length);
1710
1727
  }, 0) - 1;
1711
- const xScale = d3.scaleLinear().domain([0, lastIndex]).range([marginLeft + yAxisWidth + (yAxisPadding || 0), width - marginRight]);
1728
+ const xScale = d3.scaleLinear().domain([0, lastIndex]).range([marginLeft + yAxisWidth + (yAxisPadding || 0), width - yAxisRightWidth - marginRight]);
1712
1729
  const xAxisBottom = d3.axisBottom(xScale).tickFormat(value => // @ts-ignore
1713
1730
  labels && labels.length > 0 ? labels[value] : 0).ticks(lastIndex);
1714
1731