Skip to content

Commit

Permalink
fix: reconfigure CustomTooltipProps
Browse files Browse the repository at this point in the history
  • Loading branch information
severinlandolt committed Jan 23, 2024
1 parent a63d9f9 commit 5cc10f2
Show file tree
Hide file tree
Showing 10 changed files with 24 additions and 24 deletions.
4 changes: 2 additions & 2 deletions src/components/chart-elements/DonutChart/DonutChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { DonutChartTooltip } from "./DonutChartTooltip";
import { parseData, parseLabelInput } from "./inputParser";

import type { EventProps } from "components/chart-elements/common";
import { CustomTooltipType } from "components/chart-elements/common/CustomTooltipProps";
import { CustomTooltipProps } from "components/chart-elements/common/CustomTooltipProps";
import type BaseAnimationTimingProps from "../common/BaseAnimationTimingProps";

type DonutChartVariant = "donut" | "pie";
Expand All @@ -35,7 +35,7 @@ export interface DonutChartProps extends BaseAnimationTimingProps {
noDataText?: string;
className?: string;
onValueChange?: (value: EventProps) => void;
customTooltip?: React.ComponentType<CustomTooltipType>;
customTooltip?: React.ComponentType<CustomTooltipProps>;
}

const renderInactiveShape = (props: any) => {
Expand Down
4 changes: 2 additions & 2 deletions src/components/chart-elements/ScatterChart/ScatterChart.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import {
getYAxisDomain,
} from "../common/utils";

import { CustomTooltipType } from "components/chart-elements/common/CustomTooltipProps";
import { CustomTooltipProps } from "components/chart-elements/common/CustomTooltipProps";
import {
BaseColors,
colorPalette,
Expand Down Expand Up @@ -73,7 +73,7 @@ export interface ScatterChartProps
noDataText?: string;
enableLegendSlider?: boolean;
onValueChange?: (value: EventProps) => void;
customTooltip?: React.ComponentType<CustomTooltipType>;
customTooltip?: React.ComponentType<CustomTooltipProps>;
rotateLabelX?: {
angle: number;
verticalShift: number;
Expand Down
4 changes: 2 additions & 2 deletions src/components/chart-elements/common/BaseChartProps.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Color, ValueFormatter, IntervalType } from "../../../lib";
import type BaseAnimationTimingProps from "./BaseAnimationTimingProps";
import { CustomTooltipType } from "./CustomTooltipProps";
import { CustomTooltipProps } from "./CustomTooltipProps";

type FixedProps = {
eventType: "dot" | "category" | "bar" | "slice" | "bubble";
Expand Down Expand Up @@ -34,7 +34,7 @@ interface BaseChartProps extends BaseAnimationTimingProps, React.HTMLAttributes<
noDataText?: string;
onValueChange?: (value: EventProps) => void;
enableLegendSlider?: boolean;
customTooltip?: React.ComponentType<CustomTooltipType>;
customTooltip?: React.ComponentType<CustomTooltipProps>;
rotateLabelX?: {
angle: number;
verticalShift?: number;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { NameType, Payload } from "recharts/types/component/DefaultTooltipContent";

export type CustomTooltipType = {
export type CustomTooltipProps = {
payload: Payload<string | number | (string | number)[], string | number>[] | undefined;
active: boolean | undefined;
label: NameType | undefined;
Expand Down
2 changes: 1 addition & 1 deletion src/components/chart-elements/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export type { EventProps } from "./BaseChartProps";
export type { CustomTooltipType } from "./CustomTooltipProps";
export type { CustomTooltipProps } from "./CustomTooltipProps";
8 changes: 4 additions & 4 deletions src/stories/chart-elements/AreaChart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from "react";
import type { Meta, StoryObj } from "@storybook/react";

import { AreaChart } from "components";
import { CustomTooltipType } from "components/chart-elements/common/CustomTooltipProps";
import { CustomTooltipProps } from "components/chart-elements/common/CustomTooltipProps";
import { Color, currencyValueFormatter } from "lib";
import {
simpleBaseChartData as data,
Expand Down Expand Up @@ -228,7 +228,7 @@ export const CustomTooltipSimple: Story = {
categories: ["Sales"],
colors: customTooltipColors,
valueFormatter: currencyValueFormatter,
customTooltip: (props: CustomTooltipType) => {
customTooltip: (props: CustomTooltipProps) => {
const { payload, active, label } = props;
if (!active || !payload) return null;

Expand Down Expand Up @@ -263,7 +263,7 @@ export const CustomTooltipPreviousDay: Story = {
categories: ["Sales"],
colors: customTooltipColors,
valueFormatter: currencyValueFormatter,
customTooltip: (props: CustomTooltipType) => {
customTooltip: (props: CustomTooltipProps) => {
const { payload, active, label } = props;
if (!active || !payload) return null;

Expand Down Expand Up @@ -307,7 +307,7 @@ export const CustomTooltipComplex: Story = {
categories: ["Sales"],
colors: customTooltipColors,
valueFormatter: currencyValueFormatter,
customTooltip: (props: CustomTooltipType) => {
customTooltip: (props: CustomTooltipProps) => {
const { payload, active, label } = props;
if (!active || !payload) return null;

Expand Down
8 changes: 4 additions & 4 deletions src/stories/chart-elements/BarChart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from "react";
import type { Meta, StoryObj } from "@storybook/react";

import { BarChart } from "components";
import { CustomTooltipType } from "components/chart-elements/common/CustomTooltipProps";
import { CustomTooltipProps } from "components/chart-elements/common/CustomTooltipProps";
import { Color, currencyValueFormatter } from "lib";
import {
simpleBaseChartData as data,
Expand Down Expand Up @@ -244,7 +244,7 @@ export const CustomTooltipSimple: Story = {
categories: ["Sales"],
colors: customTooltipColors,
valueFormatter: currencyValueFormatter,
customTooltip: (props: CustomTooltipType) => {
customTooltip: (props: CustomTooltipProps) => {
const { payload, active, label } = props;
if (!active || !payload) return null;

Expand Down Expand Up @@ -279,7 +279,7 @@ export const CustomTooltipPreviousDay: Story = {
categories: ["Sales"],
colors: customTooltipColors,
valueFormatter: currencyValueFormatter,
customTooltip: (props: CustomTooltipType) => {
customTooltip: (props: CustomTooltipProps) => {
const { payload, active, label } = props;
if (!active || !payload) return null;

Expand Down Expand Up @@ -323,7 +323,7 @@ export const CustomTooltipComplex: Story = {
categories: ["Sales"],
colors: customTooltipColors,
valueFormatter: currencyValueFormatter,
customTooltip: (props: CustomTooltipType) => {
customTooltip: (props: CustomTooltipProps) => {
const { payload, active, label } = props;
if (!active || !payload) return null;

Expand Down
4 changes: 2 additions & 2 deletions src/stories/chart-elements/DonutChart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Meta, StoryObj } from "@storybook/react";

import { DonutChart } from "components";

import { CustomTooltipType } from "components/chart-elements/common/CustomTooltipProps";
import { CustomTooltipProps } from "components/chart-elements/common/CustomTooltipProps";
import { currencyValueFormatter } from "lib";
import {
simpleBaseChartData as data2,
Expand Down Expand Up @@ -144,7 +144,7 @@ export const CustomTooltipSimple: Story = {
index: "month",
category: "Sales",
valueFormatter: currencyValueFormatter,
customTooltip: (props: CustomTooltipType) => {
customTooltip: (props: CustomTooltipProps) => {
const { payload, active, label } = props;
if (!active || !payload) return null;
const categoryPayload = payload?.[0];
Expand Down
8 changes: 4 additions & 4 deletions src/stories/chart-elements/LineChart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from "react";
import type { Meta, StoryObj } from "@storybook/react";

import { LineChart } from "components";
import { CustomTooltipType } from "components/chart-elements/common/CustomTooltipProps";
import { CustomTooltipProps } from "components/chart-elements/common/CustomTooltipProps";
import { Color, currencyValueFormatter } from "lib";
import {
simpleBaseChartData as data,
Expand Down Expand Up @@ -188,7 +188,7 @@ export const CustomTooltipSimple: Story = {
categories: ["Sales"],
colors: customTooltipColors,
valueFormatter: currencyValueFormatter,
customTooltip: (props: CustomTooltipType) => {
customTooltip: (props: CustomTooltipProps) => {
const { payload, active, label } = props;
if (!active || !payload) return null;

Expand Down Expand Up @@ -223,7 +223,7 @@ export const CustomTooltipPreviousDay: Story = {
categories: ["Sales"],
colors: customTooltipColors,
valueFormatter: currencyValueFormatter,
customTooltip: (props: CustomTooltipType) => {
customTooltip: (props: CustomTooltipProps) => {
const { payload, active, label } = props;
if (!active || !payload) return null;

Expand Down Expand Up @@ -267,7 +267,7 @@ export const CustomTooltipComplex: Story = {
categories: ["Sales"],
colors: customTooltipColors,
valueFormatter: currencyValueFormatter,
customTooltip: (props: CustomTooltipType) => {
customTooltip: (props: CustomTooltipProps) => {
const { payload, active, label } = props;
if (!active || !payload) return null;

Expand Down
4 changes: 2 additions & 2 deletions src/stories/chart-elements/ScatterChart.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import React from "react";
import type { Meta, StoryObj } from "@storybook/react";

import { ScatterChart } from "components";
import { CustomTooltipType } from "components/chart-elements/common/CustomTooltipProps";
import { CustomTooltipProps } from "components/chart-elements/common/CustomTooltipProps";
import { Color } from "lib";
import {
simpleScatterChartData as data,
Expand Down Expand Up @@ -157,7 +157,7 @@ export const CustomTooltip: Story = {
args: {
colors: customTooltipColors,
category: customTooltipIndex,
customTooltip: (props: CustomTooltipType) => {
customTooltip: (props: CustomTooltipProps) => {
const { payload, active, label } = props;
if (!active || !payload) return null;

Expand Down

0 comments on commit 5cc10f2

Please sign in to comment.