Skip to content

Commit

Permalink
cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
nofurtherinformation committed Jul 31, 2024
1 parent 618d8aa commit 5d5c664
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 7 deletions.
2 changes: 1 addition & 1 deletion components/MapTooltip/MapTooltip.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ export const MapTooltipInner: React.FC<
<h3 key={i}>{section.section}</h3>
<ul className="list-none">
{section.columns.map((column, j) => (
<li key={`store-ttooltip-${i}-${j}`} className="p-0 my-1 text-xs">
<li key={`store-ttooltip-${i}-${j}`} className="my-1 p-0 text-xs">
<b>{column.label}</b>: {column.data}
</li>
))}
Expand Down
28 changes: 22 additions & 6 deletions components/ScatterPlot/ScaterplotStatefulWrapper.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,33 @@ import { globals } from "utils/state/globals"
import { store, useAppSelector } from "utils/state/store"
import ScatterPlot from "./ScatterPlot"
import { ScatterPlotWrapperProps } from "./types"
// import HeatmapComponent from "components/Heatmap/Heatmap"

const getDefaultKeys = () => {
const allKeys = Object.keys(columnsDict)
const cleanKeys = []
for (const key of allKeys) {
// @ts-ignore
if (!Array.isArray(columnsDict[key].column)) {
cleanKeys.push(key)
} else {
console.log("Skipping key !!!!", key)
}
}

return cleanKeys
}

const ScatterPlotWrapper: React.FC<ScatterPlotWrapperProps> = ({
id,
options = Object.keys(columnsDict),
options = getDefaultKeys(),
initialXVar,
initialYVar,
}) => {
const { parentRef } = useParentSize()
const [xVar, setXVar] = useState<DataColumns>(initialXVar! || options?.[0]! || Object.keys(columnsDict)[0])
const [yVar, setYVar] = useState<DataColumns>(initialYVar! || options?.[1]! || Object.keys(columnsDict)[1])
const cleanOptions = options.filter((f) => f in columnsDict && !columnsDict[f as keyof typeof columnsDict].bivariate)

const [xVar, setXVar] = useState<DataColumns>(initialXVar! || cleanOptions?.[0]! || Object.keys(columnsDict)[0])
const [yVar, setYVar] = useState<DataColumns>(initialYVar! || cleanOptions?.[1]! || Object.keys(columnsDict)[1])
const [data, setData] = useState<Record<string, any>[]>([])
// const [heatmapData, setHeatmapData] = useState<any>(null)
const handleXChange = (value: DataColumns) => setXVar(value)
Expand Down Expand Up @@ -53,7 +69,7 @@ const ScatterPlotWrapper: React.FC<ScatterPlotWrapperProps> = ({
<div className="flex flex-row items-center gap-4 border-2 border-r-0 pl-4">
<p>X Variable</p>
<SelectMenu title="Choose X Variable" value={xVar} onValueChange={handleXChange}>
{options.map((key, i) => (
{cleanOptions.map((key, i) => (
<Select.Item key={i} value={key}>
<Select.ItemText>{key}</Select.ItemText>
</Select.Item>
Expand All @@ -63,7 +79,7 @@ const ScatterPlotWrapper: React.FC<ScatterPlotWrapperProps> = ({
<div className="flex flex-row items-center gap-4 border-2 pl-4">
<p>Y Variable</p>
<SelectMenu title="Choose Y Variable" value={yVar} onValueChange={handleYChange}>
{options.map((key, i) => (
{cleanOptions.map((key, i) => (
<Select.Item key={i} value={key}>
<Select.ItemText>{key}</Select.ItemText>
</Select.Item>
Expand Down

0 comments on commit 5d5c664

Please sign in to comment.