So I have two json files, one that contains all objects i have a line to plot:
import { bairro1, bairro2, bairro3 } from "../Data/dataBairros"
export const listaBairros = [
{ value: bairro1, label: "bairro1" },
{ value: bairro2, label: "bairro2" },
{ value: bairro3, label: "bairro3" }
and onde with the dataset that will go to the graphs from each object:
export const bairro1 = [
{ month: 'Jan', sales: 900 }, { month: 'Fev', sales: 1220},
{ month: 'Mar', sales: 1400 }, { month: 'Abr', sales: 3153 },
{ month: 'Mai', sales: 1321 }, { month: 'Jun', sales: 3132 },
{ month: 'Jul', sales: 1323 }, { month: 'Ago', sales: 2154 },
{ month: 'Set', sales: 1231 }, { month: 'Out', sales: 1212 },
{ month: 'Nov', sales: 1212 }, { month: 'Dez', sales: 1300 }
]
export const bairro2 = [
{ month: 'Jan', sales: 3526 }, { month: 'Fev', sales: 1120 },
{ month: 'Mar', sales: 1231 }, { month: 'Abr', sales: 3143 },
{ month: 'Mai', sales: 1121 }, { month: 'Jun', sales: 2312 },
{ month: 'Jul', sales: 1213 }, { month: 'Ago', sales: 2544 },
{ month: 'Set', sales: 1151 }, { month: 'Out', sales: 1142 },
{ month: 'Nov', sales: 1142 }, { month: 'Dez', sales: 1312 }
]
export const bairro3 = [
{ month: 'Jan', sales: 1900 }, { month: 'Fev', sales: 1112},
{ month: 'Mar', sales: 1451 }, { month: 'Abr', sales: 3123 },
{ month: 'Mai', sales: 1591 }, { month: 'Jun', sales: 3322 },
{ month: 'Jul', sales: 1215 }, { month: 'Ago', sales: 2524 },
{ month: 'Set', sales: 2231 }, { month: 'Out', sales: 1444 },
{ month: 'Nov', sales: 2212 }, { month: 'Dez', sales: 1130 }
]
On a jsx file i make a selection of all the objects i want plotted at the same time
const [selectedList, setSelected] = useState ([]);
<Multiselect
options={listaBairros}
value={selectedList}
displayValue="label"
onChange={setSelected}
/>
But, from now on I simple don't know how to take the list of objetcs selected and plot a Line for each of those objects
I'm trying to use ChartComponent library (https://ej2.syncfusion.com/react/documentation/chart/getting-started/) However, i have to manually write a Line Series for each object instead of only the ones selected:
<ChartComponent primaryXAxis={{valueType:"Category"}}>
<Inject services={[LineSeries, Category]}/>
<SeriesCollectionDirective>
<SeriesDirective type="Line" dataSource ={bairro1} xName="month" yName="sales"/>
<SeriesDirective type="Line" dataSource ={bairro2} xName="month" yName="sales"/>
<SeriesDirective type="Line" dataSource ={bairro3} xName="month" yName="sales"/>
</SeriesCollectionDirective>
</ChartComponent>
Please somone, I've been trying to do this for really long!!