question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Currently it is not possible to use this library with React (easily).

Some modifications are needed to use it.

I want to discuss what should happen in this repository and what not.

I already did small changes to use it as a simple React component.

import React, { Component } from 'react'
import PropTypes from 'prop-types'
import Frappe from 'frappe-charts/src/scripts/charts.js'

import 'frappe-charts/dist/frappe-charts.min.css' // to import styling

class Chart extends Component {
  componentDidMount() {
    const {title, data, type = 'bar', height = 250} = this.props
    this.c = new Frappe({
      parent: this.chart,
      title,
      data,
      type,
      height
    })
  }

  render() {
    return <div ref={chart => (this.chart = chart)}/>
  }
}

export default Chart

I created a demo repo for showcase: https://github.com/tobiaslins/frappe-charts-react-example

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:18
  • Comments:22 (6 by maintainers)

github_iconTop GitHub Comments

3reactions
achillesrasquinhacommented, Nov 5, 2017

@tobiaslins, Could you add your credits to our README with reference to your example? 😄

1reaction
mrdaveycommented, May 2, 2019

I’m using the latest version of Frappe Charts and it was quite easy to use in React JS.

In my App render() {}:

        <div id="chart"></div>
        {!this.state.isLoading &&          
          <ChartRender chartData={this.state.chartData} />
        }

Then in the same file, under the App component:

const ChartRender = (props) => {
  let data = {
    labels: props.chartData.dates,
    datasets: [
      ...
    ]
  }

  let chart = new Chart("#chart", {
   ...
  });
  return null;
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Where To Get Support - React
Where To Get Support. React has a community of millions of developers. On this page we've listed some React-related communities that you can...
Read more >
React | endoflife.date
React is an open-source JavaScript web framework for building modern web applications. Release, Released, Active Support, Security Support, Latest. 18.2, 6 ...
Read more >
Supported Browsers and Features | Create React App
For a set of polyfills to support older browsers, use react-app-polyfill. Supported Language Features​. This project supports a superset of the ...
Read more >
6 Best React Communities to get Information and Support
6 Best React Communities to get Information and Support · 1. Dev's React Community · 2. Hashnode's React Community · 3. Reactiflux ·...
Read more >
React Experts to Help, Mentor, Review Code & More
Find a freelance React expert for help with reviewing code, mentorship, tutoring, and other React help you might need.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found