LineChartRenderer
Reference
LineChartRendererdraws 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
datais one series (a Plotly trace). The component sets the tracetypetoscatterand themodefor every series.
Props
-
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.
- Type:
-
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 passmoderender as lines only.
- Type:
-
layout- Type:
object - Default:
{} - Description: Plotly layout options (title, axes, margins).
- Type:
-
config- Type:
object - Default:
{} - Description: Plotly config options.
- Type:
-
onClick- Type:
(event) => void - Default: no-op
- Description: Called when a point is clicked.
event.points[0]has the clicked point.
- Type:
-
style- Type:
object - Default:
{} - Description: Style for the chart container.
- Type:
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)}
/>
);
}