How to use the @nivo/core.getLabelGenerator function in @nivo/core

To help you get started, we’ve selected a few @nivo/core 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 / sankey / src / enhance.js View on Github external
withPropsOnChange(['label', 'labelFormat'], ({ label, labelFormat }) => ({
            getLabel: getLabelGenerator(label, labelFormat),
        })),
        withPropsOnChange(['sort'], ({ sort }) => {
github plouc / nivo / packages / bar / src / enhance.js View on Github external
withPropsOnChange(['label', 'labelFormat'], ({ label, labelFormat }) => ({
            getLabel: getLabelGenerator(label, labelFormat),
        })),
        withPropsOnChange(['borderColor', 'theme'], ({ borderColor, theme }) => ({
github plouc / nivo / packages / pie / src / PieCanvasRenderer.js View on Github external
if (enableRadialLabels === true) {
            const {
                radialLabel,
                radialLabelsSkipAngle,
                radialLabelsLinkOffset,
                radialLabelsLinkStrokeWidth,
                radialLabelsLinkDiagonalLength,
                radialLabelsLinkHorizontalLength,
                radialLabelsTextXOffset,
                radialLabelsTextColor,
                radialLabelsLinkColor,
            } = props

            drawRadialLabels(this.ctx, arcs, {
                radius,
                getLabel: getLabelGenerator(radialLabel),
                skipAngle: radialLabelsSkipAngle,
                linkOffset: radialLabelsLinkOffset,
                linkDiagonalLength: radialLabelsLinkDiagonalLength,
                linkHorizontalLength: radialLabelsLinkHorizontalLength,
                linkStrokeWidth: radialLabelsLinkStrokeWidth,
                textXOffset: radialLabelsTextXOffset,
                getTextColor: getInheritedColorGenerator(radialLabelsTextColor, theme),
                getLinkColor: getInheritedColorGenerator(radialLabelsLinkColor, theme),
                theme,
            })
        }

        this.ctx.restore()

        legends.forEach(legend => {
            renderLegendToCanvas(this.ctx, {
github plouc / nivo / packages / radar / src / RadarDots.js View on Github external
symbol,
    size,
    color,
    borderWidth,
    borderColor,

    enableLabel,
    label,
    labelFormat,
    labelYOffset,
}) => {
    const theme = useTheme()
    const { animate, springConfig } = useMotionConfig()
    const fillColor = getInheritedColorGenerator(color, theme)
    const strokeColor = getInheritedColorGenerator(borderColor, theme)
    const getLabel = getLabelGenerator(label, labelFormat)

    const points = data.reduce((acc, datum, i) => {
        const index = getIndex(datum)
        keys.forEach(key => {
            const pointData = {
                index,
                key,
                value: datum[key],
                color: colorByKey[key],
            }
            acc.push({
                key: `${key}.${index}`,
                label: enableLabel ? getLabel(pointData) : null,
                style: {
                    fill: fillColor(pointData),
                    stroke: strokeColor(pointData),
github plouc / nivo / packages / pie / src / PieCanvasRenderer.js View on Github external
this.ctx.beginPath()
            this.ctx.fillStyle = arc.color
            this.ctx.strokeStyle = getBorderColor({ ...arc.data, color: arc.color })
            this.ctx.lineWidth = borderWidth
            arcGenerator(arc)
            this.ctx.fill()
            if (borderWidth > 0) this.ctx.stroke()
        })

        if (enableSlicesLabels === true) {
            const { sliceLabel, slicesLabelsSkipAngle, slicesLabelsTextColor } = props

            drawSliceLabels(this.ctx, arcs, {
                arcGenerator,
                skipAngle: slicesLabelsSkipAngle,
                getLabel: getLabelGenerator(sliceLabel),
                getTextColor: getInheritedColorGenerator(slicesLabelsTextColor, theme),
                theme,
            })
        }

        if (enableRadialLabels === true) {
            const {
                radialLabel,
                radialLabelsSkipAngle,
                radialLabelsLinkOffset,
                radialLabelsLinkStrokeWidth,
                radialLabelsLinkDiagonalLength,
                radialLabelsLinkHorizontalLength,
                radialLabelsTextXOffset,
                radialLabelsTextColor,
                radialLabelsLinkColor,
github plouc / nivo / packages / pie / src / Pie.js View on Github external
withPropsOnChange(['sliceLabel'], ({ sliceLabel }) => ({
            getSliceLabel: getLabelGenerator(sliceLabel),
        })),
        pure