@gravity-ui/chartkit 1.5.0 → 1.5.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 CHANGED
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.5.2](https://github.com/gravity-ui/chartkit/compare/v1.5.1...v1.5.2) (2022-12-20)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * **Highcharts plugin:** add widget rendering time ([#109](https://github.com/gravity-ui/chartkit/issues/109)) ([0db5c73](https://github.com/gravity-ui/chartkit/commit/0db5c737e4de588decb6cc191fa624db8b2119b4))
9
+
10
+ ## [1.5.1](https://github.com/gravity-ui/chartkit/compare/v1.5.0...v1.5.1) (2022-12-20)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * **Highcharts plugin:** add merging serie stack name if it already exists ([#107](https://github.com/gravity-ui/chartkit/issues/107)) ([fa73b55](https://github.com/gravity-ui/chartkit/commit/fa73b5554a491f20c109416d979e74c3b9d7e2c3))
16
+
3
17
  ## [1.5.0](https://github.com/gravity-ui/chartkit/compare/v1.4.3...v1.5.0) (2022-12-19)
4
18
 
5
19
 
@@ -564,6 +564,7 @@ export declare class HighchartsComponent extends React.PureComponent<Props, Stat
564
564
  callback?: undefined;
565
565
  } | null;
566
566
  state: State;
567
+ private id?;
567
568
  private chartComponent;
568
569
  componentDidMount(): void;
569
570
  componentDidUpdate(): void;
@@ -572,6 +573,7 @@ export declare class HighchartsComponent extends React.PureComponent<Props, Stat
572
573
  extendChartInstance: (chart: Chart) => void;
573
574
  getParams: () => StringParams;
574
575
  updateParams: (params: StringParams) => void;
576
+ private getId;
575
577
  private onLoad;
576
578
  }
577
579
  export {};
@@ -3,6 +3,7 @@ import Highcharts from 'highcharts';
3
3
  import HighchartsReact from 'highcharts-react-official';
4
4
  import get from 'lodash/get';
5
5
  import { settings } from '../../../../libs';
6
+ import { markChartPerformance, getChartPerformanceDuration, getRandomCKId } from '../../../../utils';
6
7
  import { getGraph } from '../helpers/graph';
7
8
  import { initHighchartsModules } from '../helpers/init-highcharts-modules';
8
9
  import { withSplitPane } from './withSplitPane/withSplitPane';
@@ -91,8 +92,15 @@ export class HighchartsComponent extends React.PureComponent {
91
92
  if (isError) {
92
93
  return null;
93
94
  }
95
+ markChartPerformance(this.getId(true));
94
96
  return (React.createElement(Component, { key: Math.random(), options: options, highcharts: Highcharts, onSplitPaneMountCallback: this.state.callback || undefined, callback: this.extendChartInstance, constructorType: (options === null || options === void 0 ? void 0 : options.useHighStock) ? 'stockChart' : 'chart', containerProps: { className: 'chartkit-graph' }, ref: this.chartComponent }));
95
97
  }
98
+ getId(refresh = false) {
99
+ if (refresh) {
100
+ this.id = getRandomCKId();
101
+ }
102
+ return `${this.props.id}_${this.id}`;
103
+ }
96
104
  onLoad() {
97
105
  if (!this.state.isError && !this.props.splitTooltip) {
98
106
  const data = {
@@ -103,8 +111,9 @@ export class HighchartsComponent extends React.PureComponent {
103
111
  if (this.state.callback && data.widget) {
104
112
  this.state.callback(data.widget);
105
113
  }
114
+ const widgetRendering = getChartPerformanceDuration(this.getId());
106
115
  if (this.props.onLoad) {
107
- this.props.onLoad({ widget: data.widget });
116
+ this.props.onLoad({ widget: data.widget, widgetRendering });
108
117
  }
109
118
  window.requestAnimationFrame(this.reflow);
110
119
  }
@@ -1471,7 +1471,7 @@ export function prepareConfig(data, options, isMobile, holidays) {
1471
1471
  }
1472
1472
  }, false);
1473
1473
  if (serieHasIntersectionWithOthers && !hasPositiveValues && hasNegativeValues) {
1474
- serie.stack = 'negative';
1474
+ serie.stack = serie.stack ? `${serie.stack}__negative` : 'negative';
1475
1475
  }
1476
1476
  }
1477
1477
  });
@@ -1,2 +1,3 @@
1
1
  export { getRandomCKId } from './common';
2
2
  export { typedMemo } from './react';
3
+ export { getChartPerformanceDuration, markChartPerformance } from './performance';
@@ -1,2 +1,3 @@
1
1
  export { getRandomCKId } from './common';
2
2
  export { typedMemo } from './react';
3
+ export { getChartPerformanceDuration, markChartPerformance } from './performance';
@@ -0,0 +1,2 @@
1
+ export declare const markChartPerformance: (name: string) => void;
2
+ export declare const getChartPerformanceDuration: (name: string) => number | undefined;
@@ -0,0 +1,12 @@
1
+ export const markChartPerformance = (name) => {
2
+ window.performance.mark(`${name}-mark`);
3
+ };
4
+ export const getChartPerformanceDuration = (name) => {
5
+ const measureName = `${name}-measure`;
6
+ window.performance.measure(measureName, `${name}-mark`);
7
+ const entry = window.performance.getEntriesByName(measureName)[0];
8
+ if (entry) {
9
+ return entry.duration;
10
+ }
11
+ return undefined;
12
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gravity-ui/chartkit",
3
- "version": "1.5.0",
3
+ "version": "1.5.2",
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",