File tree Expand file tree Collapse file tree 1 file changed +5
-7
lines changed
apps/webapp/app/components/primitives/charts Expand file tree Collapse file tree 1 file changed +5
-7
lines changed Original file line number Diff line number Diff line change @@ -191,16 +191,14 @@ export function useHasNoData(): boolean {
191191 * Useful for legend displays.
192192 */
193193export function useSeriesTotal ( ) : Record < string , number > {
194- const { data, dataKey } = useChartContext ( ) ;
194+ const { data, dataKeys } = useChartContext ( ) ;
195195
196196 return useMemo ( ( ) => {
197197 return data . reduce ( ( acc , item ) => {
198- Object . entries ( item ) . forEach ( ( [ key , value ] ) => {
199- if ( key !== dataKey ) {
200- acc [ key ] = ( acc [ key ] || 0 ) + ( Number ( value ) || 0 ) ;
201- }
202- } ) ;
198+ for ( const seriesKey of dataKeys ) {
199+ acc [ seriesKey ] = ( acc [ seriesKey ] || 0 ) + Number ( item [ seriesKey ] || 0 ) ;
200+ }
203201 return acc ;
204202 } , { } as Record < string , number > ) ;
205- } , [ data , dataKey ] ) ;
203+ } , [ data , dataKeys ] ) ;
206204}
You can’t perform that action at this time.
0 commit comments