Skip to content

Commit

Permalink
fix(scatterplot): fix canvas missing annotations layer (plouc#1043)
Browse files Browse the repository at this point in the history
  • Loading branch information
wyze authored Jul 3, 2020
1 parent f87be93 commit d2ceffc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion packages/scatterplot/src/ScatterPlotCanvas.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,13 @@ import {
getRelativeCursor,
isCursorInRect,
} from '@nivo/core'
import { renderAnnotationsToCanvas } from '@nivo/annotations'
import { renderAxesToCanvas, renderGridLinesToCanvas } from '@nivo/axes'
import { renderLegendToCanvas } from '@nivo/legends'
import { useTooltip } from '@nivo/tooltip'
import { useVoronoiMesh, renderVoronoiToCanvas, renderVoronoiCellToCanvas } from '@nivo/voronoi'
import { ScatterPlotCanvasPropTypes, ScatterPlotCanvasDefaultProps } from './props'
import { useScatterPlot } from './hooks'
import { useScatterPlot, useScatterPlotAnnotations } from './hooks'

const ScatterPlotCanvas = props => {
const {
Expand Down Expand Up @@ -50,6 +51,8 @@ const ScatterPlotCanvas = props => {
axisBottom,
axisLeft,

annotations,

isInteractive,
debugMesh,
onMouseEnter,
Expand Down Expand Up @@ -83,6 +86,8 @@ const ScatterPlotCanvas = props => {
colors,
})

const boundAnnotations = useScatterPlotAnnotations(nodes, annotations)

const { delaunay, voronoi } = useVoronoiMesh({
points: nodes,
width: innerWidth,
Expand Down Expand Up @@ -139,6 +144,8 @@ const ScatterPlotCanvas = props => {
axis: 'y',
values: gridYValues,
})
} else if (layer === 'annotations') {
renderAnnotationsToCanvas(ctx, { annotations: boundAnnotations, theme })
} else if (layer === 'axes') {
renderAxesToCanvas(ctx, {
xScale,
Expand Down

0 comments on commit d2ceffc

Please sign in to comment.