This is a stack area chart in react : // StackedLongShortAreaChart.js import React from…
- User
This is a stack area chart in react : // StackedLongShortAreaChart.js import React from 'react'; import { AreaChart, Area, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, Legend, } from 'recharts';
const StackedLongShortAreaChart = ({ data }) => {
// Get list of countries from color map const COUNTRY_COLORS = { France: '#04068a', Italy: '#45a61c', Germany: "#968082", Spain: '#9c0303', UK: '#ebb7bf', Netherlands: '#f29141', Austria: '#b852eb', Ireland: '#cbed5c', Portugal: '#db4dc1', Finland: '#8edbe6', Norway: '#5792ff', US : '#ffc400' };
const countries = Object.keys(COUNTRY_COLORS); const allKeys = Object.keys(data[0] || {});
return ( <AreaChart data={data} margin={{ top: 20, right: 30, left: 20, bottom: 20 }} > {countries.map((country) => ( <linearGradient key={country} id={
color_${country}} x1="0" y1="0" x2="0" y2="1"> ))}code<CartesianGrid strokeDasharray="3 3" /> <XAxis dataKey="date" /> <YAxis /> <Tooltip /> <Legend /> {countries.map((country) => ( <Area key={`${country}_long`} type="monotone" dataKey={`${country}_long`} stackId="long" stroke={COUNTRY_COLORS[country]} fill={`url(#color_${country})`} name={`${country} Long`} isAnimationActive={false} /> ))} {countries.map((country) => ( <Area key={`${country}_short`} type="monotone" dataKey={`${country}_short`} stackId="short" stroke={COUNTRY_COLORS[country]} fill={`url(#color_${country})`} name={`${country} Short`} isAnimationActive={false} /> ))} </AreaChart> </ResponsiveContainer>); };
export default StackedLongShortAreaChart; But there are things I don't like. I don't want to have variable opacity, I want a much cleaner legend, I want much cleaner hoveron information. Please prefer a compact display of the style Country : Long _qty| Short_qty.
- Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.