Recharts: Could Cell component be child of Scatter?

Created on 5 Oct 2017  路  1Comment  路  Source: recharts/recharts

I want to use different color for each data point in Scatter component, like using different color for each slice in Pie component.

I tested Cell child in Scatter component but it doesn't work. I also read Scatter.js source and it seems this component find all Cell children. Would you please help me to draw scatter diagram with colorful points?

Most helpful comment

@alishir Yeah, It's supported now.

        <ScatterChart width={400} height={400} margin={{ top: 20, right: 20, bottom: 0, left: 20 }}>
            <XAxis type="number" dataKey="x" name="stature" unit="cm" />
            <YAxis type="number" dataKey="y" name="weight" unit="kg" />
            <CartesianGrid />
            <Tooltip />
            <Legend/>
            <Scatter name="A school" data={data01} fill="#ff7300">
              {
                data01.map((entry, index) => {
                  return <Cell key={`cell-${index}`} fill={colors[index % colors.length]} />
                })
              }
            </Scatter>
          </ScatterChart>

>All comments

@alishir Yeah, It's supported now.

        <ScatterChart width={400} height={400} margin={{ top: 20, right: 20, bottom: 0, left: 20 }}>
            <XAxis type="number" dataKey="x" name="stature" unit="cm" />
            <YAxis type="number" dataKey="y" name="weight" unit="kg" />
            <CartesianGrid />
            <Tooltip />
            <Legend/>
            <Scatter name="A school" data={data01} fill="#ff7300">
              {
                data01.map((entry, index) => {
                  return <Cell key={`cell-${index}`} fill={colors[index % colors.length]} />
                })
              }
            </Scatter>
          </ScatterChart>
Was this page helpful?
0 / 5 - 0 ratings

Related issues

scottdickerson picture scottdickerson  路  3Comments

alexandersoto picture alexandersoto  路  3Comments

patientplatypus picture patientplatypus  路  3Comments

alexliu-github picture alexliu-github  路  3Comments

patrick-lewandowski picture patrick-lewandowski  路  3Comments