Skip to content

Commit

Permalink
#14: Remove MUI dependencies from EventClusters
Browse files Browse the repository at this point in the history
  • Loading branch information
netzwerg committed Apr 7, 2022
1 parent 8f6e2a8 commit 1b97d16
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions src/layers/EventClusters.tsx
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import React from 'react'
import { ScaleBand, ScaleLinear, scaleSqrt } from 'd3-scale'
import { Theme } from '@material-ui/core'
import { TimelineEventCluster } from '../model'
import { defaultClusterColor, defaultSingleEventMarkHeight } from '../utils'
import makeStyles from '@material-ui/core/styles/makeStyles'
import { extent } from 'd3-array'
import { useTimelineTheme } from '../theme'

const useStyles = makeStyles((theme: Theme) => ({
clusterCircle: {
stroke: theme.palette.background.paper,
const useCircleStyle = () => {
const theme = useTimelineTheme()
return {
stroke: theme.base.backgroundColor,
strokeWidth: 2,
fillOpacity: 0.5,
},
}))
}
}

interface Props<LID extends string> {
readonly height: number
Expand All @@ -29,7 +29,7 @@ export const EventClusters = <LID extends string>({
expanded,
height,
}: Props<LID>) => {
const classes = useStyles()
const circleStyle = useCircleStyle()

const [clusterSizeDomainMin, clusterSizeDomainMax] = extent(eventClusters.map((c) => c.size))
const clusterRadiusMin = defaultSingleEventMarkHeight / 2
Expand All @@ -47,10 +47,10 @@ export const EventClusters = <LID extends string>({
{eventClusters.map((eventCluster) => (
<g key={`eventCluster-${eventCluster.laneId}-${eventCluster.timeMillis}`}>
<circle
style={circleStyle}
cx={timeScale(eventCluster.timeMillis)}
cy={expanded ? yScale(eventCluster.laneId) : height / 2}
r={clusterScale(eventCluster.size)!}
className={classes.clusterCircle}
fill={eventCluster.color || defaultClusterColor}
/>
</g>
Expand Down

0 comments on commit 1b97d16

Please sign in to comment.