Skip to content

The Open Standard for Generative UI

ScatterChart dot fix (#212)

subham3df32f7e8d33
diff --git a/js/packages/react-ui/package.json b/js/packages/react-ui/package.json
index dced55b9b..b570910d5 100644
--- a/js/packages/react-ui/package.json
+++ b/js/packages/react-ui/package.json
@@ -2,7 +2,7 @@
"type": "module",
"name": "@crayonai/react-ui",
"license": "MIT",
- "version": "0.8.38",
+ "version": "0.8.39",
"description": "Component library for Generative UI SDK",
"main": "dist/index.js",
"types": "dist/index.d.ts",
diff --git a/js/packages/react-ui/src/components/Charts/ScatterChart/ScatterChart.tsx b/js/packages/react-ui/src/components/Charts/ScatterChart/ScatterChart.tsx
index a527d00b2..8dc0ce8ab 100644
--- a/js/packages/react-ui/src/components/Charts/ScatterChart/ScatterChart.tsx
+++ b/js/packages/react-ui/src/components/Charts/ScatterChart/ScatterChart.tsx
@@ -131,11 +131,9 @@ export const ScatterChart = ({
}, [data, yAxisDataKey]);
const renderDotShape = useMemo(() => {
- return (props: unknown) => <ScatterDot {...(props as object)} variant={shape} active={false} />;
- }, [shape]);
-
- const renderActiveDotShape = useMemo(() => {
- return (props: unknown) => <ScatterDot {...(props as object)} variant={shape} active />;
+ return (props: unknown) => {
+ return <ScatterDot {...(props as object)} variant={shape} />;
+ };
}, [shape]);
useEffect(() => {
@@ -315,7 +313,6 @@ export const ScatterChart = ({
key={`scatter-${id}`}
data={transformedData}
shape={renderDotShape}
- activeShape={renderActiveDotShape}
isAnimationActive={isAnimationActive}
>
{transformedData.map((entry, index) => (
diff --git a/js/packages/react-ui/src/components/Charts/ScatterChart/components/ScatterDot.tsx b/js/packages/react-ui/src/components/Charts/ScatterChart/components/ScatterDot.tsx
index a8e3d8300..b7d2bfc61 100644
--- a/js/packages/react-ui/src/components/Charts/ScatterChart/components/ScatterDot.tsx
+++ b/js/packages/react-ui/src/components/Charts/ScatterChart/components/ScatterDot.tsx
@@ -1,4 +1,4 @@
-import React from "react";
+import React, { useState } from "react";
export interface ScatterDotProps {
cx?: number;
@@ -6,16 +6,10 @@ export interface ScatterDotProps {
fill?: string;
radius?: number;
variant?: "circle" | "square";
- active?: boolean;
}
-const ScatterDot: React.FC<ScatterDotProps> = ({
- cx,
- cy,
- fill,
- variant = "circle",
- active = false,
-}) => {
+const ScatterDot: React.FC<ScatterDotProps> = ({ cx, cy, fill, variant = "circle" }) => {
+ const [active, setActive] = useState(false);
if (typeof cx !== "number" || typeof cy !== "number") {
return null;
}
@@ -38,6 +32,12 @@ const ScatterDot: React.FC<ScatterDotProps> = ({
strokeLinejoin="round"
vectorEffect="non-scaling-stroke"
rx={2}
+ onPointerEnter={() => {
+ setActive(true);
+ }}
+ onPointerLeave={() => {
+ setActive(false);
+ }}
/>
);
}
@@ -51,6 +51,12 @@ const ScatterDot: React.FC<ScatterDotProps> = ({
stroke={active ? OUTLINE_COLOR : "none"}
strokeWidth={OUTLINE_WIDTH}
vectorEffect="non-scaling-stroke"
+ onPointerEnter={() => {
+ setActive(true);
+ }}
+ onPointerLeave={() => {
+ setActive(false);
+ }}
/>
);
};