How to use @nivo/voronoi - 10 common examples

To help you get started, we’ve selected a few @nivo/voronoi examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github plouc / nivo / packages / line / src / LineCanvas.js View on Github external
ctx.beginPath()
                    ctx.arc(point.x, point.y, pointSize / 2, 0, 2 * Math.PI)
                    ctx.fill()

                    if (pointBorderWidth > 0) {
                        ctx.strokeStyle = point.borderColor
                        ctx.lineWidth = pointBorderWidth
                        ctx.stroke()
                    }
                })
            }

            if (layer === 'mesh' && debugMesh === true) {
                renderVoronoiToCanvas(ctx, voronoi)
                if (currentPoint) {
                    renderVoronoiCellToCanvas(ctx, voronoi, currentPoint.index)
                }
            }

            if (layer === 'legends') {
                const legendData = series
                    .map(serie => ({
                        id: serie.id,
                        label: serie.id,
                        color: serie.color,
                    }))
                    .reverse()

                legends.forEach(legend => {
                    renderLegendToCanvas(ctx, {
                        ...legend,
                        data: legend.data || legendData,
github plouc / nivo / packages / swarmplot / src / SwarmPlotCanvas.js View on Github external
}

                if (layer === 'nodes') {
                    nodes.forEach(node => {
                        renderNode(ctx, {
                            node,
                            getBorderWidth,
                            getBorderColor,
                        })
                    })
                }

                if (layer === 'mesh' && debugMesh === true) {
                    renderVoronoiToCanvas(ctx, voronoi)
                    if (currentNode) {
                        renderVoronoiCellToCanvas(ctx, voronoi, currentNode.index)
                    }
                }

                if (layer === 'annotations') {
                    renderAnnotationsToCanvas(ctx, {
                        annotations: computedAnnotations,
                        theme,
                    })
                }

                if (typeof layer === 'function') {
                    layer(ctx, {
                        nodes,
                        innerWidth,
                        innerHeight,
                        outerWidth,
github plouc / nivo / packages / scatterplot / src / ScatterPlotCanvas.js View on Github external
height: innerHeight,
                    top: axisTop,
                    right: axisRight,
                    bottom: axisBottom,
                    left: axisLeft,
                    theme,
                })
            } else if (layer === 'nodes') {
                nodes.forEach(node => {
                    renderNode(ctx, node)
                })
            } else if (layer === 'mesh') {
                if (debugMesh === true) {
                    renderVoronoiToCanvas(ctx, voronoi)
                    if (currentNode) {
                        renderVoronoiCellToCanvas(ctx, voronoi, currentNode.index)
                    }
                }
            } else if (layer === 'legends') {
                legends.forEach(legend => {
                    renderLegendToCanvas(ctx, {
                        ...legend,
                        data: legendData,
                        containerWidth: innerWidth,
                        containerHeight: innerHeight,
                        theme,
                    })
                })
            } else if (typeof layer === 'function') {
                layer(ctx, customLayerProps)
            } else {
                throw new Error(`Invalid layer: ${layer}`)
github plouc / nivo / packages / line / src / LineCanvas.js View on Github external
points.forEach(point => {
                    ctx.fillStyle = point.color
                    ctx.beginPath()
                    ctx.arc(point.x, point.y, pointSize / 2, 0, 2 * Math.PI)
                    ctx.fill()

                    if (pointBorderWidth > 0) {
                        ctx.strokeStyle = point.borderColor
                        ctx.lineWidth = pointBorderWidth
                        ctx.stroke()
                    }
                })
            }

            if (layer === 'mesh' && debugMesh === true) {
                renderVoronoiToCanvas(ctx, voronoi)
                if (currentPoint) {
                    renderVoronoiCellToCanvas(ctx, voronoi, currentPoint.index)
                }
            }

            if (layer === 'legends') {
                const legendData = series
                    .map(serie => ({
                        id: serie.id,
                        label: serie.id,
                        color: serie.color,
                    }))
                    .reverse()

                legends.forEach(legend => {
                    renderLegendToCanvas(ctx, {
github plouc / nivo / packages / swarmplot / src / SwarmPlotCanvas.js View on Github external
theme,
                    })
                }

                if (layer === 'nodes') {
                    nodes.forEach(node => {
                        renderNode(ctx, {
                            node,
                            getBorderWidth,
                            getBorderColor,
                        })
                    })
                }

                if (layer === 'mesh' && debugMesh === true) {
                    renderVoronoiToCanvas(ctx, voronoi)
                    if (currentNode) {
                        renderVoronoiCellToCanvas(ctx, voronoi, currentNode.index)
                    }
                }

                if (layer === 'annotations') {
                    renderAnnotationsToCanvas(ctx, {
                        annotations: computedAnnotations,
                        theme,
                    })
                }

                if (typeof layer === 'function') {
                    layer(ctx, {
                        nodes,
                        innerWidth,
github plouc / nivo / packages / scatterplot / src / ScatterPlotCanvas.js View on Github external
yScale,
                    width: innerWidth,
                    height: innerHeight,
                    top: axisTop,
                    right: axisRight,
                    bottom: axisBottom,
                    left: axisLeft,
                    theme,
                })
            } else if (layer === 'nodes') {
                nodes.forEach(node => {
                    renderNode(ctx, node)
                })
            } else if (layer === 'mesh') {
                if (debugMesh === true) {
                    renderVoronoiToCanvas(ctx, voronoi)
                    if (currentNode) {
                        renderVoronoiCellToCanvas(ctx, voronoi, currentNode.index)
                    }
                }
            } else if (layer === 'legends') {
                legends.forEach(legend => {
                    renderLegendToCanvas(ctx, {
                        ...legend,
                        data: legendData,
                        containerWidth: innerWidth,
                        containerHeight: innerHeight,
                        theme,
                    })
                })
            } else if (typeof layer === 'function') {
                layer(ctx, customLayerProps)
github plouc / nivo / website / src / data / components / voronoi / props.js View on Github external
},
    {
        key: 'cellLineWidth',
        help: 'Border width for cells.',
        type: 'number',
        required: false,
        defaultValue: defaults.cellLineWidth,
        controlType: 'lineWidth',
        group: 'Cells',
    },
    {
        key: 'cellLineColor',
        help: 'Border color for cells.',
        type: 'string',
        required: false,
        defaultValue: defaults.cellLineColor,
        controlType: 'colorPicker',
        group: 'Cells',
    },
    {
        key: 'enablePoints',
        help: 'Enable/disable points.',
        type: 'boolean',
        required: false,
        defaultValue: defaults.enablePoints,
        controlType: 'switch',
        group: 'Points',
    },
    {
        key: 'pointSize',
        help: 'Size of points.',
        type: 'number',
github plouc / nivo / website / src / components / charts / voronoi / props.js View on Github external
default: defaults.cellLineWidth,
        controlType: 'range',
        controlGroup: 'Cells',
        controlOptions: {
            unit: 'px',
            min: 0,
            max: 12,
            step: 1,
        },
    },
    {
        key: 'cellLineColor',
        description: 'Border color for cells.',
        type: '{string}',
        required: false,
        default: defaults.cellLineColor,
        controlType: 'colorPicker',
        controlGroup: 'Cells',
    },
    {
        key: 'enablePoints',
        scopes: '*',
        description: 'Enable/disable points.',
        type: '{boolean}',
        required: false,
        default: defaults.enablePoints,
        controlType: 'switch',
        controlGroup: 'Points',
    },
    {
        key: 'pointSize',
        description: 'Size of points (px).',
github plouc / nivo / website / src / components / charts / voronoi / props.js View on Github external
{
        key: 'enableCells',
        scopes: '*',
        description: 'Enable/disable cells.',
        type: '{boolean}',
        required: false,
        default: defaults.enableCells,
        controlType: 'switch',
        controlGroup: 'Cells',
    },
    {
        key: 'cellLineWidth',
        description: 'Border width for cells (px).',
        type: '{number}',
        required: false,
        default: defaults.cellLineWidth,
        controlType: 'range',
        controlGroup: 'Cells',
        controlOptions: {
            unit: 'px',
            min: 0,
            max: 12,
            step: 1,
        },
    },
    {
        key: 'cellLineColor',
        description: 'Border color for cells.',
        type: '{string}',
        required: false,
        default: defaults.cellLineColor,
        controlType: 'colorPicker',
github plouc / nivo / website / src / data / components / voronoi / props.js View on Github external
},
    {
        key: 'enableCells',
        help: 'Enable/disable cells.',
        type: 'boolean',
        required: false,
        defaultValue: defaults.enableCells,
        controlType: 'switch',
        group: 'Cells',
    },
    {
        key: 'cellLineWidth',
        help: 'Border width for cells.',
        type: 'number',
        required: false,
        defaultValue: defaults.cellLineWidth,
        controlType: 'lineWidth',
        group: 'Cells',
    },
    {
        key: 'cellLineColor',
        help: 'Border color for cells.',
        type: 'string',
        required: false,
        defaultValue: defaults.cellLineColor,
        controlType: 'colorPicker',
        group: 'Cells',
    },
    {
        key: 'enablePoints',
        help: 'Enable/disable points.',
        type: 'boolean',