All Projects → seliopou → Elm D3

seliopou / Elm D3

Licence: other
Elm bindings for D3.js

Programming Languages

javascript
184084 projects - #8 most used programming language

Labels

Projects that are alternatives of or similar to Elm D3

react-org-chart
Component for displaying an org chart for a large organization. Supports lazy load and export.
Stars: ✭ 147 (-55.86%)
Mutual labels:  d3
D3 Extended
Extends D3 with some common jQuery functions and more
Stars: ✭ 269 (-19.22%)
Mutual labels:  d3
Carbon Charts
📊 📈⠀Robust dataviz framework implemented using D3 & typescript
Stars: ✭ 287 (-13.81%)
Mutual labels:  d3
d3-sankey-circular
A fork of the d3-sankey library to allow circular links.
Stars: ✭ 65 (-80.48%)
Mutual labels:  d3
Floweaver
View flow data as Sankey diagrams
Stars: ✭ 266 (-20.12%)
Mutual labels:  d3
Realize
A React component tree visualizer
Stars: ✭ 285 (-14.41%)
Mutual labels:  d3
vue-d3-charts
D3 charts for Vue
Stars: ✭ 66 (-80.18%)
Mutual labels:  d3
Flask jsondash
🐍 📊 📈 Build complex dashboards without any front-end code. Use your own endpoints. JSON config only. Ready to go.
Stars: ✭ 3,215 (+865.47%)
Mutual labels:  d3
React Native Svg Charts Examples
A collection of usage examples of react-native-svg-charts
Stars: ✭ 266 (-20.12%)
Mutual labels:  d3
Recharts
Redefined chart library built with React and D3
Stars: ✭ 17,455 (+5141.74%)
Mutual labels:  d3
cryptoization
Data visualization application showing all BTC transactions in real-time
Stars: ✭ 12 (-96.4%)
Mutual labels:  d3
Plottable
📊 A library of modular chart components built on D3
Stars: ✭ 2,834 (+751.05%)
Mutual labels:  d3
Doctor
基于知识图谱的医学诊断系统。Medical Diagnosis System Based on Knowledge Map.
Stars: ✭ 286 (-14.11%)
Mutual labels:  d3
jelly-chart
Jelly-Chart is a chart library based on D3v4 and SVG.
Stars: ✭ 34 (-89.79%)
Mutual labels:  d3
Rumble Charts
React components for building composable and flexible charts
Stars: ✭ 293 (-12.01%)
Mutual labels:  d3
pdf2xml-viewer
A simple viewer and inspection tool for text boxes in PDF documents
Stars: ✭ 82 (-75.38%)
Mutual labels:  d3
D3 Funnel
A JavaScript library for rendering funnel charts using the D3.js framework.
Stars: ✭ 283 (-15.02%)
Mutual labels:  d3
D3 Cloud
Create word clouds in JavaScript.
Stars: ✭ 3,460 (+939.04%)
Mutual labels:  d3
Dtree
A library for visualizing data trees with multiple parents, such as family trees. Built on top of D3.
Stars: ✭ 308 (-7.51%)
Mutual labels:  d3
Victory Chart
Chart Component for Victory
Stars: ✭ 286 (-14.11%)
Mutual labels:  d3

elm-d3

elm-d3 provides Elm bindings for d3.js. It enables you to create type-safe, composable widgets using HTML, SVG, and CSS. D3 acts as a conceptual basis for the library, as well as an alternative renderer for Elm.

Installation

First make sure that you have node.js installed, as well as the Elm compiler. Once you've installed those dependencies, clone the elm-d3 repository and run the following command from the root directory:

elm-make

This will locally install the smash utility and build the library.

To get an example compiled and running in your browser, use the following command:

elm-make examples/Circles.elm --output circles.html

You must then edit the HTML file and add a <script> tag that will load the D3.js library. (Unfortunately, it is no longer possible to control linking of external JavaScript code using the Elm compiler, so this manual step is necessary.) Then, load it up on your browser:

open build/examples/circles.html

If you're not using OS X, the last command won't work. In that case open circles.html however you normally would in your operating system. Once the page is open, move your mouse left and right to add and remove circles, and move your mouse up and down to change their brightness.

Conceptual Prerequisites

In order to effectively use elm-d3, you should be familiar with the core concepts of D3.js, including data joins, nested selections, and reusable charts. The following series of blog posts by @mbostock introduce these concepts quite nicely, and independently of elm-d3 should be read by anybody that is interested in developing their D3.js skills:

Usage

elm-d3 is designed to be a very literal interpretation of the D3.js API. In fact, any D3.js code that uses only the Core Selection API should be fairly straightforward to port over to elm-d3. For example, here's a fragment of code taken from the Voronoi Diagram example (original D3.js version):

voronoi : D3 [D3.Voronoi.Point] [D3.Voronoi.Point]
voronoi =
  selectAll "path"
  |. bind cells
     |- enter <.> append "path"
     |- update
        |. fun attr "d" (\ps _ -> path ps)
        |. fun attr "class" (\_ i -> "q" ++ (show ((%) i 9)) ++ "-9")

Operations such as selectAll, enter, and attr have the same behavior as their D3.js counterparts. The bind operation is equivalent to the data() operator from D3.js, though it requires its argument to be a function. Similarly, attr also requires a function as its second argument, which takes the data bound to the element and the element's index in the selection. Another difference is that elm-d3 replaces method chaining with the |. operator. For example,

selectAll "path"
|. bind cells

is equivalent to

d3.selectAll("path")
  .data(cells)

Sequencing is another operation that's slightly different in elm-d3. In Javascript, there's a common pattern where you apply a data bound to a selection, assign it to a variable, and then apply enter(), update, and exit() operations to the variable. In place of sequencing, you would use the |- infix operator. Its use is illustrated in the example above. You can see the equivalent code in JavaScript below.

var path = d3.selectAll('path')
    .bind(function(d) { ... });

path.enter()
  .append('path');

path
    .attr('d', function(d) { ... })
    .attr('class', function(d) { ... });

Rendering

Creating a selection such as voronoi above does not actually draw anything to the screen. Rather, it defines a computation that the runtime knows how to draw to the screen. To do this, you use the render function. Its first two arguments are the height and width of the drawing area. The third is the D3 a b that will be rendered. The final argument is the datum of type a that will be bound to the selection. The result is an Element that the Elm runtime knows what to do with:

main : Element
main = render 800 600 voronoi [{x: 200, y: 200}, {x: 320, y:100}]

Further documentation

For more information about the API, the source file in src/D3.elm. Each function is preceded by a comment describing the equivalent expression in JavaScript. Types are also very instructive.

License

BSD3, see LICENSE file for its text.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].