Using the chart functionality in SpreadJS with React, you can visualise data for your applications while keeping all the chart elements in synchronization with the native data binding support.
Open the Command Prompt window and type the following commands:
npm install -g create-react-app create-react-app quick-start cd quick-start npm start |
After you finish, the react project will be created at the specified location in the directory. For more information on how to create a React project, refer to https://reactjs.org/docs/add-react-to-a-new-app.html
Next, you need to install @grapecity/spread-sheets-react in your project using the following command:
npm install @grapecity/spread-sheets-react |
Next, you need to import the SpreadJS CSS in your index.js file using the following code:
import '@grapecity/spread-sheets/styles/gc.spread.sheets.excel2013white.css'; |
Next, you need to install the charts module in your project using the following command:
npm install @grapecity/spread-sheets-charts |
Now, you can modify the App.js file as per your requirements. Changes will be reflected when the browser window is refreshed. As an example, you can use the sample code given below:
This example shows how to use charts in a React Application.
JavaScript |
Copy Code
|
---|---|
import React from 'react'; // Import the Charts module var SpreadJSKey = "xxx"; class App extends React.Component { { // Handling workbook initialized event { // Fetching sheet // Setting Sheetname //Prepare data for chart { // Add columnClustered chart // Add columnStacked chart // Add columnStacked100 chart sheetCharts.resumePaint(); render() { export default App; |