Giter Club home page Giter Club logo

react-d3-library's People

Contributors

andrewsburke avatar dloyst avatar hideto0710 avatar jamessam avatar jdlee23 avatar moriyaman 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  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 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

react-d3-library's Issues

Unknown prop `__data__` on <circle> tag

I currently have the following node:

import d3 from 'd3';

let node = document.createElement('div');
const w = 1280;
const h = 800;

let nodes = d3.range(200).map(function() {
    return {radius: Math.random() * 12 + 4};
});

let color = d3.scale.category10();

let force = d3.layout.force()
    .gravity(0.05)
    .charge(function(d, i) { return i ? 0 : -2000; })
    .nodes(nodes)
    .size([w, h]);

let root = nodes[0];

root.radius = 0;
root.fixed = true;
force.start();

let svg = d3.select(node).append('svg:svg')
    .attr('width', w)
    .attr('height', h);

svg.selectAll('circle')
    .data(nodes.slice(1))
    .enter().append('svg:circle')
    .attr('r', function(d) { return d.radius - 2; })
    .style('fill', function(d, i) { return color(i % 3); });

force.on('tick', function(e) {
    let i = 0;
    const q = d3.geom.quadtree(nodes);
    const n = nodes.length;

    while (++i < n) {
        q.visit(collide(nodes[i]));
    }

    svg.selectAll('circle')
        .attr('cx', function(d) { return d.x; })
        .attr('cy', function(d) { return d.y; });
});

//    svg.on('mousemove', function() {
//        const p1 = d3.svg.mouse(this);
//        root.px = p1[0];
//        root.py = p1[1];
//        force.resume();
//    });

function collide(node) {
    const r = node.radius + 16;
    const nx1 = node.x - r;
    const nx2 = node.x + r;
    const ny1 = node.y - r;
    const ny2 = node.y + r;

    return function(quad, x1, y1, x2, y2) {
        if (quad.point && (quad.point !== node)) {
            let x = node.x - quad.point.x;
            let y = node.y - quad.point.y;
            let l = Math.sqrt(x * x + y * y);
            const r = node.radius + quad.point.radius;

            if (l < r) {
                l = (l - r) / l * .5;
                node.x -= x *= l;
                node.y -= y *= l;
                quad.point.x += x;
                quad.point.y += y;
            }
        }

        return x1 > nx2
            || x2 < nx1
            || y1 > ny2
            || y2 < ny1;
    };
}

// indicate which class can be exported, and instantiated via 'require'
export default node;

It is generating an Unknown prop error in the browser console:

d3-error

Additionally, I'd like to uncomment the the following from above, which also produces it's own error:

//    svg.on('mousemove', function() {
//        const p1 = d3.svg.mouse(this);
//        root.px = p1[0];
//        root.py = p1[1];
//        force.resume();
//    });

Transitions are not working

Not sure if I've implemented something incorrectly, but I am unable to identify the issue with my code.

Here is the d3 code. Its from the Bilevel Partition example on the d3 website:

import React        from 'react';
import d3           from 'd3';
import DataCircles  from './dataCircles.jsx';
import data from 'json!./TestData.json'

var node = document.createElement('div');

console.log('d3 data: ', data)

var root = data

var margin = {top: 450, right: 480, bottom: 350, left: 480},
    radius = Math.min(margin.top, margin.right, margin.bottom, margin.left) - 10;

var hue = d3.scale.category10();

var luminance = d3.scale.sqrt()
    .domain([0, 1e6])
    .clamp(true)
    .range([90, 20]);

var svg = d3.select(node).append("svg")
    .attr("width", margin.left + margin.right)
    .attr("height", margin.top + margin.bottom)
    .append("g")
    .attr("transform", "translate(" + margin.left + "," + margin.top + ")");

var partition = d3.layout.partition()
    .sort(function(a, b) { return d3.ascending(a.name, b.name); })
    .size([2 * Math.PI, radius]);

var arc = d3.svg.arc()
    .startAngle(function(d) { return d.x; })
    .endAngle(function(d) { return d.x + d.dx - .01 / (d.depth + .5); })
    .innerRadius(function(d) { return radius / 3 * d.depth; })
    .outerRadius(function(d) { return radius / 3 * (d.depth + 1) - 1; });

partition
    .value(function(d) { return d.size; })
    .nodes(root)
    .forEach(function(d) {
        d._children = d.children;
        d.sum = d.value;
        d.key = key(d);
        d.fill = fill(d);
    });

// Now redefine the value function to use the previously-computed sum.
partition
    .children(function(d, depth) { return depth < 2 ? d._children : null; })
    .value(function(d) { return d.sum; });

var center = svg.append("circle")
    .attr("r", radius / 3)
    .on("click", zoomOut);

center.append("title")
    .text("zoom out");

var path = svg.selectAll("path")
    .data(partition.nodes(root).slice(1))
    .enter().append("path")
    .attr("d", arc)
    .style("fill", function(d) { return d.fill; })
    .each(function(d) { this._current = updateArc(d); })
    .on("click", zoomIn);

function zoomIn(p) {
    console.log(p)
    if (p.depth > 1) p = p.parent;
    if (!p.children) return;
    zoom(p, p);
}

function zoomOut(p) {
    if (!p.parent) return;
    zoom(p.parent, p);
}

// Zoom to the specified new root.
function zoom(root, p) {
    if (document.documentElement.__transition__) return;

    // Rescale outside angles to match the new layout.
    var enterArc,
        exitArc,
        outsideAngle = d3.scale.linear().domain([0, 2 * Math.PI]);

    function insideArc(d) {
        return p.key > d.key
            ? {depth: d.depth - 1, x: 0, dx: 0} : p.key < d.key
            ? {depth: d.depth - 1, x: 2 * Math.PI, dx: 0}
            : {depth: 0, x: 0, dx: 2 * Math.PI};
    }

    function outsideArc(d) {
        return {depth: d.depth + 1, x: outsideAngle(d.x), dx: outsideAngle(d.x + d.dx) - outsideAngle(d.x)};
    }

    center.datum(root);

    // When zooming in, arcs enter from the outside and exit to the inside.
    // Entering outside arcs start from the old layout.
    if (root === p) enterArc = outsideArc, exitArc = insideArc, outsideAngle.range([p.x, p.x + p.dx]);

    path = path.data(partition.nodes(root).slice(1), function(d) { return d.key; });

    console.log("path: ", path)

    // When zooming out, arcs enter from the inside and exit to the outside.
    // Exiting outside arcs transition to the new layout.
    if (root !== p) enterArc = insideArc, exitArc = outsideArc, outsideAngle.range([p.x, p.x + p.dx]);

    d3.transition().duration(d3.event.altKey ? 7500 : 750).each(function() {
        path.exit().transition()
            .style("fill-opacity", function(d) { return d.depth === 1 + (root === p) ? 1 : 0; })
            .attrTween("d", function(d) { return arcTween.call(this, exitArc(d)); })
            .remove();


        path.enter().append("path")
            .style("fill-opacity", function(d) { return d.depth === 2 - (root === p) ? 1 : 0; })
            .style("fill", function(d) { return d.fill; })
            .on("click", zoomIn)
            .each(function(d) { this._current = enterArc(d); });


        path.transition()
            .style("fill-opacity", 1)
            .attrTween("d", function(d) { return arcTween.call(this, updateArc(d)); });
    });

}

function key(d) {
    var k = [], p = d;
    while (p.depth) k.push(p.name), p = p.parent;
    return k.reverse().join(".");
}

function fill(d) {
    var p = d;
    while (p.depth > 1) p = p.parent;
    var c = d3.lab(hue(p.name));
    c.l = luminance(d.sum);
    return c;
}

function arcTween(b) {
    var i = d3.interpolate(this._current, b);
    this._current = i(0);
    return function(t) {
        return arc(i(t));
    };
}

function updateArc(d) {
    return {depth: d.depth, x: d.x, dx: d.dx};
}


d3.select(self.frameElement).style("height", margin.top + margin.bottom + "px");

module.exports = node

And here is the entry point. :

import React from 'react'
import Paper from 'material-ui/Paper';
import { inject, observer } from 'mobx-react';
import {observable} from 'mobx'
import node from './DashboardCharts/TestChart.jsx'
import rd3 from 'react-d3-library'
const RD3Component = rd3.Component;

@observer
export default class LoggedOut extends React.Component {

  @observable node

  constructor(props) {
    super(props)
    this.node = node
    this.state = observable({
      d3: ''
    })
  }

  componentDidMount() {
    this.setState({d3: this.node});
  }

  render() {
      return (
      <div style={{
         display: 'flex',
         alignItems: 'center',
         justifyContent: 'center',
         height: '100vh'
      }}>
        <div style={{
           backgroundColor: '#f3f2ef'
        }}>
          <Paper zDepth={2} rounded={false} style={{padding:'30px'}}>
            <div>
              <RD3Component data={this.state.d3} />
            </div>
          </Paper>
        </div>
      </div>
  )
  }

}

how update data in in react d3 bubble chart without draw another chart?

I want to change data when the data props changed, but every time just draws another chart and add it to the screen, I want to do changes in the same bubble chart how can I do it?!

import React, { useEffect, useRef } from "react";
import * as d3 from "d3";
import { CardBody, Card, CardHeader } from "reactstrap";

const BubbleChartD3Test = ({ data }) => {
  const el = useRef();
  console.log(data);

  function createSvg() {
    return d3
      .select(el.current)
      .append("svg")
      .attr("width", 500)
      .attr("height", 500);
  }
  function drawChart(svg) {
    let hierachalData = makeHierarchy(data);
    let packLayout = pack([400 - 10, 400 - 10]);
    const root = packLayout(hierachalData);

    const leaf = svg
      .selectAll("g")
      .data(root.leaves())
      .join("g")
      .attr("transform", (d) => `translate(${d.x + 1},${d.y + 1})`);

    leaf
      .append("circle")
      .attr("r", (d) => d.r)
      .attr("fill-opacity", 0.7)
      .attr("fill", "navy");

    leaf
      .append("text")
      .attr("dy", ".2em")
      .style("text-anchor", "middle")
      .text(function (d) {
        return d.data["Screen Name"];
      })
      .attr("font-family", "sans-serif")
      .attr("font-size", function (d) {
        return d.r / 5;
      })
      .attr("fill", "white");

    leaf.append("title").text(function (d) {
      return d.data["Screen Name"] + ": " + d.data["تعداد توییت"];
    });
  }

  function pack(size) {
    return d3.pack().size(size).padding(3);
  }

  function makeHierarchy() {
    return d3.hierarchy({ children: data }).sum((d) => d["تعداد توییت"]);
  }

  useEffect(() => {
    let svg = createSvg();
    drawChart(svg);
  }, [data]);

  return (
    <Card>
      <CardHeader>
        {" "}
        <h2>bubble chart</h2>
      </CardHeader>
      <CardBody>
        {" "}
        <div id="bubblechart" ref={el}></div>
      </CardBody>
    </Card>
  );
};

export default BubbleChartD3Test;

this is my array in data props has two filed :

[Screen Name: "h_javanmarrd13"
تعداد توییت: 1]

first, add a space and add a chart, when data change adds another chart.

how can fix it
thanks.

Brush with bar chart.

Please can you provide details how the brush feature in react-d3-library can be used. I am new to brush and have a d3 grouped bar chart where I want to implement the brush feature.

Thank you.

How to open url ?

I need to open url when clicked on the donut chart slices. i used react-d3.js to build a donut chart. i'm new to react-d3.js. any help in this is highly appreciated.
I look forward to your reply.

Change colour of AreaChart based on data given

I'm using this library to draw AreaChart and I used AreaChart successfully inside my project as a component. Now, I want to change the colour of half part of AreaChart based on data that I'm giving. Is there any option using which I can pass flag or something to draw with specific colour based on values.

Also, there is a class called 'createAreaChart.js'. How can I use it in my current project if it's going to help me to solve coloring issue?

Thanks.

Unknown props error

I'm attempting to load the code borrowed from http://codepen.io/danieljoonlee/pen/jrPoPE in my app and receive the following error:

warning.js:36 Warning: Unknown props `__data__`, `__onmouseover`, `__onmouseout` on <line> tag. Remove these props from the element.

Dependencies:

"dependencies": {
    "d3": "3.5.17",
    "react": "^15.4.1",
    "react-d3-library": "^1.1.7",
    "react-dom": "^15.4.1"
},

Receiving Warning when using append('text')

React don't like the textContent attribute of the d3 text element.

My code:

const node = document.createElement('div');
const svg = d3.select(node).append('svg');
svg.append('text').text('Hello d3');

The Warning:

Warning: React does not recognize the `textContent` prop on a DOM element. If you intentionally 
want it to appear in the DOM as a custom attribute, spell it as lowercase `textcontent` instead. If you 
accidentally passed it from a parent component, remove it from the DOM element.
in text
in svg
in div
in div
in childComponent
in div
...

Update wiki templates page

Hey guys,

@dloyst I noticed few errors in Templates wiki page when tried to set it up

fix string values

data.dataset = [
  {label: apples, value: 25},
  {label: oranges, value: 30},
  {label: surfboards, value: 150},
  ...
]

should be replaced with

data.dataset = [
  {label: 'apples', value: 25},
  {label: 'oranges', value: 30},
  {label: 'surfboards', value: 150},
  // ...
]

fix array assignment

data.fill['lemonChiffon', 'aliceblue', 'sandybrown', 'darksalmon']

should be replaced with

data.fill = ['lemonChiffon', 'aliceblue', 'sandybrown', 'darksalmon']

fix case sensitivity

data.dataset = [

should be replaced

data.dataSet = [

suggestion

And I'd add to this page some code like this

import { BarChart } from 'react-d3-library'

const data = {}
//...
const Chart () => <BarChart data={data} /> 

New Maintainer?

Is this repo actively maintained? If not, I am interested in taking over as the maintainer.

Also, could you provide reasons for no longer maintaining? If that is the case.

WebStorm React d3 library force()

I have a really strange problem with my libraries in WebStorm. I have been trying to find out why this does not work, but nobody seem to have the exact problem I am having, maybe because I search bad, but I have really tried.

I have followed the WebStorm support, and from their perspective it should work by now! I do not get any fault when installing the libraries with npm.

I also tried installing external libraries.

However, I am trying to use react-d3-library because I am doing a relational graph with d3. I can see that is available in my node modules in my project, the folder was gray and the others orange? Did not really know why... did some research and found something about "Right click on the directory and go to 'Mark Directory as' and select 'Resource Root'" but does not seem to work for me?

When I run this in my browser I get when pressing F12

Uncaught TypeError: Cannot read property 'force' of undefined
at App.componentDidMount (App.js:311)
at ReactCompositeComponent.js:265
at measureLifeCyclePerf (ReactCompositeComponent.js:75)
at ReactCompositeComponent.js:264
at CallbackQueue.notifyAll (CallbackQueue.js:76)
at ReactReconcileTransaction.close (ReactReconcileTransaction.js:80)
at ReactReconcileTransaction.closeAll (Transaction.js:206)
at ReactReconcileTransaction.perform (Transaction.js:153)
at batchedMountComponentIntoNode (ReactMount.js:126)
at ReactDefaultBatchingStrategyTransaction.perform (Transaction.js:140)
Code:

import d3 from 'react-d3-library';
//var d3 = require('react-d3-library);// tried this...

     const force = d3.layout.force() // (App.js:311)
    .charge(-120)
    .linkDistance(50)
    .size([width, height])
    .nodes(data.nodes)
    .links(data.links);

I would really like some help with this... I really do not get why it does not work? It is probably something easy but I have been fighting this the last 3 days...

P.S. Code is here on my github: https://github.com/Thelin90/react-d3.git

Example i tried to follow: https://egghead.io/lessons/react-creating-a-d3-force-layout-in-react-c65fa37c

Cannot read property 'select' of undefined

I tried your D3 code & React code example from the wiki, but it gives me the the error
'Cannot read property 'select' of undefined'
in line 7
var svg = d3.select(node).append("svg")

Is the library still up to date ?

Packaged d3 overrides global/window d3

The dist version comes with it's own version of d3. When importing react-d3-library this instance of d3 overrides any other version which may exist on the global/window.
This becomes an issue when d3.event is set in once instance and a handler in another instance see it as still being null.
It being prepackaged into the main file also would mean the final payload would have d3 in it twice making the file size larger.
I don't think this library should include it's own d3, it could look for it on the global/window scope or have the ability to receive d3 (something like:)

import d3 from 'd3';
import rd3 from 'react-d3-library';
const RD3Component = rd3.Component(d3);

forthermore, since it is prepackaged, external d3 is not even needed, just try your example without the d3 script (Pen Settings -> JavaScript -> Add External JavaScript -> remove d3 script from the list).

Right now, as a workaround, I am not including my own d3, which avoids the double the d3 lib in the bundled js. I grab d3 off the window when I need it.

// import d3 from 'd3';
import rd3 from 'react-d3-library';
// ... omitted for brevity
const d3 = window.d3; // explicitly get d3 from window.

what is the main difference of this repo and the repo "d3"

we could simply use d3 by npm install d3

and then do sth like


import * as d3 from 'd3'
const svg = d3.select(element)
			.append("svg")
				.attr("width", 500)
				.attr("height", 500)

may I know what is the difference of this repo and the d3 package in npm?

TypeError: data.dataSet is undefined

var BarChart = require('react-d3-library').BarChart;
...
        var values = [];
        for (var i = 0; i < hourly.length; i++) {
            values.push({"x": hourly[i].DESCRIP, "y": hourly[i].DYES});
        }
        var barData = [
          { 
            "label": "Hourly Series",
            'dataSet': values
          }
        ];
...
                        <BarChart
                            data={barData}
                            height={200}
                            width={300}
                        />

How to call function from d3 file on event handler in react component

I want to be able to call the 'infect_start' function which is in my graphTest.js file (containing javascript d3) from my controlsComponent.js file which is a react component. The function should be called onClick of the 'playButton'. I have been trying a few different techniques, but am struggling how to coordinate the Javascript file with my React one, currently the error is to do with importing and exporting wrong - I think this would be the wrong approach anyway. Anyone have any clues?

My graphTest.js file:

`import $ from 'jquery';

const d3 = require('d3');
const nodeSVG = document.createElement('div');
nodeSVG.setAttribute("id", "svgDiv");
const url = "http://127.0.0.1:5000/";

const width = 700,
height = 700,
radius = 8;

let inf_list = [];
let alive = false;

$.ajax({type: "POST", url: url.concat("graph_receiver"), data: JSON.stringify([{"graph": "TUS2"}]), success: function(response) {
d3.select(nodeSVG).remove(); create_graph(response); console.log('Created Graph');}});

function create_graph(graph) {
var force = d3.layout.force()
.size([width, height])
.nodes(graph.nodes) // initialize with a single node
.links(graph.links)
.linkDistance(60) // 60
.size([width, height])
.charge(-200) // -200
.on("tick", tick);

var drag = force.drag()
    .on("dragstart", dragstarted)
    .on("drag", dragged)
    .on("dragend", dragended);

var svg = d3.select("body").append("svg")
    .attr("width", width)
    .attr("height", height);

var nodes = force.nodes(),
    links = force.links();

var node = svg.selectAll(".node"),
    link = svg.selectAll(".link");

restart();

function tick() {
    link.attr("x1", function (d) {
        return d.source.x = Math.max(radius, Math.min(width - radius, d.source.x));
    })
        .attr("y1", function (d) {
            return d.source.y = Math.max(radius, Math.min(height - radius, d.source.y));
        })
        .attr("x2", function (d) {
            return d.target.x = Math.max(radius, Math.min(width - radius, d.target.x));
        })
        .attr("y2", function (d) {
            return d.target.y = Math.max(radius, Math.min(height - radius, d.target.y));
        });

    node.attr("cx", function (d) {
        return d.x = Math.max(radius, Math.min(width - radius, d.x));
    })
        .attr("cy", function (d) {
            return d.y = Math.max(radius, Math.min(height - radius, d.y));
        });
}

function restart() {
    node = node.data(nodes);
    node.enter().insert("circle")
        .attr("class", "node")                    // Changes class to node
        .attr("r", radius)                             // Sets radius of node
        .call(drag);
    node.exit()                                   // Nodes to remove
        .remove();                                // Remove nodes
    link = link.data(links);
    link.enter().insert("line", ".node")
        .attr("class", "link");
    link.exit()
        .remove();
    force.start();
}

function dragstarted(d) {
    if (!d3.event.active) {
        d.fx = d.x;
        d.fy = d.y;
    }
}

function dragged(d) {
    d.fx = d3.event.x;
    d.fy = d3.event.y;
}

function dragended(d) {
    // d3.select(this).classed("fixed", d.fixed = true);    // This fixes node in position - may add later
    if (!d3.event.active) {
        d.fx = null;
        d.fy = null;
    }
}

function get_json(d) {
        inf_list = JSON.parse(d).inf_list;
}

svg.on("mount", function(){
    this.infect_start = this.infect_start.bind(this);
});

function infect_start() {
        console.log('Started Infection');
        // Send call to backend to start infection
        alive = true;
        $.ajax({
            type: "POST",
            url: url.concat("init"),
            data: JSON.stringify([{"action": 'INITIALISE'}]),
            success: get_json,
            async: false
        });

        node.filter(function (d) {
            return inf_list.includes(d.id);
        })
        .style('fill', 'red');
        d3.event.preventDefault();
}

}

export {
infect_start,
nodeSVG,
}`

My controlsComponent.js file:

`import React, { Component } from 'react';
import {ButtonDropdown, ButtonGroup, DropdownItem, Button, Navbar, DropdownMenu, DropdownToggle, Collapse, NavbarToggler, Tooltip} from 'reactstrap';
import { Link } from 'react-router-dom';
import {infect_start} from '../graphTest';

class Controls extends React.Component{

constructor(props){
    super(props)
    this.state = {
        isDropdown1Open: false,
        isDropdown2Open: false,
        isControlsOpen: true,
        isTooltip1Open: false,
        isTooltip2Open: false,
        isTooltip3Open: false,
        isTooltip4Open: false
    };
    this.toggleDropdown1 = this.toggleDropdown1.bind(this);
    this.toggleDropdown2 = this.toggleDropdown2.bind(this);
    this.toggleControls = this.toggleControls.bind(this);
    this.toggleTooltip1 = this.toggleTooltip1.bind(this);
    this.toggleTooltip2 = this.toggleTooltip2.bind(this);
    this.toggleTooltip3 = this.toggleTooltip3.bind(this);
    this.toggleTooltip4 = this.toggleTooltip4.bind(this);
};

toggleDropdown1(){
    this.setState({
        isDropdown1Open: !this.state.isDropdown1Open
    });
}

toggleDropdown2(){
    this.setState({
        isDropdown2Open: !this.state.isDropdown2Open
    });
}

toggleControls(){
    this.setState({
       isControlsOpen: !this.state.isControlsOpen
    });
}

toggleTooltip1(){
    this.setState({
        isTooltip1Open: !this.state.isTooltip1Open
    });
}

toggleTooltip2(){
    this.setState({
        isTooltip2Open: !this.state.isTooltip2Open
    });
}

toggleTooltip3(){
    this.setState({
        isTooltip3Open: !this.state.isTooltip3Open
    });
}

toggleTooltip4(){
    this.setState({
        isTooltip4Open: !this.state.isTooltip4Open
    });
}


render() {
  return(
      <Navbar className="navbar wrapper float-left pl-0" id="sidebar">
        <div className="row">
              <Button className="fa fa-bars" id="controlToggler" onClick={this.toggleControls}/>
        </div>
        <div className="container ml-0 pl-0 float-left align-center" id="controls">
          <Collapse isOpen={this.state.isControlsOpen}>
              <ButtonGroup vertical className="float-left ml-0 pl-0">
                  <Button variant="outline-light" size="sm" className="fa fa-play" id="playButton" onClick={infect_start}></Button>
                  <Tooltip placement="right" target="playButton" isOpen={this.state.isTooltip1Open} toggle={this.toggleTooltip1} delay={{show: 1250, hide: 0}}>
                      Start
                  </Tooltip>
                  <Button variant="outline-light" size="sm" className="fa fa-repeat" id="resetButton"></Button>
                  <Tooltip placement="right" target="resetButton" isOpen={this.state.isTooltip2Open} toggle={this.toggleTooltip2} delay={{show: 1250, hide: 0}}>
                      Reset
                  </Tooltip>
                  <Button variant="outline-light" size="sm" className="fa fa-compress" id="hold-releaseButton"></Button>
                  <Tooltip placement="right" target="hold-releaseButton" isOpen={this.state.isTooltip3Open} toggle={this.toggleTooltip3} delay={{show: 1250, hide: 0}}>
                      Hold/Release
                  </Tooltip>
                  <Button variant="outline-light" size="sm" className="fa fa-times" id="noActionButton"></Button>
                  <Tooltip placement="right" target="noActionButton" isOpen={this.state.isTooltip4Open} toggle={this.toggleTooltip4} delay={{show: 1250, hide: 0}}>
                      No Action
                  </Tooltip>

                  <ButtonDropdown id="difficultyDropdown" isOpen={this.state.isDropdown1Open} toggle={this.toggleDropdown1} className="mt-4" id="difficultyButton">
                      <DropdownToggle caret className="verticalText">
                          Difficulty
                      </DropdownToggle>
                      <DropdownMenu className="w-auto">
                          <DropdownItem className="border-bottom">Easy</DropdownItem>
                          <DropdownItem className="border-bottom">Medium</DropdownItem>
                          <DropdownItem>Hard</DropdownItem>
                      </DropdownMenu>
                  </ButtonDropdown>

                  <ButtonDropdown id="speedDropdown" isOpen={this.state.isDropdown2Open} toggle={this.toggleDropdown2} className="mt-5" id="speedButton">
                      <DropdownToggle caret className="verticalText">
                          Speed
                      </DropdownToggle>
                      <DropdownMenu>
                          <DropdownItem className="border-bottom">Wait</DropdownItem>
                          <DropdownItem className="border-bottom">Slow</DropdownItem>
                          <DropdownItem className="border-bottom">Medium</DropdownItem>
                          <DropdownItem>Fast</DropdownItem>
                      </DropdownMenu>
                  </ButtonDropdown>
              </ButtonGroup>
          </Collapse>
        </div>
      </Navbar>
  );
};

}

export default Controls;`

Complete template example

Do you have a complete example using the template charts, I can't seem to get anything displaying and there are no errors in the console.

Is there something else I'm supposed to be including? It is not clear from the template documentation if so.

import React from 'react';
import rd3 from 'react-d3-library';
const LineChart = rd3.LineChart;

class DGraph extends React.Component {
  render() {
    const dataObj = {};
    dataObj.dataset = [
      {time: '24-Apr-07', value: 93.24},
      {time: '25-Apr-07', value: 95.35 },
      {time: '26-Apr-07', value: 98.84 },
      {time: '27-Apr-07', value: 99.92 },
      {time: '28-Apr-07', value: 99.80 }
    ];
    dataObj.height = 350;
    dataObj.width = 750;
    dataObj.margins = {top: 20, right: 10, bottom: 0, left: 10};

    return (
      <div>
        <h1>D3 Graph</h1>
        <LineChart data={dataObj}/>
      </div>
    );
  }
}

export default DGraph;
  • "react": "^15.4.2"
  • "react-d3-library": "^1.1.7"
  • "d3": "3.5.17"

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.