Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ const calculateDomain = (data: ExtendedDataPoint[]) => [
export const SpiderChart = ({
data,
radars,
band = 30,
tickBand = 5,
scale = 1,
outerRadius = 90,
Expand Down Expand Up @@ -78,6 +77,9 @@ export const SpiderChart = ({
);
});

const angleStep = 360 / data.length;
const computedAngleOffset = 90 % angleStep;

return (
<StyledRadarChart onClick={handleClick}>
<ResponsiveContainer width="100%" height="100%">
Expand All @@ -95,7 +97,7 @@ export const SpiderChart = ({
data={[{ subject: "1" }]}
polarAngles={Array(data.length)
.fill(0)
.map((_, i) => i * (360 / data.length) + tickBand)}
.map((_, i) => i * angleStep + tickBand)}
/>
<Customized
component={CustomPolarGrid}
Expand All @@ -107,7 +109,7 @@ export const SpiderChart = ({
scale={scale}
polarAngles={Array(data.length)
.fill(0)
.map((_, i) => i * (360 / data.length) + band)}
.map((_, i) => i * angleStep + computedAngleOffset)}
/>
<Customized
component={CustomLines}
Expand All @@ -120,7 +122,7 @@ export const SpiderChart = ({
outerRadius={1}
polarAngles={Array(data.length)
.fill(0)
.map((_, i) => i * (360 / data.length) + band)}
.map((_, i) => i * angleStep + computedAngleOffset)}
/>

{radars.map((radar, index) => (
Expand Down
5 changes: 4 additions & 1 deletion packages/open-ui-kit/src/charts/spider-chart/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,7 @@
*/

export { SpiderChart } from "./components/spider-chart";
export type { SpiderChartProps } from "./types/spider-chart.types";
export type {
SpiderChartProps,
ExtendedDataPoint,
} from "./types/spider-chart.types";
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,6 @@ const meta: Meta<typeof SpiderChart> = {
outerRadius: {
description: "The outer radius of the chart.",
},
band: {
description: "The outer radius of the chart",
},
onTooltipClick: {
description: "Callback to call on tooltip click",
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export type SpiderChartProps = {
radars: RadarType[];
outerRadius?: number;
padData?: number;
band?: number;
onTooltipClick?: (subject: string) => void;
tooltipContent?: (dataPoint: ExtendedDataPoint) => React.ReactNode;
showTooltip?: boolean;
Expand Down