@@ -15,14 +15,21 @@ import { AxisDomain } from 'recharts/types/util/types';
1515import { remove } from 'lodash' ;
1616
1717import { ChartBaseProps } from '../../types' ;
18- import { defaultValueFormatter , getYAxisDomain , getCategoryColors } from '../../utils' ;
18+ import {
19+ defaultValueFormatter ,
20+ getYAxisDomain ,
21+ getCategoryColors ,
22+ getCategoryMap ,
23+ } from '../../utils' ;
1924import { Legend as LegendContent } from '../../components/Legend' ;
2025import { Tooltip as TooltipContent } from '../../components/Tooltip' ;
2126
2227export interface AreaChartProps extends ChartBaseProps {
2328 stack ?: boolean ;
2429 xAxisProps ?: XAxisProps ;
2530 yAxisProps ?: YAxisProps ;
31+ strokeDasharrays ?: any [ ] ;
32+ fillOpacitys ?: any [ ] ;
2633}
2734
2835export const AreaChart = ( {
@@ -53,12 +60,16 @@ export const AreaChart = ({
5360 maxActiveCategories = 50 ,
5461 xAxisProps = { } ,
5562 yAxisProps = { } ,
63+ strokeDasharrays,
64+ fillOpacitys,
5665 ...rest
5766} : AreaChartProps ) => {
5867 const initialActiveCats = categories . slice ( 0 , maxActiveCategories ) ;
5968 const [ activeCategories , setActiveCategories ] = useState ( initialActiveCats ) ;
6069 const yAxisDomain = getYAxisDomain ( autoMinValue , minValue , maxValue ) ;
6170 const categoryColors = getCategoryColors ( categories , colors ) ;
71+ const categoryStrokeDasharrays = getCategoryMap ( categories , strokeDasharrays ) ;
72+ const categoryFillOpacitys = getCategoryMap ( categories , fillOpacitys ) ;
6273
6374 const handleLegendClick = ( category ) => {
6475 const newActiveCategories = [ ...activeCategories ] ;
@@ -131,16 +142,17 @@ export const AreaChart = ({
131142 { showTooltip ? (
132143 < Tooltip
133144 wrapperStyle = { { outline : 'none' } }
134- content = { ( { active, payload, label } ) => (
135- customTooltip && customTooltip ( payload ) ) || (
136- < TooltipContent
137- active = { active }
138- payload = { payload }
139- label = { label }
140- valueFormatter = { valueFormatter }
141- legendFormatter = { legendFormatter }
142- />
143- ) }
145+ content = { ( { active, payload, label } ) =>
146+ ( customTooltip && customTooltip ( payload ) ) || (
147+ < TooltipContent
148+ active = { active }
149+ payload = { payload }
150+ label = { label }
151+ valueFormatter = { valueFormatter }
152+ legendFormatter = { legendFormatter }
153+ />
154+ )
155+ }
144156 />
145157 ) : null }
146158 { categories . map ( ( category ) => (
@@ -165,6 +177,8 @@ export const AreaChart = ({
165177 dataKey = { category }
166178 stroke = { categoryColors . get ( category ) }
167179 fill = { `url(#${ categoryColors . get ( category ) } )` }
180+ strokeDasharray = { categoryStrokeDasharrays . get ( category ) }
181+ fillOpacity = { categoryFillOpacitys . get ( category ) }
168182 strokeWidth = { 1 }
169183 dot = { false }
170184 isAnimationActive = { showAnimation }
0 commit comments