File size: 1,899 Bytes
1e92f2d | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 | import { CssMixBlendMode } from '@nivo/core'
import { Node } from './Node'
import { Tooltip } from './Tooltip'
import {
ScatterPlotCommonProps,
ScatterPlotDatum,
ScatterPlotLayerId,
ScatterPlotNodeData,
} from './types'
export const commonDefaultProps = {
xScale: {
type: 'linear',
min: 0,
max: 'auto',
} as ScatterPlotCommonProps<ScatterPlotDatum>['xScale'],
yScale: {
type: 'linear',
min: 0,
max: 'auto',
} as ScatterPlotCommonProps<ScatterPlotDatum>['yScale'],
enableGridX: true,
enableGridY: true,
axisTop: null,
axisRight: null,
axisBottom: {},
axisLeft: {},
nodeId: (({ serieId, index }) =>
`${serieId}.${index}`) as ScatterPlotCommonProps<ScatterPlotDatum>['nodeId'],
nodeSize: 9,
nodeComponent: Node,
colors: { scheme: 'nivo' } as ScatterPlotCommonProps<ScatterPlotDatum>['colors'],
isInteractive: true,
debugMesh: false,
tooltip: Tooltip,
markers: [],
legends: [],
annotations: [],
}
export const svgDefaultProps = {
...commonDefaultProps,
blendMode: 'normal' as CssMixBlendMode,
layers: [
'grid',
'axes',
'nodes',
'markers',
'mesh',
'legends',
'annotations',
] as ScatterPlotLayerId[],
role: 'img',
useMesh: true,
animate: true,
motionConfig: 'default',
}
export const canvasDefaultProps = {
...commonDefaultProps,
layers: ['grid', 'axes', 'nodes', 'mesh', 'legends', 'annotations'] as ScatterPlotLayerId[],
pixelRatio: typeof window !== 'undefined' ? window.devicePixelRatio || 1 : 1,
renderNode: (ctx: CanvasRenderingContext2D, node: ScatterPlotNodeData<ScatterPlotDatum>) => {
ctx.beginPath()
ctx.arc(node.x, node.y, node.size / 2, 0, 2 * Math.PI)
ctx.fillStyle = node.color
ctx.fill()
},
}
|