{"version":3,"sources":["../src/area-chart.tsx"],"sourcesContent":["import type { HTMLUIProps, ThemeProps } from \"@yamada-ui/core\"\nimport type { UseAreaChartOptions } from \"./use-area-chart\"\nimport type { UseChartProps } from \"./use-chart\"\nimport type { UseChartAxisOptions } from \"./use-chart-axis\"\nimport type { UseChartGridOptions } from \"./use-chart-grid\"\nimport type { UseChartLegendProps } from \"./use-chart-legend\"\nimport type { UseChartReferenceLineOptions } from \"./use-chart-reference-line\"\nimport type { UseChartTooltipOptions } from \"./use-chart-tooltip\"\nimport {\n  forwardRef,\n  omitThemeProps,\n  ui,\n  useComponentMultiStyle,\n} from \"@yamada-ui/core\"\nimport { cx } from \"@yamada-ui/utils\"\nimport { Fragment, useMemo } from \"react\"\nimport {\n  Area,\n  CartesianGrid,\n  Label,\n  Legend,\n  AreaChart as ReChartsAreaChart,\n  ReferenceLine,\n  ResponsiveContainer,\n  Tooltip,\n  XAxis,\n  YAxis,\n} from \"recharts\"\nimport { AreaGradient } from \"./area-chart-gradient\"\nimport { AreaSplit } from \"./area-chart-split\"\nimport { ChartLegend } from \"./chart-legend\"\nimport { ChartTooltip } from \"./chart-tooltip\"\nimport { useAreaChart } from \"./use-area-chart\"\nimport { ChartProvider, useChart } from \"./use-chart\"\nimport { useChartAxis } from \"./use-chart-axis\"\nimport { useChartGrid } from \"./use-chart-grid\"\nimport { useChartLegend } from \"./use-chart-legend\"\nimport { useChartReferenceLine } from \"./use-chart-reference-line\"\nimport { useChartTooltip } from \"./use-chart-tooltip\"\n\ninterface AreaChartOptions {\n  /**\n   * If `true`, legend is visible.\n   *\n   * @default false\n   */\n  withLegend?: boolean\n  /**\n   * If `true`, tooltip is visible.\n   *\n   * @default true\n   */\n  withTooltip?: boolean\n}\n\nexport interface AreaChartProps\n  extends Omit<HTMLUIProps, \"fillOpacity\" | \"strokeDasharray\" | \"strokeWidth\">,\n    ThemeProps<\"AreaChart\">,\n    AreaChartOptions,\n    UseAreaChartOptions,\n    UseChartProps,\n    UseChartAxisOptions,\n    UseChartReferenceLineOptions,\n    UseChartGridOptions,\n    UseChartTooltipOptions,\n    UseChartLegendProps {}\n\n/**\n * `AreaChart` is a component for drawing area charts to compare multiple sets of data.\n *\n * @see Docs https://yamada-ui.com/components/data-display/area-chart\n */\nexport const AreaChart = forwardRef<AreaChartProps, \"div\">((props, ref) => {\n  const [styles, mergedProps] = useComponentMultiStyle(\"AreaChart\", props)\n  const {\n    type = \"default\",\n    className,\n    connectNulls,\n    curveType,\n    data,\n    dataKey,\n    fillOpacity,\n    gridAxis,\n    labelFormatter,\n    layoutType,\n    series,\n    splitColors,\n    splitOffset,\n    strokeDasharray,\n    strokeWidth,\n    syncId,\n    tickLine,\n    tooltipAnimationDuration,\n    unit,\n    valueFormatter,\n    withActiveDots,\n    withDots,\n    withGradient,\n    withLegend = false,\n    withTooltip = true,\n    withXAxis,\n    withYAxis,\n    xAxisLabel,\n    xAxisTickFormatter,\n    yAxisLabel,\n    yAxisTickFormatter,\n    areaProps,\n    chartProps,\n    containerProps,\n    gridProps,\n    legendProps,\n    referenceLineProps = [],\n    tooltipProps,\n    xAxisLabelProps,\n    xAxisProps,\n    yAxisLabelProps,\n    yAxisProps,\n    ...rest\n  } = omitThemeProps(mergedProps)\n\n  const {\n    areaVars,\n    setHighlightedArea,\n    getAreaChartProps,\n    getAreaGradientProps,\n    getAreaProps,\n    getAreaSplitProps,\n  } = useAreaChart({\n    type,\n    connectNulls,\n    curveType,\n    data,\n    fillOpacity,\n    layoutType,\n    series,\n    splitColors,\n    splitOffset,\n    strokeWidth,\n    styles,\n    syncId,\n    withActiveDots,\n    withDots,\n    withGradient,\n    xAxisLabel,\n    yAxisLabel,\n    areaProps,\n    chartProps,\n    referenceLineProps,\n  })\n  const { getContainerProps } = useChart({ containerProps })\n  const {\n    getXAxisLabelProps,\n    getXAxisProps,\n    getYAxisLabelProps,\n    getYAxisProps,\n  } = useChartAxis({\n    type,\n    dataKey,\n    gridAxis,\n    layoutType,\n    styles,\n    tickLine,\n    unit,\n    withXAxis,\n    withYAxis,\n    xAxisLabel,\n    xAxisTickFormatter,\n    yAxisLabel,\n    yAxisTickFormatter,\n    xAxisLabelProps,\n    xAxisProps,\n    yAxisLabelProps,\n    yAxisProps,\n  })\n  const { getReferenceLineProps } = useChartReferenceLine({\n    styles,\n    referenceLineProps,\n  })\n  const { getGridProps } = useChartGrid({\n    gridAxis,\n    strokeDasharray,\n    styles,\n    gridProps,\n  })\n  const { getTooltipProps, tooltipProps: computedTooltipProps } =\n    useChartTooltip({\n      styles,\n      tooltipAnimationDuration,\n      tooltipProps,\n    })\n  const { getLegendProps, legendProps: computedLegendProps } = useChartLegend({\n    legendProps,\n  })\n\n  const areas = useMemo(\n    () =>\n      series.map(({ dataKey }, index) => {\n        const { id, stroke, ...rest } = getAreaProps({\n          className: \"ui-area-chart__area\",\n          index,\n        })\n\n        return (\n          <Fragment key={`area-${dataKey}`}>\n            <defs>\n              <AreaGradient {...getAreaGradientProps({ id, color: stroke })} />\n            </defs>\n\n            <Area id={id} stroke={stroke} {...rest} />\n          </Fragment>\n        )\n      }),\n    [getAreaGradientProps, getAreaProps, series],\n  )\n\n  const referenceLinesItems = useMemo(\n    () =>\n      referenceLineProps.map((_, index) => (\n        <ReferenceLine\n          key={`referenceLine-${index}`}\n          {...getReferenceLineProps({\n            className: \"ui-area-chart__reference-line\",\n            index,\n          })}\n        />\n      )),\n    [getReferenceLineProps, referenceLineProps],\n  )\n\n  return (\n    <ChartProvider value={{ styles }}>\n      <ui.div\n        ref={ref}\n        className={cx(\"ui-area-chart\", className)}\n        __css={{ maxW: \"full\", vars: areaVars, ...styles.container }}\n        {...rest}\n      >\n        <ResponsiveContainer\n          {...getContainerProps({ className: \"ui-area-chart__container\" })}\n        >\n          <ReChartsAreaChart\n            {...getAreaChartProps({ className: \"ui-area-chart__chart\" })}\n          >\n            <CartesianGrid\n              {...getGridProps({ className: \"ui-area-chart__grid\" })}\n            />\n\n            <XAxis {...getXAxisProps({ className: \"ui-area-chart__x-axis\" })}>\n              <Label\n                {...getXAxisLabelProps({\n                  className: \"ui-area-chart__x-axis-label\",\n                })}\n              />\n            </XAxis>\n\n            <YAxis {...getYAxisProps({ className: \"ui-area-chart__y-axis\" })}>\n              <Label\n                {...getYAxisLabelProps({\n                  className: \"ui-area-chart__y-axis-label\",\n                })}\n              />\n            </YAxis>\n\n            {withLegend ? (\n              <Legend\n                content={({ payload }) => (\n                  <ChartLegend\n                    className=\"ui-area-chart__legend\"\n                    payload={payload}\n                    onHighlight={setHighlightedArea}\n                    {...computedLegendProps}\n                  />\n                )}\n                {...getLegendProps()}\n              />\n            ) : null}\n\n            {withTooltip ? (\n              <Tooltip\n                content={({ label, payload }) => (\n                  <ChartTooltip\n                    className=\"ui-area-chart__tooltip\"\n                    label={label}\n                    labelFormatter={labelFormatter}\n                    payload={payload}\n                    unit={unit}\n                    valueFormatter={valueFormatter}\n                    {...computedTooltipProps}\n                  />\n                )}\n                {...getTooltipProps()}\n              />\n            ) : null}\n\n            {type === \"split\" ? (\n              <defs>\n                <AreaSplit {...getAreaSplitProps()} />\n              </defs>\n            ) : null}\n\n            {areas}\n            {referenceLinesItems}\n          </ReChartsAreaChart>\n        </ResponsiveContainer>\n      </ui.div>\n    </ChartProvider>\n  )\n})\n\nAreaChart.displayName = \"AreaChart\"\nAreaChart.__ui__ = \"AreaChart\"\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAQA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AACP,SAAS,UAAU;AACnB,SAAS,UAAU,eAAe;AAClC;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA,aAAa;AAAA,EACb;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AAgLG,SAEI,KAFJ;AAnIH,IAAM,YAAY,WAAkC,CAAC,OAAO,QAAQ;AACzE,QAAM,CAAC,QAAQ,WAAW,IAAI,uBA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