Skip to content

Instantly share code, notes, and snippets.

@mgold
mgold / SuperTimer.elm
Created February 12, 2016 14:40 — forked from shamrin/SuperTimer.elm
Restartable timer
module SuperTimer where
import Html exposing (..)
import Html.Events exposing (onClick)
import Time exposing (Time)
import Signal exposing (Address)
type Action = Tick Time | Toggle Bool | NoOp
type alias Model = { running: Bool, count: Float}
@mgold
mgold / README.md
Last active December 21, 2017 20:15 — forked from mbostock/.block
Multi-Series Line Chart Demoing Selection Groups

This is a fork of Mike Bostock's Multi-Series Line Chart, which adds circles along the line for each data point. The circles help anchor us to the real datapoints (rather than extrapolations) when comparing across lines.

But this is really an exercise in nested selections, leveraging selections as groups. The data consists of multiple lines, which each have multiple data points. We call .data twice: first with the data for all cities, binding the array for each city as a single datum. This is good enough for D3's line generators but not for placing circles. So we selectAll circles from the merged enter-update selection, and then bind the data for each line using a function, which is passed each datum from the prior join. This step produces a new data join, and you need to do it even if the function you pass is the identity. Since there are no circles, we skip straight to the enter selection and append them. Then we assign them x and y positions based on the accessor