@gravity-ui/chartkit
Advanced tools
Comparing version 2.2.1 to 2.2.2
@@ -363,3 +363,3 @@ import React from 'react'; | ||
events: { | ||
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject) => void; | ||
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void; | ||
mouseOver: () => void; | ||
@@ -390,3 +390,3 @@ mouseOut: () => void; | ||
events: { | ||
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject) => void; | ||
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void; | ||
}; | ||
@@ -393,0 +393,0 @@ }; |
@@ -521,3 +521,3 @@ export function synchronizeTooltipTablesCellsWidth(tooltipContainer: any, isMobile: any): false | undefined; | ||
events: { | ||
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject) => void; | ||
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void; | ||
mouseOver: () => void; | ||
@@ -548,3 +548,3 @@ mouseOut: () => void; | ||
events: { | ||
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject) => void; | ||
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void; | ||
}; | ||
@@ -551,0 +551,0 @@ }; |
import Highcharts from 'highcharts'; | ||
export declare const handleLegendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject) => void; | ||
export declare const handleLegendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void; |
import { drawComments, hideComments } from '../comments/drawing'; | ||
import { isNavigatorSeries } from './utils'; | ||
const getSeriesIdentifier = (series) => { | ||
return series.userOptions.id || series.name; | ||
import Highcharts from 'highcharts'; | ||
const getSeriesIdentifier = (item) => { | ||
if (item instanceof Highcharts.Point) { | ||
return item.name; | ||
} | ||
return item.userOptions.id || item.name; | ||
}; | ||
@@ -10,2 +14,4 @@ const needSetVisible = (seriesName, seriesVisible, chartSeries) => { | ||
} | ||
// TypeScript have problems when filter/map/reduce with union type arrays. | ||
// https://github.com/microsoft/TypeScript/issues/44373 | ||
const hasAnotherVisibleSeries = chartSeries | ||
@@ -22,2 +28,6 @@ .filter((series) => series.options.showInLegend !== false && getSeriesIdentifier(series) !== seriesName) | ||
if (getSeriesIdentifier(item) === clickedSeriesName) { | ||
// Highcharts.Series has serVisible in types | ||
// Highcharts.Point doesn't have this method in types | ||
// but it has this method in __proto__ and it works | ||
// @ts-ignore | ||
item.setVisible(!item.visible, false); | ||
@@ -32,5 +42,7 @@ } | ||
if (getSeriesIdentifier(item) === clickedSeriesName) { | ||
// @ts-ignore | ||
item.setVisible(true, false); | ||
} | ||
else { | ||
// @ts-ignore | ||
item.setVisible(visible, false); | ||
@@ -53,6 +65,4 @@ } | ||
const series = event.target; | ||
const chart = series.chart ? series.chart : series.series.chart; | ||
const chartSeries = series.chart | ||
? chart.series | ||
: series.series.data; | ||
const chart = series instanceof Highcharts.Point ? series.series.chart : series.chart; | ||
const chartSeries = series instanceof Highcharts.Point ? series.series.data : series.chart.series; | ||
if (isNavigatorSeries(series)) { | ||
@@ -59,0 +69,0 @@ return; |
import type { Highcharts } from '../../../../types'; | ||
export declare const isNavigatorSeries: (series?: Highcharts.Series | undefined) => boolean; | ||
export declare const isNavigatorSeries: (series?: Highcharts.Point | Highcharts.Series | undefined) => boolean; |
@@ -357,3 +357,3 @@ import type { ChartKitHolidays } from '../../../../types'; | ||
events: { | ||
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject) => void; | ||
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void; | ||
mouseOver: () => void; | ||
@@ -384,3 +384,3 @@ mouseOut: () => void; | ||
events: { | ||
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject) => void; | ||
legendItemClick: (event: Highcharts.SeriesLegendItemClickEventObject | Highcharts.PointLegendItemClickEventObject) => void; | ||
}; | ||
@@ -387,0 +387,0 @@ }; |
# Changelog | ||
## [2.2.2](https://github.com/gravity-ui/chartkit/compare/v2.2.1...v2.2.2) (2023-03-28) | ||
### Bug Fixes | ||
* **Highcharts plugin:** fix legend item click ([#142](https://github.com/gravity-ui/chartkit/issues/142)) ([a64f1b9](https://github.com/gravity-ui/chartkit/commit/a64f1b962bec45bfd2568110c1c9050fc9d75807)) | ||
## [2.2.1](https://github.com/gravity-ui/chartkit/compare/v2.2.0...v2.2.1) (2023-03-27) | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "@gravity-ui/chartkit", | ||
"version": "2.2.1", | ||
"version": "2.2.2", | ||
"description": "React component used to render charts based on any sources you need", | ||
@@ -5,0 +5,0 @@ "license": "MIT", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
920014
26165