Skip to main content

LineChartRenderer

Reference​

  • LineChartRenderer draws a line chart with Plotly. The chart library is loaded only when the chart is first shown, and a spinner is displayed meanwhile.
  • Each item in data is one series (a Plotly trace). The component sets the trace type to scatter and the mode for every series.

Props​

  1. data

    • Type: Array<{ name, x, y, ... }>
    • Default: []
    • Description: One object per series. Any other Plotly trace field (for example line, marker, hovertemplate) is passed through.
  2. mode

    • Type: string
    • Default: 'lines'
    • Description: The Plotly scatter mode for every series: 'lines', 'markers' or 'lines+markers'. Use 'lines+markers' when a series can have a single point, or a flat line, which a line alone does not show. Charts that do not pass mode render as lines only.
  3. layout

    • Type: object
    • Default: {}
    • Description: Plotly layout options (title, axes, margins).
  4. config

    • Type: object
    • Default: {}
    • Description: Plotly config options.
  5. onClick

    • Type: (event) => void
    • Default: no-op
    • Description: Called when a point is clicked. event.points[0] has the clicked point.
  6. style

    • Type: object
    • Default: {}
    • Description: Style for the chart container.

Usage Example​

function Example() {
const { protrakComponents } = React.useContext(customWidgetContext);
const { LineChartRenderer } = protrakComponents;

const traces = [
{ name: 'Keys', x: ['Aug-2026', 'Sep-2026'], y: [15152, 15842] },
];

return (
<LineChartRenderer
data={traces}
mode="lines+markers"
onClick={(event) => console.log(event.points[0].x)}
/>
);
}