Git Product home page Git Product logo

react-roughviz's Introduction

react-roughviz

This is a thin React wrapper around the awesome roughViz.

Installation

npm i react-roughviz

Usage

    <h3>Bar</h3>
    <Bar
      data='https://raw.githubusercontent.com/jwilber/random_data/master/flavors.csv'
      labels='flavor'
      values='price'
    />
    <h3>Pie</h3>
    <Pie
      data={{
        labels: ['North', 'South', 'East', 'West'],
        values: [10, 5, 8, 3]
      }}
      title='Regions'
      colors={['red', 'orange', 'blue', 'skyblue']}
      roughness={8}
    />

See it in action here: https://codesandbox.io/s/react-codesandbox-zmn70

Development

Run it via

npm start

This runs an example app (at http://localhost:3000) via react-scripts, you can then edit the example or the packaged code.

Testing

Due to how roughViz accesses the browser environment when rendering, React testing is limited: Testing by rendering to document.createElement(), or snapshot testing, won't work.

Integration testing via e.g. jest-puppeteer is possible, though. See ./integration/smoketest.test.js, or run it yourself:

npm run test:integration

react-roughviz's People

Contributors

chris927 avatar moldy530 avatar ninpeng avatar yenpingchew avatar

Stargazers

圈爷 avatar David Wen avatar  avatar fadholifh avatar Noob Tsai avatar  avatar chūn níng mǎ 马春宁 avatar LocTran avatar ranjanprj avatar Efrem Ropelato avatar Lezan avatar  avatar Leo avatar Erica Yee avatar Tolga Erdönmez avatar Mathusuthan Kannan avatar Tom Huang avatar 爱可可-爱生活 avatar Brad Pillow avatar Acampbell avatar Vasco Fernandes avatar 0xFrizen.eth avatar Jason Morganson avatar Max Schönberger avatar João Victor avatar Özgün Bal avatar Faye avatar CS avatar zhengll avatar  avatar Martín Varela avatar Donny Prasetyobudi avatar  avatar Tsang Chin Lung avatar Dylan Roy avatar Harald Kirkerød avatar Konstantin Pauk avatar R. Rajesh Jeba Anbiah avatar  avatar Marius Beineris avatar  avatar Martin Funk avatar  avatar Marco Casula avatar Chandan Mahapatra avatar Mark avatar Bill Brower avatar Arnis Lapsa avatar Robert McGuinness avatar  avatar Abdellah avatar Clayton Aldern avatar Raj K Singh avatar Gary Wu avatar Saad Regal avatar Rahav Lussato avatar Lance He avatar V5n avatar Siddhartha Basu avatar Ahmad Ali avatar Emmanuel Marcha avatar Gonçalo Mendes Cabrita avatar Sébastien Colbert avatar Evgeny Shcherbinin avatar okumurakengo avatar Randy Vianda Putra avatar Muhibbudin Suretno avatar Chris Edwards avatar Luke avatar Masaki Utsumiya avatar Christopher Bartling avatar Dmitrii Pashutskii avatar Jon Copperstone avatar Andrey avatar Robbie Jacobs avatar Tasso Evangelista avatar Fernando Bueno avatar Alex Figueiredo avatar  avatar Ken Wallace avatar  avatar Cash Sun avatar Chris Hart avatar Gustavo Gualbano avatar Matthias Treitler avatar Jared Wilber avatar

Watchers

Pierre Martin avatar  avatar James Cloos avatar  avatar  avatar

react-roughviz's Issues

Chart legend does not appear

Legend does not appear in charts, even when property legend is set to true.

Tried with the examples on README without success.

<h3>Bar</h3>
<Bar
  data='https://raw.githubusercontent.com/jwilber/random_data/master/flavors.csv'
  labels='flavor'
  values='price'
  legend={true}
/>
<h3>Pie</h3>
<Pie
  data={{
    labels: ['North', 'South', 'East', 'West'],
    values: [10, 5, 8, 3]
  }}
  title='Regions'
  colors={['red', 'orange', 'blue', 'skyblue']}
  roughness={8}
  legend={true}
/>

renders with crashing

This test fails `yarn test, seems to be related to jwilber/roughViz#8

my test only includes the Pie example from https://codesandbox.io/s/react-codesandbox-w7o6u

import React from 'react'
import ReactDOM from 'react-dom'
import App from './App'

it('renders without crashing', () => {
  const div = document.createElement('div')
  ReactDOM.render(<App />, div)
  ReactDOM.unmountComponentAtNode(div)
})
● renders without crashing

    TypeError: Cannot read property 'ownerDocument' of null

       6 |   const div = document.createElement('div')
       7 |   ReactDOM.render(<App />, div)
    >  8 |   ReactDOM.unmountComponentAtNode(div)
         |            ^
       9 | })
      10 | 

      at Q.draw (node_modules/rough-viz/dist/roughviz.min.js:1:275343)
      at Q.arc (node_modules/rough-viz/dist/roughviz.min.js:1:277832)
      at node_modules/rough-viz/dist/roughviz.min.js:1:343594
          at Array.forEach (<anonymous>)
      at t.value (node_modules/rough-viz/dist/roughviz.min.js:1:343561)
      at t.drawChart (node_modules/rough-viz/dist/roughviz.min.js:1:340811)
      at new t (node_modules/rough-viz/dist/roughviz.min.js:1:339505)
      at node_modules/react-roughviz/src/lib/index.js:11:7
      at commitHookEffectList (node_modules/react-dom/cjs/react-dom.development.js:22030:26)
      at commitPassiveHookEffects (node_modules/react-dom/cjs/react-dom.development.js:22064:11)
      at HTMLUnknownElement.callCallback (node_modules/react-dom/cjs/react-dom.development.js:336:14)
      at invokeEventListeners (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:193:27)
      at HTMLUnknownElementImpl._dispatch (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:119:9)
      at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/events/EventTarget-impl.js:82:17)
      at HTMLUnknownElementImpl.dispatchEvent (node_modules/jsdom/lib/jsdom/living/nodes/HTMLElement-impl.js:30:27)
      at HTMLUnknownElement.dispatchEvent (node_modules/jsdom/lib/jsdom/living/generated/EventTarget.js:157:21)
      at Object.invokeGuardedCallbackDev (node_modules/react-dom/cjs/react-dom.development.js:385:16)
      at invokeGuardedCallback (node_modules/react-dom/cjs/react-dom.development.js:440:31)
      at flushPassiveEffectsImpl (node_modules/react-dom/cjs/react-dom.development.js:25392:7)
      at unstable_runWithPriority (node_modules/scheduler/cjs/scheduler.development.js:697:12)
      at runWithPriority$2 (node_modules/react-dom/cjs/react-dom.development.js:12149:10)
      at flushPassiveEffects (node_modules/react-dom/cjs/react-dom.development.js:25361:12)
      at performSyncWorkOnRoot (node_modules/react-dom/cjs/react-dom.development.js:24251:5)
      at scheduleUpdateOnFiber (node_modules/react-dom/cjs/react-dom.development.js:23698:7)
      at updateContainer (node_modules/react-dom/cjs/react-dom.development.js:27103:3)
      at legacyRenderSubtreeIntoContainer (node_modules/react-dom/cjs/react-dom.development.js:27544:5)
      at node_modules/react-dom/cjs/react-dom.development.js:27649:7
      at unbatchedUpdates (node_modules/react-dom/cjs/react-dom.development.js:24433:12)
      at Object.unmountComponentAtNode (node_modules/react-dom/cjs/react-dom.development.js:27648:5)
      at Object.<anonymous> (src/App.test.tsx:8:12)

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.