Giter VIP home page Giter VIP logo

fusioncharts / react-fusioncharts-component Goto Github PK

View Code? Open in Web Editor NEW
92.0 14.0 32.0 19.63 MB

ReactJS component for FusionCharts JavaScript Charting library.

Home Page: https://fusioncharts.github.io/react-fusioncharts-component/

License: MIT License

HTML 0.55% JavaScript 99.45%
react reactjs react-fusioncharts-component react-fusioncharts fusioncharts javascript-charts react-charts interactive-charts charts graphs

react-fusioncharts-component's Introduction

A simple and lightweight official React component for FusionCharts JavaScript charting library. react-fusioncharts enables you to add JavaScript charts in your React application or project without any hassle.


Validation and Verification

The FusionCharts React integration component has been verified and validated with different versions of Fusioncharts (3.19 / 3.18 / 3.17) with React versions 16/17/18

Table of Contents

Getting Started

Requirements

  • Node.js, NPM/Yarn installed globally in your OS.
  • FusionCharts and React installed in your project, as detailed below:

Installation

There are multiple ways to install react-fusioncharts component.

Direct Download All binaries are located on our github repository.

Install from NPM

npm install --save react-fusioncharts

See npm documentation to know more about npm usage.

Install from Yarn

yarn add react-fusioncharts

See yarn documentation to know more about yarn usage.

For general instructions, refer to this developer docs page.

Usage

If you have created your app using create-react-app

Import React, react-fusioncharts and FusionCharts in your app:

import React from 'react';
import ReactDOM from 'react-dom';
import FusionCharts from 'fusioncharts';
import Charts from 'fusioncharts/fusioncharts.charts';
import ReactFC from 'react-fusioncharts';

ReactFC.fcRoot(FusionCharts, Charts);

If you have created your app using tools like webpack or parcel

Import React, react-fusioncharts and FusionCharts in your app:

import React from 'react';
import ReactDOM from 'react-dom';
import FusionCharts from 'fusioncharts/core';
import Column2d from 'fusioncharts/viz/column2d';
import ReactFC from 'react-fusioncharts';

ReactFC.fcRoot(FusionCharts, Column2d);

Note: This way of import will not work in IE11 and below.

Quick Start

Here is a basic sample that shows how to create a chart using react-fusioncharts:

import React from 'react';
import ReactDOM from 'react-dom';
import FusionCharts from 'fusioncharts';
import Charts from 'fusioncharts/fusioncharts.charts';
import FusionTheme from 'fusioncharts/themes/fusioncharts.theme.fusion';
import ReactFC from 'react-fusioncharts';

ReactFC.fcRoot(FusionCharts, Charts, FusionTheme);

const dataSource = {
  chart: {
    caption: 'Countries With Most Oil Reserves [2017-18]',
    subCaption: 'In MMbbl = One Million barrels',
    xAxisName: 'Country',
    yAxisName: 'Reserves (MMbbl)',
    numberSuffix: 'K',
    theme: 'fusion'
  },
  data: [
    { label: 'Venezuela', value: '290' },
    { label: 'Saudi', value: '260' },
    { label: 'Canada', value: '180' },
    { label: 'Iran', value: '140' },
    { label: 'Russia', value: '115' },
    { label: 'UAE', value: '100' },
    { label: 'US', value: '30' },
    { label: 'China', value: '30' }
  ]
};

const chartConfigs = {
  type: 'column2d',
  width: 600,
  height: 400,
  dataFormat: 'json',
  dataSource: dataSource
};

ReactDOM.render(<ReactFC {...chartConfigs} />, document.getElementById('root'));

Render FusionMaps

To render a map, import the FusionMaps module along with the map definition.

import React from 'react';
import ReactDOM from 'react-dom';
import FusionCharts from 'fusioncharts';
import Maps from 'fusioncharts/fusioncharts.maps';
import World from 'fusioncharts/maps/fusioncharts.world';
import FusionTheme from 'fusioncharts/themes/fusioncharts.theme.fusion';
import ReactFC from 'react-fusioncharts';

ReactFC.fcRoot(FusionCharts, Maps, World, FusionTheme);
// Data Source B
const dataSource = {
  chart: {
    caption: 'Average Annual Population Growth',
    subcaption: ' 1955-2015',
    numbersuffix: '%',
    includevalueinlabels: '1',
    labelsepchar: ': ',
    entityFillHoverColor: '#FFF9C4',
    theme: 'fusion'
  },
  colorrange: {
    minvalue: '0',
    code: '#FFE0B2',
    gradient: '1',
    color: [
      { minvalue: '0.5', maxvalue: '1.0', color: '#FFD74D' },
      { minvalue: '1.0', maxvalue: '2.0', color: '#FB8C00' },
      { minvalue: '2.0', maxvalue: '3.0', color: '#E65100' }
    ]
  },
  data: [
    { id: 'NA', value: '.82', showLabel: '1' },
    { id: 'SA', value: '2.04', showLabel: '1' },
    { id: 'AS', value: '1.78', showLabel: '1' },
    { id: 'EU', value: '.40', showLabel: '1' },
    { id: 'AF', value: '2.58', showLabel: '1' },
    { id: 'AU', value: '1.30', showLabel: '1' }
  ]
};

const chartConfigs = {
  type: 'world',
  width: 600,
  height: 400,
  dataFormat: 'json',
  dataSource: dataSource
};

ReactDOM.render(<ReactFC {...chartConfigs} />, document.getElementById('root'));

Working with Events

To attach event callbacks to a FusionCharts component, follow the pattern below.

Write the callback:

As a separate function:

var chartEventCallback  = function (eventObj, dataObj) {
  [Code goes here]
}

Or, as a component class method:

chartEventCallback (eventObj, dataObj) {
  [Code goes here]
}

Attach the callback to an event through the React-FC component:

<ReactFC {...chartConfigs} fcEvent-EVENTNAME={this.chartEventCallback} />

Where, EVENTNAME is to be replaced by the event you want to track.

Consider the example below that tracks hover events on a data plot.
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import FusionCharts from 'fusioncharts';
import Charts from 'fusioncharts/fusioncharts.charts';
import ReactFC from 'react-fusioncharts';
import FusionTheme from 'fusioncharts/Charts/fusioncharts.theme.fusion';

ReactFC.fcRoot(FusionCharts, Charts, FusionTheme);

const dataSource = /* Data Source A , given above */;

const chartConfigs = {
  type: 'column2d',
  width: 600,
  height: 400,
  dataFormat: 'json',
  dataSource: dataSource
};

class Chart extends Component {
  constructor(props) {
    super(props);
    this.state = {
      actualValue: 'Hover on the plot to see the value along with the label'
    };
    this.showPlotValue = this.showPlotValue.bind(this);
  }

  // Event callback handler for 'dataplotRollOver'.
  // Shows the value of the hovered plot on the page.
  showPlotValue(eventObj, dataObj) {
    this.setState({
      actualValue: `You’re are currently hovering over ${
        dataObj.categoryLabel
      } whose value is ${dataObj.displayValue}`
    });
  }

  render() {
    return (
      <div>
        <ReactFC
          {...chartConfigs}
          fcEvent-dataplotRollOver={this.showPlotValue}
        />
        <p style={{ padding: '10px', background: '#f5f2f0' }}>
          {this.state.actualValue}
        </p>
      </div>
    );
  }
}

ReactDOM.render(<Chart />, document.getElementById('root'));

Usage and integration of FusionTime

From [email protected] and [email protected], You can visualize timeseries data easily on react.

Learn more about FusionTime here.

Consider the example below for integration of FusionTime

import React from 'react';
import FusionCharts from 'fusioncharts';
import TimeSeries from 'fusioncharts/fusioncharts.timeseries';
import ReactFC from 'react-fusioncharts';

ReactFC.fcRoot(FusionCharts, TimeSeries);

const jsonify = res => res.json();
const dataFetch = fetch(
  'https://raw.githubusercontent.com/fusioncharts/dev_centre_docs/fusiontime-beta-release/charts-resources/fusiontime/online-sales-single-series/data.json'
).then(jsonify);
const schemaFetch = fetch(
  'https://raw.githubusercontent.com/fusioncharts/dev_centre_docs/fusiontime-beta-release/charts-resources/fusiontime/online-sales-single-series/schema.json'
).then(jsonify);

class ChartViewer extends React.Component {
  constructor(props) {
    super(props);
    this.onFetchData = this.onFetchData.bind(this);
    this.state = {
      timeseriesDs: {
        type: 'timeseries',
        renderAt: 'container',
        width: '600',
        height: '400',
        dataSource: {
          caption: { text: 'Online Sales of a SuperStore in the US' },
          data: null,
          yAxis: [
            {
              plot: [
                {
                  value: 'Sales ($)'
                }
              ]
            }
          ]
        }
      }
    };
  }

  componentDidMount() {
    this.onFetchData();
  }

  onFetchData() {
    Promise.all([dataFetch, schemaFetch]).then(res => {
      const data = res[0];
      const schema = res[1];
      const fusionTable = new FusionCharts.DataStore().createDataTable(
        data,
        schema
      );
      const timeseriesDs = Object.assign({}, this.state.timeseriesDs);
      timeseriesDs.dataSource.data = fusionTable;
      this.setState({
        timeseriesDs
      });
    });
  }

  render() {
    return (
      <div>
        {this.state.timeseriesDs.dataSource.data ? (
          <ReactFC {...this.state.timeseriesDs} />
        ) : (
          'loading'
        )}
      </div>
    );
  }
}

Useful links for FusionTime

Drill Down Component

A custom component to easily add drill down to your react application.

Syntax

import FusionCharts from 'fusioncharts';
import Charts from 'fusioncharts/fusioncharts.charts';
import ReactFC from 'react-fusioncharts';
import DrillDown from 'react-fusioncharts/components/DrillDown';
DrillDown.fcRoot(FusionCharts, Charts);
class MyComponent extends React.Component{
  constructor(props){
    super(props);
    this.plotChildMap = [ 0, 2, 1 ];
    this.dataSource = /*Data Source A : Given above */   ;
    this.btnConfig = {text : 'Back'};
    this.type= 'column2d';
    this.height = 400;
    this.width = 400;
  }
  render(){
    return (
       <DrillDown
        dataSource={dataSource}
        plotChildMap={plotChildMap}
        btnConfig={btnConfig}
        btnStyle={btnStyle}
        dataFormat={dataFormat}
        type={type}
        height={height}
        width={width}
        ...other
        >
        <ReactFC />              /* ReactFC as a child */
        <ReactFC />
        ...
        <DrillDown></DrillDown> /* DrillDown as a child for next level drill down*/
      </DrillDown>
    )
  }
}

Attribute Description

  • plotChildMap[Array(Number)| Array[Object]]

    • Array ( Number ) - Representation of child mapped to the plot of the parent data source passed to the DrillDown component . Array location are considered plot index of parent, the value corresponding to it are considered which child chart to render. Eg. [0,2,1]
      0(location) -> 0 (value) means clicking the first (zero indexed) data plot , render the 0th child ,
      1(location) -> 2(value) means clicking the second data plot, render the 1st Child (Note: It is 0-indexed )
      Null case : You can pass null for a data plot for which you dont want a drill down.
    • Array ( Object ) - Representation of child mapped with plot in form of an object of shape
      { "plotPosition": Number, "childPosition": Number }
      This object holds information about which child render on a data plot is clicked.
      Eg. [{ plotPosition: 1 , childPosition: 0}, { plotPosition: 0, childPosition: 1}]
      Note: plotChildMap does not honour heterogeneous data , eg. Number and Object both.
      [ 0 , { plotPosition:0, childPosition: 1 } ]
  • btnConfig [Object]- Basic configuration without overriding the default button styles

    • text: PropTypes.string - Button Text
    • color: PropTypes.string
    • backgroundColor: PropTypes.string
    • borderColor: PropTypes.string
    • fontSize: PropTypes.string
    • fontWeight: PropTypes.string
    • padding: PropTypes.string
    • fontFamily: PropTypes.string
  • btnStyle [Object] - CSS styles which override the styles in default btnConfig except text.

Working with APIs

To call APIs we will need the chart object. To get the chart object for an React-FC component, pass a callback through the attribute onRender.

Write the callback:

As a separate function:

var chartRenderCallback  = function (chart) {
  [Code goes here]
}

Or, as a component class method:

chartRenderCallback (chart) {
  [Code goes here]
}

Pass the callback as a prop, to which the chart object will be returned on rendering

<ReactFC {...chartConfigs} onRender={chartRenderCallback} />
Consider the example below that conerts a Column 2D chart to a Pie 2D chart after 5 seconds.
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import FusionCharts from 'fusioncharts';
import Charts from 'fusioncharts/fusioncharts.charts';
import ReactFC from 'react-fusioncharts';
import FusionTheme from 'fusioncharts/themes/fusioncharts.theme.fusion';

ReactFC.fcRoot(FusionCharts, Charts, FusionTheme);

const dataSource = /* Data source A given above */;

const chartConfigs = {
  type: 'column2d',
  width: 600,
  height: 400,
  dataFormat: 'json',
  dataSource: dataSource
};

class Chart extends Component {
  // Convert the chart to a 2D Pie chart after 5 secs.
  alterChart(chart) {
    setTimeout(() => {
      chart.chartType('pie2d');
    }, 5000);
  }

  render() {
    return (
      <div>
        <ReactFC {...chartConfigs} onRender={alterChart} />
      </div>
    );
  }
}

ReactDOM.render(<Chart />, document.getElementById('root'));

links to help you get started:

Going Beyond Charts

  • Explore 20+ pre-built business specific dashboards for different industries like energy and manufacturing to business functions like sales, marketing and operations here.
  • See Data Stories built using FusionCharts’ interactive JavaScript visualizations and learn how to communicate real-world narratives through underlying data to tell compelling stories.

For Contributors

  • Clone the repository and install dependencies
$ git clone https://github.com/fusioncharts/react-fusioncharts-component.git
$ cd react-fusioncharts-component
$ npm i
$ npm start

Licensing

The FusionCharts React integration component is open-source and distributed under the terms of the MIT/X11 License. However, you will need to download and include FusionCharts library in your page separately, which has a separate license.

react-fusioncharts-component's People

Contributors

ashok1994 avatar ayanbhaduryfc avatar gaurav-celestial avatar jaycho46 avatar kodandarama-accolite avatar meherhowji-5740 avatar phistuck avatar prembalaji39 avatar rohanoid5 avatar rohitkr avatar rousan avatar sanjay-bhan avatar sanjaybhan avatar saurabh-celes avatar vishal-appwrk avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

react-fusioncharts-component's Issues

Map collections are not auto download

Need to implement MAP chart using fusion charts library but some how with npm package installer I can not able to download all map collection. rather I have to download those files from your official website and then need to paste in map folder.

I tried 4-5 times but maps are not downloaded along with npm package.

Do we have any other way to handle this issue?

Can build project because of fusioncharts

I am developing react project created by create-react-app. I don't use webpack. just project created by create-react-app.

Now I want to build using "npm run build", but i can't because of the error following:

Failed to minify the code from this file:

    ./node_modules/fusioncharts/_internal/lib/lib.js:1:9788

Possible import correction

Very new to react but I think it should be import ReactFC from 'react-fusioncharts' in the documentation instead of import react-fusioncharts from 'react-fusioncharts'.
I might be using the modules wrong though.

Used with wepack

Getting the below error for Different Maps

image

Code
// STEP 1 - Include Dependencies

// Include react
import React from 'react';
// import ReactDOM from 'react-dom';
// Step 1 - Including react
// import React from 'react';
// import ReactDOM from 'react-dom';

// Step 2 - Including the react-fusioncharts component
import ReactFC from 'react-fusioncharts';

// Step 3 - Including the fusioncharts library
import FusionCharts from 'fusioncharts';

// Step 4 - Including the map renderer
import FusionMaps from 'fusioncharts/fusioncharts.maps';

// Step 5 - Including the map definition file
import California from 'fusionmaps/maps/fusioncharts.california';

// Step 6 - Including the theme as fusion
import FusionTheme from 'fusioncharts/themes/fusioncharts.theme.fusion';

// Step 7 - Adding the map and theme as dependency to the core fusioncharts
ReactFC.fcRoot(FusionCharts, FusionMaps, California, FusionTheme);

//Step 8 - Defining map data
const mapData = [{ "id": "001", "value": 2834 }, { "id": "003", "value": 3182 }, { "id": "005", "value": 3280 }, { "id": "007", "value": 911 }, { "id": "009", "value": 292 }, { "id": "011", "value": 530 }, { "id": "013", "value": 2515 }, { "id": "015", "value": 728 }, { "id": "017", "value": 1974 }, { "id": "019", "value": 848 }, { "id": "021", "value": 3278 }, { "id": "023", "value": 4463 }, { "id": "025", "value": 1198 }, { "id": "027", "value": 378 }, { "id": "029", "value": 2610 }, { "id": "031", "value": 1200 }, { "id": "033", "value": 3820 }, { "id": "035", "value": 940 }, { "id": "037", "value": 3416 }, { "id": "039", "value": 4004 }, { "id": "041", "value": 1604 }, { "id": "043", "value": 4011 }, { "id": "045", "value": 3203 }, { "id": "047", "value": 3775 }, { "id": "049", "value": 2721 }, { "id": "051", "value": 3417 }, { "id": "053", "value": 1530 }, { "id": "055", "value": 412 }, { "id": "057", "value": 3434 }, { "id": "059", "value": 1670 }, { "id": "061", "value": 1274 }, { "id": "063", "value": 4339 }, { "id": "065", "value": 2073 }, { "id": "067", "value": 1018 }, { "id": "069", "value": 3967 }, { "id": "071", "value": 3401 }, { "id": "073", "value": 3307 }, { "id": "075", "value": 1938 }, { "id": "077", "value": 489 }, { "id": "079", "value": 3207 }, { "id": "081", "value": 2295 }, { "id": "083", "value": 2747 }, { "id": "085", "value": 1114 }, { "id": "087", "value": 3400 }, { "id": "089", "value": 784 }, { "id": "091", "value": 1673 }, { "id": "093", "value": 4274 }, { "id": "095", "value": 4509 }, { "id": "097", "value": 3862 }, { "id": "099", "value": 1356 }, { "id": "101", "value": 4126 }, { "id": "103", "value": 1314 }, { "id": "105", "value": 1807 }, { "id": "107", "value": 4026 }, { "id": "109", "value": 3456 }, { "id": "111", "value": 1393 }, { "id": "113", "value": 1500 }, { "id": "115", "value": 2218 }]

const colorrange = {
"minvalue": "0",
"startlabel": "Low",
"endlabel": "High",
"code": "e44a00",
"gradient": "1",
"color": [{ "maxvalue": "2500", "code": "f8bd19" }, { "maxvalue": "5000", "code": "6baa01" }]
};

// Step 9 - Creating the JSON object to store the map configurations
const chartConfigs = {
type: 'maps/northcarolina',
width: '1000',
height: '1000',
dataFormat: 'json',
dataSource: {
"chart": {
"animation": "0",
"showbevel": "0",
"usehovercolor": "1",
"showlegend": "1",
"legendposition": "BOTTOM",
"legendborderalpha": "0",
"legendbordercolor": "ffffff",
"legendallowdrag": "0",
"legendshadow": "0",
"caption": "Website Visits for the month of March 2018",
"connectorcolor": "000000",
"fillalpha": "80",
"hovercolor": "CCCCCC",
"theme": "fusion"
},
"colorrange": colorrange,
"data": mapData
}
};
// Step 10 - Creating the DOM element to pass the react-fusioncharts component
class Test extends React.Component {
render() {
return (
<ReactFC {...chartConfigs} />
);
}
}

// export default App

export default Test;

Peer dependency error with react 17.x.x

> npm i react-fusioncharts

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! While resolving: [email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/react
npm ERR!   react@"^17.0.2" from the root project
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! peer react@"^0.14.0 || ^15.0.0 || ^16.0.0" from [email protected]
npm ERR! node_modules/react-fusioncharts
npm ERR!   react-fusioncharts@"*" from the root project
npm ERR! 
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

Npm error(not warning) occurs because of peer dependency issue when I run npm install for the first time on a new project.

npm i --force can avoid this error but npm still showing few warning messages.

According to this issue #71, there doesn't seem to be any compatibility issues with react 17.
So adding react 17 to the peer dependency shouldn't be a problem.

Please checkout this pr #75

multiseries 2d column chart always showing "No data"

{
    "chart": {
        "caption": "Expense Analysis",
        "subCaption": "ACME Inc.",
        "xAxisname": "Region",
        "yAxisName": "Amount (In USD)",
        "numberPrefix": "$",
        "theme": "fusion"
    },
    "categories": [
        {
            "category": [
                {
                    "label": "East"
                },
                {
                    "label": "West"
                },
                {
                    "label": "South"
                },
                {
                    "label": "North"
                }
            ]
        }
    ],
    "dataset": [
        {
            "seriesName": "Actual Expenses",
            "data": [
                {
                    "value": "1441290"
                },
                {
                    "value": "855912"
                },
                {
                    "value": "911404"
                },
                {
                    "value": "648136"
                }
            ]
        },
        {
            "seriesName": "Budgeted Expenses",
            "renderAs": "line",
            "data": [
                {
                    "value": "1297430"
                },
                {
                    "value": "776485"
                },
                {
                    "value": "685352"
                },
                {
                    "value": "726791"
                }
            ]
        },
        {
            "seriesName": "Unknown liabilities",
            "renderAs": "area",
            "showAnchors" : "0",
            "data": [
                {
                    "value": "143860"
                },
                {
                    "value": "79427"
                },
                {
                    "value": "226052"
                },
                {
                    "value": "78655"
                }
            ]
        }
    ]
}

Tried with this sample dataset from the examples as well. Its always showing "No data to display".

Am I missing something?

Import Modules

Hi,
I get console error sometimes.
"Uncaught TypeError: a.setChartData is not a function", as I observed this happens when the 3 module is about to regenerate on importing modules

import React from 'react';
import ReactDOM from 'react-dom';
import ReactFC from 'react-fusioncharts';

// Here import licensed version of FusionCharts
import FusionCharts from './path/to/fusioncharts';
import Charts from './path/to/fusioncharts/fusioncharts.charts';

// Provide FusionCharts core and other modules to resolve
ReactFC.fcRoot(FusionCharts, Charts)

, so my is this, although my page still running and execute the charts correctly even this error console showed, but there are times that it cause to break my page.

How to enable scrolling on mobile view, when the initial touch is over the chart area ?

I'm using the ReactFC component to build cross platform dashboard application with React and CapacitorJS. When we are in mobile view, the scroll is not working if the initial touch is inside the chart area, which causes bad UX (the user needs to search an area which outside chart boundaries to be able to scroll down to the next charts). Is there any option to change this behavior ?

I'm using licensed 3.1.2 react-fusioncharts version

Build error with NextJs

Hi, I faced some difficulties which I cannot solve, so I am here for help.
I would like to use fusioncharts but in the built project the charts do now show up, and the console throws an error: Uncaught SyntaxError: Unexpected token ( .

I recreated the basics in a new example NextJS app and also had the same problem when I build it, you can check it out: https://github.com/Lunatial/FusionCharts

Another problem of mine is that (I could only try it in development mode) the fusionCharts tried to download google-fonts by CDN, and I do not know how to disable that effort.

Chart Type World, annotation label doesn't support styling.

I am trying to style the label for annotations of chart type world, the styling in tooltext is possible and I was able to customize it, however when I try to do same it randers all html as string. Surprisingly </br> tag does work on label. below is the sample what I want to achieve

image

I want to make the font of first line bigger and bold in the label.

Getting Error : Uncaught (in promise) ChunkLoadError: Loading chunk 13 failed.

Getting Error : Uncaught (in promise) ChunkLoadError: Loading chunk 13 failed. --> while loading of fusioncharts.
graphs & charts are rendered very well but it's throwing error in console.
please help me out with this error.

Uncaught (in promise) ChunkLoadError: Loading chunk 13 failed.
(missing: http://localhost:3000/fusioncharts.excelexport.js)
at a.e (fusioncharts.js:13:1)
at Function. (fusioncharts.js:13:1)
at i (fusioncharts.js:13:1)
at o (fusioncharts.js:13:1)
at d (fusioncharts.js:13:1)
at t.fireEvent (fusioncharts.js:13:1)
at t.preConfigure (fusioncharts.js:13:1)
at r.preConfigure (fusioncharts.js:14:1)
at t.preConfigure (fusioncharts.js:299:1)
at t.configure (fusioncharts.js:13:1)

Thanks.

Chart Type World, label unexpected border displayed.

The world map label shows an unexpected rounded border. The html element which gets generated at runtime is as below -

<rect x="629.40625" y="257" width="62.828125" height="31.15625" ry="10" rx="10" fill="none" stroke="#666666" stroke-opacity="0.9" stroke-width="1" shape-rendering="crispEdges" stroke-dasharray="none" style="shape-rendering: crispedges; cursor: default;" opacity="1"></rect>

This is how it looks -

image

Errors when using Node 18 in React application

I have recently upgraded the node.js version on my machine from 16.12.0 -> 18.18.0, prior to this change I was able to render my time series fusion chart fine but now when I start my project I am seeing the following runtime errors in the browser:

ERROR
y@http://localhost:3000/static/js/bundle.js:11594:100
./node_modules/fusioncharts/fusioncharts.js/</</t._render@http://localhost:3000/static/js/bundle.js:7922:118
c@http://localhost:3000/static/js/bundle.js:7901:40
./node_modules/fusioncharts/fusioncharts.js/</</t._renderChart@http://localhost:3000/static/js/bundle.js:7911:58
./node_modules/fusioncharts/fusioncharts.js/</</t._setState@http://localhost:3000/static/js/bundle.js:7646:18
./node_modules/fusioncharts/fusioncharts.js/</</Le/<@http://localhost:3000/static/js/bundle.js:7436:13

./node_modules/fusioncharts/fusioncharts.js/</</Le/<@http://localhost:3000/static/js/bundle.js:7440:44
ERROR
#90211 ExtensionExtension Error >> A FusionCharts extension must have a valid extension property.
./node_modules/fusioncharts/fusioncharts.js/</</t.addDep/<@http://localhost:3000/static/js/bundle.js:11440:48
./node_modules/fusioncharts/fusioncharts.js/</</t.addDep@http://localhost:3000/static/js/bundle.js:11433:9
./node_modules/fusioncharts/fusioncharts.js/</</e.addDep@http://localhost:3000/static/js/bundle.js:7550:32
./node_modules/fusioncharts/fusioncharts.js/</</Le/<@http://localhost:3000/static/js/bundle.js:7410:16

package.json

{
  "name": "second-fusioncharts-project",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^5.17.0",
    "@testing-library/react": "^13.4.0",
    "@testing-library/user-event": "^13.5.0",
    "fusioncharts": "^3.20.0",
    "react": "^18.2.0",
    "react-dom": "^18.2.0",
    "react-fusioncharts": "^4.0.0",
    "react-scripts": "^5.0.1",
    "web-vitals": "^2.1.4"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

What I have tried

  • Deleted node_modules folder and package-lock.json and re-run npm install

Are powercharts supported? Issue with dragnode

Hi,
I'm giving a quick try at adding a graph to an existing React application which already successfully shows bar charts and angular charts (gauges).

I keep getting

Uncaught SyntaxError: expected expression, got '<'

and

The script from “http://localhost:3000/fleet-management/machine/fusioncharts.powercharts.js” has been loaded although its MIME type (“text/html”) isn't a valid JavaScript MIME type

in the browser console.

I copied the example code from here https://www.fusioncharts.com/charts/drag-node-charts/simple-graph-layout?framework=react and added to the webapp source. I didn't change any dependency.
Am I missing something perhaps?

Tooltip losing reference when scroll page down or up

I got this error when I scroll the page and return to the chart, the tooltip is losing the reference, is that a bug in the library?

Component props:

{
 xAxisName: 'Day',
  labelDisplay: 'auto',
  formatNumber: '0',
  formatNumberScale: '0',
  numVisiblePlot: '21',
  showValues: '1',
  enableSmartLabels: '1',
  valuePosition: 'ABOVE',
  setAdaptiveYMin: '1',
  scrollShowButtons: '1',
  scrollColor: '#FFF',
  scrollPadding: '6',
  scrollToEnd: '1',
}

image

JQuery question

More of a question than an issue, but I noticed that JQuery is listed as a dependency in your package.json file. Is this correct that the plugin and or fusion charts itself dependent on JQuery?

I'm researching react charting packages right now for my react project and am looking to implement a charting tool thats not dependent on JQuery is why I am asking.

Thanks

Hide XT Trial

Hi I Just bought commercial license for fusion charts. Let me know how I can remove that trial watermark .

window not defined when start

I added a chart from Fusioncharts (this is chart: https://www.fusioncharts.com/charts/gauges/rating-meter-gauge) as a new dependency and trying to start the app it throws the following error and aborts:
ReferenceError: window is not defined
at Object. (/Users/phunghoang/Desktop/StockbookWebNew/node_modules/fusioncharts/fusioncharts.js:13:961)
I followed these step:
Install FusionCharts from npm
$ npm install react-fusioncharts --save
$ npm install fusioncharts --save
My Project using Reactjs and Nextjs.
Sorry My english not good?

How to display react gauge using this package?

Hi, I want to display gauges in reactjs components using this package.
I didn't find the attributes values for gauge like, type.
For chart :
chartConfigs = {
type : 'Column3D'
}
It's working...

For gauge :
chartConfigs = {
type : 'angulargauge' or 'AngulareGauge'
}
It's nit working , getting "chart type not supported" error.

Please help me to fix it. Thanks in advance.

tooltip and chart line/bar clicks not working

I've created the following component, and when I import this component into another react component, it renders just fine, but the tooltips do not show and the event clicks on a bar or line do not work either. Is this a bug?

`import FusionCharts from 'fusioncharts';
import charts from 'fusioncharts/fusioncharts.charts';
import ReactFC from 'react-fusioncharts';
charts(FusionCharts);

export default class test extends React.Component {
constructor(props) {
super(props);
}

render() {
	let myDataSource = {
		chart: {
			caption: "Harry's SuperMart",
			subCaption: "Top 5 stores in last month by revenue",
			numberPrefix: "$",
			theme: "ocean"
		},
		data: [{
			label: "Bakersfield Central",
			value: "880000"
		}, {
			label: "Garden Groove harbour",
			value: "730000"
		}, {
			label: "Los Angeles Topanga",
			value: "590000"
		}, {
			label: "Compton-Rancho Dom",
			value: "520000"
		}, {
			label: "Daly City Serramonte",
			value: "330000"
		}]
	};

let chartConfigs = {
    id: "revenue-chart2",
    renderAt: "revenue-chart-container2",
    type: "column2d",
    width: 500,
    height: 400,
    dataFormat: "json",
    dataSource: myDataSource,
    events: {
        dataplotclick: function (ev, props) {
            document.getElementById("value").innerHTML = props.displayValue;
        }
    }
};

	return (<ReactFC { ...chartConfigs } />);
}

}`

Unable to render in Remix.run app

This explicit line fails when used in a Remix.run app:

ReactFC.fcRoot(FusionCharts, Column2D, GammelTheme)

I'm getting this error:

ReferenceError: document is not defined

It makes sense since Remix use SSR, but even if I use this safe guard it fails (recommended approach from Remix docs):

if (typeof document !== 'undefined') {
    ReactFC.fcRoot(FusionCharts, Column2D, GammelTheme)
}

Fusion Charts not rendering in Angular 17 using esbuild

Building an Angular 17 project with ESBuild, fusion charts don't render. The following error can be seen in the debug console.

ERROR TypeError: t is not a function
at main-FDVUKKK2.js:250:138026
at Array.forEach ()
at o.resolveFusionCharts (main-FDVUKKK2.js:250:137957)
at new o (main-FDVUKKK2.js:250:137650)
at o.ɵfac [as factory] (main-FDVUKKK2.js:250:138247)
at em (main-FDVUKKK2.js:241:17093)
at aU (main-FDVUKKK2.js:241:16602)
at lM (main-FDVUKKK2.js:241:16331)
at sM (main-FDVUKKK2.js:241:15852)
at Be (main-FDVUKKK2.js:241:54171)

Error trying to use licensed version....

What's the correct process to use upgrade to the Licensed version of Fusioncharts, I've tried to reference the js files from the downloaded folder, but I always get the same error....

import FusionCharts from '../../assets/libs/fusioncharts/js/fusioncharts'

index js -- fusioncharts 2019-09-01 18-42-22

Themes fail to apply with ES6 imports

Following examples in this project, I import the ocean theme as oceanIgnore:

import React from 'react';
import ReactDOM from 'react-dom'
import ReactFC from 'react-fusioncharts';
import Dimensions from 'react-dimensions'
import FusionCharts from 'fusioncharts';
// Load the charts module
import charts from 'fusioncharts/fusioncharts.charts';
import oceanIgnore from'fusioncharts/themes/fusioncharts.theme.ocean';


charts(FusionCharts)

class YearOverYearSalesTrend extends React.Component {

  constructor(props) {
    super(props)

    this.state = {
      data: this.props.yearOverYearSalesTrend,
    
    }

    this.formatData = this.formatData.bind(this)
    this.formatData(this.props)
  }

  componentWillReceiveProps(nextProps) {
    this.formatData(nextProps)
  }

  componentDidMount() {

  }

  formatData(nextProps) {
    let newDataSet = nextProps.yearOverYearSalesTrend
    let categories = [{category: []}]
    let parent = this
    let dataset = [{seriesname: 'Previous 12 Months', data: []}, {seriesname: 'Current 12 Months', data: []}]
    Promise.resolve(
      newDataSet.map((item, index) => {
        categories[0].category.push({'label': item.month})
        dataset[0].data.push({value: item.totalSaleS1})
        dataset[1].data.push({value: item.totalSaleS2})
        return true
      })
    ).then(() => {
      parent.setState({categories: categories, dataset: dataset})
    })
    
  }

  render() {
    var barChartConfig = {
        id: 'yearOverYearSalesTrend',
        type: 'mscolumn2d',
        width: this.props.containerWidth,
        height: this.props.containerHeight - 25,
        enableSmartLabels: 1,
        className: "sales-mix-by-account-type-mtd", // ReactJS attribute-name for DOM classes
        dataFormat: "JSON",
        dataSource: {
            chart: {
              numberprefix: "$",
              showvalues: 0,
              paletteColors: "#333333,#73A3E1",
              plotgradientcolor: "",
              divlinecolor: "CCCCCC",
              theme: "ocean",
              showBorder: 0,
              "bgAlpha": 0,
            },
            dataset: this.state.dataset,
            categories: this.state.categories,
          }
        }
    return ( 
      <div className="full-height">
        <h2>Year Over Year Sales Trend</h2>
        <ReactFC {...barChartConfig} />
      </div>
    )
  }
}

export default Dimensions()(YearOverYearSalesTrend) 

However, I only get the default theme:
image

Is it being applied incorrectly? There are zero error messages or warnings in the console to suggest something isn't working. I've also tried manually including them with script tags, this hasn't worked either.

overlappedcolumn2d chart throwing error in react js

Overlappedcolumn2d chart throws below error while using it in react js:

Uncaught SyntaxError: Unexpected token '<'
fusioncharts.js:13 Uncaught (in promise) Error: ChunkLoadError: Loading chunk 12 failed.
(missing: http://localhost:3000/fusioncharts.overlappedcolumn2d.js)
at Function.a.e (fusioncharts.js:13)
at d (fusioncharts.js:13)
at Function. (fusioncharts.js:13)
at i (fusioncharts.js:13)
at o (fusioncharts.js:13)
at h (fusioncharts.js:13)
at e.t.chartType (fusioncharts.js:13)
at new e (fusioncharts.js:13)
at new f (fusioncharts.js:13)
at ReactFC.renderChart (ReactFC.js:319)
at ReactFC.componentDidMount (ReactFC.js:78)
at commitLifeCycles (react-dom.development.js:20663)
at commitLayoutEffects (react-dom.development.js:23426)
at HTMLUnknownElement.callCallback (react-dom.development.js:3945)
at Object.invokeGuardedCallbackDev (react-dom.development.js:3994)
at invokeGuardedCallback (react-dom.development.js:4056)
at commitRootImpl (react-dom.development.js:23151)
at unstable_runWithPriority (scheduler.development.js:646)
at runWithPriority$1 (react-dom.development.js:11276)
at commitRoot (react-dom.development.js:22990)
at performSyncWorkOnRoot (react-dom.development.js:22329)
at react-dom.development.js:11327
at unstable_runWithPriority (scheduler.development.js:646)
at runWithPriority$1 (react-dom.development.js:11276)
at flushSyncCallbackQueueImpl (react-dom.development.js:11322)
at flushSyncCallbackQueue (react-dom.development.js:11309)
at batchedEventUpdates$1 (react-dom.development.js:22403)
at batchedEventUpdates (react-dom.development.js:3745)
at dispatchEventForPluginEventSystem (react-dom.development.js:8507)
at attemptToDispatchEvent (react-dom.development.js:6005)
at dispatchEvent (react-dom.development.js:5924)
at fusioncharts.js:13
(anonymous) @ fusioncharts.js:13
Promise.catch (async)
Ne @ fusioncharts.js:13
t._addChartDependency @ fusioncharts.js:13
t.chartType @ fusioncharts.js:13
e @ fusioncharts.js:13
f @ fusioncharts.js:13
renderChart @ ReactFC.js:319
componentDidMount @ ReactFC.js:78
commitLifeCycles @ react-dom.development.js:20663
commitLayoutEffects @ react-dom.development.js:23426
callCallback @ react-dom.development.js:3945
invokeGuardedCallbackDev @ react-dom.development.js:3994
invokeGuardedCallback @ react-dom.development.js:4056
commitRootImpl @ react-dom.development.js:23151
unstable_runWithPriority @ scheduler.development.js:646
runWithPriority$1 @ react-dom.development.js:11276
commitRoot @ react-dom.development.js:22990
performSyncWorkOnRoot @ react-dom.development.js:22329
(anonymous) @ react-dom.development.js:11327
unstable_runWithPriority @ scheduler.development.js:646
runWithPriority$1 @ react-dom.development.js:11276
flushSyncCallbackQueueImpl @ react-dom.development.js:11322
flushSyncCallbackQueue @ react-dom.development.js:11309
batchedEventUpdates$1 @ react-dom.development.js:22403
batchedEventUpdates @ react-dom.development.js:3745
dispatchEventForPluginEventSystem @ react-dom.development.js:8507
attemptToDispatchEvent @ react-dom.development.js:6005
dispatchEvent @ react-dom.development.js:5924

Hi, I tried to create multilevelpie chart but it was not rendering.

My code is :

import React  from 'react';
import ReactDOM from 'react-dom';
import Markdown  from 'react-markdown';
import FusionCharts from 'fusioncharts';
import Charts from 'fusioncharts/fusioncharts.charts';
import Widgets from 'fusioncharts/fusioncharts.widgets';
import ReactFC from 'react-fusioncharts';
import ReactFusioncharts from 'react-fusioncharts';
import FusionTheme from 'fusioncharts/themes/fusioncharts.theme.fusion';

ReactFC.fcRoot(FusionCharts,Charts,FusionTheme);

const dataSource = {
  "chart": {
    "caption": "Sales by Product Category",
    "subcaption": "Last Quarter",
    "showplotborder": "1",
    "plotfillalpha": "60",
    "hoverfillcolor": "#CCCCCC",
    "numberprefix": "$",
    "plottooltext": "Sales of <b>$label</b> was <b>$$valueK</b>, which was $percentValue of parent category",
    "theme": "fusion"
  },
  "category": [
    {
      "label": "Products",
      "tooltext": "Please hover over a sub-category to see details",
      "color": "#ffffff",
      "value": "150",
      "category": [
        {
          "label": "Food & Beverage",
          "color": "#f8bd19",
          "value": "55.5",
          "category": [
            {
              "label": "Breads",
              "color": "#f8bd19",
              "value": "11.1"
            },
            {
              "label": "Juice",
              "color": "#f8bd19",
              "value": "27.75"
            },
            {
              "label": "Noodles",
              "color": "#f8bd19",
              "value": "9.99"
            },
            {
              "label": "Seafood",
              "color": "#f8bd19",
              "value": "6.66"
            }
          ]
        },
        {
          "label": "Apparel",
          "color": "#33ccff",
          "value": "42",
          "category": [
            {
              "label": "Sun Glasses",
              "color": "#33ccff",
              "value": "10.08"
            },
            {
              "label": "Clothing",
              "color": "#33ccff",
              "value": "18.9"
            },
            {
              "label": "Handbags",
              "color": "#33ccff",
              "value": "6.3"
            },
            {
              "label": "Shoes",
              "color": "#33ccff",
              "value": "6.72"
            }
          ]
        },
        {
          "label": "Baby Products",
          "color": "#ffcccc",
          "value": "22.5",
          "category": [
            {
              "label": "Bath &{br}Grooming",
              "color": "#ffcccc",
              "value": "9.45"
            },
            {
              "label": "Food",
              "color": "#ffcccc",
              "value": "6.3"
            },
            {
              "label": "Diapers",
              "color": "#ffcccc",
              "value": "6.75"
            }
          ]
        },
        {
          "label": "Electronics",
          "color": "#ccff66",
          "value": "30",
          "category": [
            {
              "label": "Laptops",
              "color": "#ccff66",
              "value": "8.1"
            },
            {
              "label": "Televisions",
              "color": "#ccff66",
              "value": "10.5"
            },
            {
              "label": "SmartPhones",
              "color": "#ccff66",
              "value": "11.4"
            }
          ]
        }
      ]
    }
  ]
};

const chartConfigs = {
      type: 'multilevelpie',
      width: 600,
      height: 400,
      renderAt: 'chart-container',
      dataFormat: 'json',
      dataSource: dataSource,
};

export default class MyEditor extends React.Component {
  constructor(props) {
    super(props);
  }
  render(){
    return(
            <div>
                <ReactFC {...chartConfigs} /> 
            </div>
        )
  }
}

so please help me to fix this. thanks in advance............

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.