From bdad98eff86a701b05256c1f8720ff631ebdd5c8 Mon Sep 17 00:00:00 2001 From: Ron Newcomb Date: Fri, 1 Mar 2019 13:19:06 -0800 Subject: [PATCH 1/2] VictoryVoronoiContainer for tooltips on Line chart VictoryVoronoiContainer for tooltips on Line chart --- types/victory/index.d.ts | 75 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/types/victory/index.d.ts b/types/victory/index.d.ts index f5c67995da..f70e8f7bf9 100644 --- a/types/victory/index.d.ts +++ b/types/victory/index.d.ts @@ -420,6 +420,81 @@ declare module "victory" { export class VictoryBrushContainer extends React.Component {} + export interface VictoryVoronoiContainerProps extends VictoryContainerProps { + /** + * When the activateData prop is set to true, the active prop will be set to true on all + * data components within a voronoi area. When this prop is set to false, the onActivated + * and onDeactivated callbacks will still fire, but no mutations to data components will + * occur via Victory’s event system. + */ + activateData?: boolean; + /** + * When the activateLabels prop is set to true, the active prop will be set to true on all + * labels corresponding to points within a voronoi area. When this prop is set to false, + * the onActivated and onDeactivated callbacks will still fire, but no mutations to label + * components will occur via Victory’s event system. Labels defined directly on + * VictoryVoronoiContainer via the labels prop will still appear when this prop is set to false. + */ + activateLabels?: boolean; + /** + * When the disable prop is set to true, VictoryVoronoiContainer events will not fire. + */ + disable?: boolean; + /** + * When a labels prop is provided to VictoryVoronoiContainer it will render a label component + * rather than activating labels on the child components it renders. This is useful for + * creating multi- point tooltips. This prop should be given as a function which will be called + * once for each active point. The labels function will be called with the arguments point, + * index, and points, where point refers to a single active point, index refers to the position + * of that point in the array of active points, and points is an array of all active points. + */ + labels?: (point: any, index: number, points: any[]) => string; + /** + * The labelComponent prop specified the component that will be rendered when labels are defined + * on VictoryVoronoiContainer. If the labels prop is omitted, no label component will be rendered. + */ + labelComponent?: React.ReactElement; + /** + * The onActivated prop accepts a function to be called whenever new data points are activated. + * The function is called with the parameters points (an array of active data objects) and props + * (the props used by VictoryVoronoiContainer). + */ + onActivated?: (points: any[], props: VictoryVoronoiContainerProps) => void; + /** + * The onDeactivated prop accepts a function to be called whenever points are deactivated. The + * function is called with the parameters points (an array of the newly-deactivated data objects) + * and props (the props used by VictoryVoronoiContainer). + */ + onDeactivated?: (points: any[], props: VictoryVoronoiContainerProps) => void; + /** + * When the radius prop is set, the voronoi areas associated with each data point will be no larger + * than the given radius. This prop should be given as a number. + */ + radius?: number; + /** + * The voronoiBlacklist prop is used to specify a list of components to ignore when calculating a + * shared voronoi diagram. Components with a name prop matching an element in the voronoiBlacklist + * array will be ignored by VictoryVoronoiContainer. Ignored components will never be flagged as + * active, and will not contribute date to shared tooltips or labels. + */ + voronoiBlacklist?: string[]; + /** + *When the voronoiDimension prop is set, voronoi selection will only take the given dimension into + * account. For example, when dimension is set to “x”, all data points matching a particular x mouse + * position will be activated regardless of y value. When this prop is not given, voronoi selection + * is determined by both x any y values. + */ + voronoiDimension?: "x" | "y"; + /** + * When the voronoiPadding prop is given, the area of the chart that will trigger voronoi events is + * reduced by the given padding on every side. By default, no padding is applied, and the entire range + * of a given chart may trigger voronoi events. This prop should be given as a number. + */ + voronoiPadding?: number; + } + + export class VictoryVoronoiContainer extends React.Component { } + export interface VictoryZoomContainerProps extends VictoryContainerProps { /** * The optional allowPan prop accepts a boolean that enables the panning From 1717bac2515339ca81bbed35ba1a588bfa3bc7c1 Mon Sep 17 00:00:00 2001 From: Ron Newcomb Date: Fri, 1 Mar 2019 14:47:33 -0800 Subject: [PATCH 2/2] VictoryVoronoiContainer for tooltips on Line chart --- types/victory/index.d.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/types/victory/index.d.ts b/types/victory/index.d.ts index f70e8f7bf9..e6443c37d8 100644 --- a/types/victory/index.d.ts +++ b/types/victory/index.d.ts @@ -423,7 +423,7 @@ declare module "victory" { export interface VictoryVoronoiContainerProps extends VictoryContainerProps { /** * When the activateData prop is set to true, the active prop will be set to true on all - * data components within a voronoi area. When this prop is set to false, the onActivated + * data components within a voronoi area. When this prop is set to false, the onActivated * and onDeactivated callbacks will still fire, but no mutations to data components will * occur via Victory’s event system. */ @@ -431,8 +431,8 @@ declare module "victory" { /** * When the activateLabels prop is set to true, the active prop will be set to true on all * labels corresponding to points within a voronoi area. When this prop is set to false, - * the onActivated and onDeactivated callbacks will still fire, but no mutations to label - * components will occur via Victory’s event system. Labels defined directly on + * the onActivated and onDeactivated callbacks will still fire, but no mutations to label + * components will occur via Victory’s event system. Labels defined directly on * VictoryVoronoiContainer via the labels prop will still appear when this prop is set to false. */ activateLabels?: boolean; @@ -441,8 +441,8 @@ declare module "victory" { */ disable?: boolean; /** - * When a labels prop is provided to VictoryVoronoiContainer it will render a label component - * rather than activating labels on the child components it renders. This is useful for + * When a labels prop is provided to VictoryVoronoiContainer it will render a label component + * rather than activating labels on the child components it renders. This is useful for * creating multi- point tooltips. This prop should be given as a function which will be called * once for each active point. The labels function will be called with the arguments point, * index, and points, where point refers to a single active point, index refers to the position @@ -455,7 +455,7 @@ declare module "victory" { */ labelComponent?: React.ReactElement; /** - * The onActivated prop accepts a function to be called whenever new data points are activated. + * The onActivated prop accepts a function to be called whenever new data points are activated. * The function is called with the parameters points (an array of active data objects) and props * (the props used by VictoryVoronoiContainer). */ @@ -474,14 +474,14 @@ declare module "victory" { /** * The voronoiBlacklist prop is used to specify a list of components to ignore when calculating a * shared voronoi diagram. Components with a name prop matching an element in the voronoiBlacklist - * array will be ignored by VictoryVoronoiContainer. Ignored components will never be flagged as + * array will be ignored by VictoryVoronoiContainer. Ignored components will never be flagged as * active, and will not contribute date to shared tooltips or labels. */ voronoiBlacklist?: string[]; /** - *When the voronoiDimension prop is set, voronoi selection will only take the given dimension into + * When the voronoiDimension prop is set, voronoi selection will only take the given dimension into * account. For example, when dimension is set to “x”, all data points matching a particular x mouse - * position will be activated regardless of y value. When this prop is not given, voronoi selection + * position will be activated regardless of y value. When this prop is not given, voronoi selection * is determined by both x any y values. */ voronoiDimension?: "x" | "y";