@gravity-ui/chartkit 2.10.0 → 2.10.1

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 CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [2.10.1](https://github.com/gravity-ui/chartkit/compare/v2.10.0...v2.10.1) (2023-06-19)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **Highcharts plugin:** show totals of selected series on legend click ([#176](https://github.com/gravity-ui/chartkit/issues/176)) ([ac7fe22](https://github.com/gravity-ui/chartkit/commit/ac7fe224363f7379f6dd35db0a3a682cdc7a2bc2))
9
+
3
10
  ## [2.10.0](https://github.com/gravity-ui/chartkit/compare/v2.9.0...v2.10.0) (2023-06-05)
4
11
 
5
12
 
@@ -0,0 +1,4 @@
1
+ import { Meta, Story } from '@storybook/react';
2
+ declare const _default: Meta<import("@storybook/react").Args>;
3
+ export default _default;
4
+ export declare const WithTotals: Story<any>;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { ChartKit } from '../../../../components/ChartKit';
3
+ import { data } from '../../mocks/pie-with-totals';
4
+ import { ChartStory } from '../components/ChartStory';
5
+ export default {
6
+ title: 'Plugins/Highcharts/Pie',
7
+ component: ChartKit,
8
+ };
9
+ const Template = () => {
10
+ return React.createElement(ChartStory, { data: data });
11
+ };
12
+ export const WithTotals = Template.bind({});
@@ -0,0 +1,2 @@
1
+ import { HighchartsWidgetData } from '../types';
2
+ export declare const data: HighchartsWidgetData;
@@ -0,0 +1,43 @@
1
+ export const data = {
2
+ data: {
3
+ graphs: [
4
+ {
5
+ name: 'Number of requests',
6
+ tooltip: {
7
+ chartKitFormatting: true,
8
+ chartKitPrecision: 0,
9
+ },
10
+ dataLabels: {
11
+ format: null,
12
+ chartKitFormatting: true,
13
+ chartKitPrecision: 0,
14
+ chartKitPrefix: '',
15
+ chartKitPostfix: '',
16
+ chartKitLabelMode: 'absolute',
17
+ chartKitFormat: 'number',
18
+ chartKitShowRankDelimiter: true,
19
+ },
20
+ data: [
21
+ { name: 'Furniture', y: 14344, label: 14344 },
22
+ { name: 'Domestic chemistry', y: 14244, label: 14244 },
23
+ { name: 'Household goods', y: 14181, label: 14181 },
24
+ ],
25
+ },
26
+ ],
27
+ categories: ['Furniture', 'Domestic chemistry', 'Household goods'],
28
+ totals: 42769,
29
+ },
30
+ config: {
31
+ showPercentInTooltip: true,
32
+ },
33
+ libraryConfig: {
34
+ chart: {
35
+ type: 'pie',
36
+ },
37
+ plotOptions: {
38
+ pie: {
39
+ innerSize: '50%',
40
+ },
41
+ },
42
+ },
43
+ };
@@ -1227,11 +1227,14 @@ export function prepareConfig(data, options, isMobile, holidays) {
1227
1227
  } }, (chartType === 'pie' &&
1228
1228
  totals && {
1229
1229
  render: function () {
1230
+ var _a;
1230
1231
  const chart = this;
1231
1232
  const chartSeries = chart.series[0];
1232
1233
  const innerWidth = chartSeries === null || chartSeries === void 0 ? void 0 : chartSeries.center[3];
1234
+ const formatOptions = (_a = chartSeries === null || chartSeries === void 0 ? void 0 : chartSeries.userOptions) === null || _a === void 0 ? void 0 : _a.tooltip;
1235
+ const value = formatDonutTotals(chartSeries === null || chartSeries === void 0 ? void 0 : chartSeries.total, formatOptions) || totals;
1233
1236
  if (innerWidth) {
1234
- debouncedAdjustDonutFontSize(chart, chartSeries, innerWidth, totals);
1237
+ debouncedAdjustDonutFontSize(chart, chartSeries, innerWidth, value);
1235
1238
  }
1236
1239
  },
1237
1240
  })),
@@ -34,6 +34,7 @@ export declare type HighchartsWidgetData = {
34
34
  } | {
35
35
  graphs: CkHighchartsSeriesOptionsType[];
36
36
  categories: string[];
37
+ totals?: number | string;
37
38
  } | {
38
39
  graphs: CkHighchartsSeriesOptionsType[];
39
40
  }) & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/chartkit",
3
- "version": "2.10.0",
3
+ "version": "2.10.1",
4
4
  "description": "React component used to render charts based on any sources you need",
5
5
  "license": "MIT",
6
6
  "repository": "git@github.com:gravity-ui/ChartKit.git",