Lumagrid
    Preparing search index...

    Function createNivoPlugin

    • Creates a ChartPlugin backed by a declarative Nivo component. The NivoTheme is derived automatically from the Lumagrid ThemeDefinition.

      Type Parameters

      • TData
      • TConfig = Record<string, unknown>

      Parameters

      Returns ChartPlugin<TData, NivoTheme, TConfig>

      import { ResponsiveBar } from '@nivo/bar';
      import { createNivoPlugin } from 'lumagrid/plugins';

      registerPlugin(createNivoPlugin<{ name: string; value: number }[], { dataKey?: string; nameKey?: string }>({
      id: 'nivo-bar',
      label: 'Bar (Nivo)',
      dataAdapter: (data) => data.rows as { name: string; value: number }[],
      Renderer: ({ data, theme, width, height, config }) => (
      <div style={{ width, height }}>
      <ResponsiveBar
      data={data}
      keys={[config?.dataKey ?? 'value']}
      indexBy={config?.nameKey ?? 'name'}
      theme={theme}
      colors={theme.colors}
      />
      </div>
      ),
      }));