Home > Mobile >  Adding new chart types to react pivottable
Adding new chart types to react pivottable

Time:12-02

I'm wondering if it's possible to add new type of charts, like a radar chart, to the React library plotly/react-pivottable https://github.com/plotly/react-pivottable.

I would like to add a spider chart, always from the chart library plotly, but I can't understand where to start as the documentation is a litle poor and the GitHub repo is quite silence...

Maybe it's not even possible.

Does anyone know if it's possible?

CodePudding user response:

Yes, it is possible to add new types of charts to the React Pivottable library, including a radar chart. The React Pivottable library is built on top of the Pivottable library, which is a powerful data-aggregation tool that can generate a variety of different charts and visualizations. It uses the Plotly library to render the charts, so you can use any of the chart types supported by Plotly in React Pivottable, including the radar chart.

To add a new chart type, such as a radar chart, to React Pivottable, you can use the addRenderer method of the pivottable object. This method takes two arguments: the name of the new chart type, and a function that generates the chart using the Plotly library.

Here's an example of how you could use the addRenderer method to add a radar chart to React Pivottable:

import { pivottable } from 'react-pivottable';
import Plotly from 'plotly.js-basic-dist';

// Define a function that generates a radar chart using the
// data and configuration provided by the Pivottable library
const radarChartRenderer = (pivotData, opts) => {
  // Use the Plotly library to generate the chart
  const chartData = [{
    type: 'scatterpolar',
    r: pivotData.map(d => d.value),
    theta: pivotData
  • Related