React UI Components Documentation
ReactJS Chart Component
The Chart component for ReactJS represents a lightweight and powerful chart widget. It offers many advanced features and supports three different rendering technologies - SVG, HTML5 Canvas & VML.
Prerequisites
Refer to ReactJS Getting Started before you start with this help topic.
Configuration
The Chart component for ReactJS requires the following imports.
import React from 'react';import ReactDOM from 'react-dom'; import JqxChart from 'jqwidgets-react/react_jqxchart.js';
Then we create our component class. Properties and methods are put as ReactJS props.
class App extends React.Component { render () { return ( <JqxChart style={{ width: 850, height: 500 }} showLegend={true} enableAnimations={true} source={dataAdapter} xAxis={xAxis} valueAxis={valueAxis} seriesGroups={seriesGroups} /> ) }}
Finally we render our class in the desired HTML element:
Events Methods & Properties
In order to bind to any event, change any property or call any method, we need a reference to the component.
For that we use the ReactJS "ref" Callback Attribute:
Now, when we have a reference, we need to call the desired event/property/method.
This is done in the componentDidMount() ReactJS Component Lifecycle method.
Events
The click event is raised when the user clicks on series element.
The following example demonstrates how to add an event listener.
Methods & Properties
This is how you call methods & props:
Every component have a method setOptions which accepts a object as an argument. This object contains component settings.
Every component also have a method getOptions which returns a object containing the component settings.
Chart Examples
Overview
The following example demonstrates how to create a Chart component.
Set Chart Columns with Local Data
The following example demonstrates the Chart bind to Local Data.
Donut Series
The following example demonstrates how to create a Chart component for ReactJS with two series of donut type (one inner and another one outer).