Hi all,
I’m trying to set up a Recharts radar chart component (example in CodeSandbox) in a Plasmic project. (Thank you @mr_biscuit for sharing the concept!)
So far, I’ve added the radar components in my repo and then registered them in Plasmic.
/components/recharts/PolarAngleAxisWrapper.jsx
import React from 'react';
import { PolarAngleAxis } from 'recharts';
const PolarAngleAxisWrapper = ({ dataKey }) => <PolarAngleAxis dataKey={dataKey} />;
export default PolarAngleAxisWrapper;
/components/recharts/PolarGrideWrapper.jsx
import React from 'react';
import { PolarGrid } from 'recharts';
const PolarGridWrapper = () => <PolarGrid />;
export default PolarGridWrapper;
/components/recharts/PolarRadiusAxisWrapper.jsx
import React from 'react';
import { PolarRadiusAxis } from 'recharts';
const PolarRadiusAxisWrapper = () => <PolarRadiusAxis />;
export default PolarRadiusAxisWrapper;
/components/recharts/RadarChartWrapper.jsx
import React from 'react';
import { RadarChart } from 'recharts';
const RadarChartWrapper = ({ width, height, data, children }) => (
<RadarChart width={width} height={height} data={data}>
{children}
</RadarChart>
);
export default RadarChartWrapper;
/components/recharts/RadarWrapper.jsx
import React from 'react';
import { Radar } from 'recharts';
const RadarWrapper = ({ name, dataKey, stroke, fill }) => (
<Radar name={name} dataKey={dataKey} stroke={stroke} fill={fill} fillOpacity={0.6} />
);
export default RadarWrapper;
/plasmic-init.ts
...
import PolarAngleAxisWrapper from './components/recharts/PolarAngleAxisWrapper';
import PolarGridWrapper from './components/recharts/PolarGridWrapper';
import PolarRadiusAxisWrapper from './components/recharts/PolarRadiusAxisWrapper';
import RadarChartWrapper from './components/recharts/RadarChartWrapper';
import RadarWrapper from './components/recharts/RadarWrapper';
PLASMIC.registerComponent(PolarAngleAxisWrapper, {
name: 'PolarAngleAxis',
props: {
dataKey: 'string',
},
});
PLASMIC.registerComponent(PolarGridWrapper, {
name: 'PolarGrid',
props: {},
});
PLASMIC.registerComponent(PolarRadiusAxisWrapper, {
name: 'PolarRadiusAxis',
props: {},
});
PLASMIC.registerComponent(RadarChartWrapper, {
name: 'RadarChart',
props: {
width: 'number',
height: 'number',
data: 'object',
children: 'slot',
},
defaultStyles: {
width: '100%',
height: '500px',
},
});
PLASMIC.registerComponent(RadarWrapper, {
name: 'Radar',
props: {
name: 'string',
dataKey: 'string',
stroke: 'string',
fill: 'string',
},
});
However, I can’t get the added component to show anything…
Is my error related to the component set up? Or am I missing something in Plasmic?
(nothing shows using the example data)
My project: Plasmic