Skip to content

Commit fba0034

Browse files
committed
Almost have the chart rendering...
1 parent 5f6969d commit fba0034

File tree

8 files changed

+25445
-0
lines changed

8 files changed

+25445
-0
lines changed
+38
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
layout: post
3+
title: D3 to React again
4+
---
5+
6+
<style>
7+
.axis path,
8+
.axis line {
9+
fill: none;
10+
stroke: #000;
11+
shape-rendering: crispEdges;
12+
}
13+
14+
.x.axis path {
15+
display: none;
16+
}
17+
18+
.line {
19+
fill: none;
20+
stroke: steelblue;
21+
stroke-width: 1.5px;
22+
}
23+
</style>
24+
25+
**This tool can be found at [Olical/react-faux-dom][].**
26+
27+
This is a continuation of my [previous experiment][prev], but this time I've built a fake DOM that you give to D3 to manipulate. So you can use your normal D3 methods and then turn the resulting node into React elements easily. This is more efficient and seamless than my previous approach. It should mean that most existing D3 components will work straight away when you swap the normal DOM element for the faux DOM.
28+
29+
The chart below is from the great [mbostock][orig-chart], I've just wrapped the D3 calls in a React component that renders into my faux DOM. Everything else has remained the same, it "just works".
30+
31+
<div id="mount"></div>
32+
33+
<script src="/js/d3-to-react-again/main.min.js"></script>
34+
35+
[particles]: http://bl.ocks.org/mbostock/1062544
36+
[Olical/react-faux-dom]: https://github.com/Olical/react-faux-dom
37+
[prev]: http://lab.oli.me.uk/d3-to-react/
38+
[orig-chart]: http://bl.ocks.org/mbostock/3883245

js/d3-to-react-again/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
node_modules/

js/d3-to-react-again/Makefile

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
default: bootstrap build
2+
3+
bootstrap:
4+
npm install
5+
6+
build:
7+
./node_modules/.bin/browserify ./main.js | ./node_modules/.bin/uglifyjs -c -m > main.min.js

0 commit comments

Comments
 (0)