Граф коммитов

48 Коммитов

Автор SHA1 Сообщение Дата
Mike Bostock c6c70d4730 Use d3.quantile in d3.chart.box. 2011-07-09 16:03:07 -07:00
Mike Bostock 0eb59e7c98 Merge branch 'horizon' into release 2011-05-27 14:58:06 -07:00
Mike Bostock 98ef2d185f Prefer style over attr. 2011-05-26 21:15:28 -07:00
Mike Bostock c75ebe10a9 Transitions for horizon bands! 2011-05-26 00:10:14 -07:00
Mike Bostock a15165398d Horizon chart improvements.
Use width and height attributes instead of size, for consistency with other
chart templates. (Though, note that chart templates are inconsistent with
layouts in this regard, which use a size property. But let's remain locally
consistent for now.) Default x and y properties to [0] and [1] to match the
defaults of d3.svg.area.

Add support for mode and interpolate properties. The mode can be either "offset"
or "mirror", with the default being "offset". The interpolate property is the
same as that used by d3.svg.area, and defaults to "linear".

The horizon chart now properly clips the horizon layers, such that if a horizon
chart is use within a larger SVG element, it will not extend the chart bounds.
In addition, this commit fixes a bug in how unique IDs are assigned to the clip
and area paths; it's a shame that SVG does not support a way to refer to paths
locally.

Note that because negative values are offset or mirrored, the horizon chart will
render twice as many paths (use elements) as the requested number of bands. For
example, if the default bands of 1 is used, there will be one negative band and
one positive band. In the data has no negative values, then the negative band
will be empty. Keep this in mind as it affects the layer's class attribute
(such as "q0-3" and "q2-3" for the default single-band horizon).
2011-05-22 11:26:46 -07:00
Jason Davies a462483b57 More sensible defaults for d3.chart.horizon.{x,y}. 2011-05-21 21:29:43 +01:00
Jason Davies 5e606729a4 Add reusable horizon chart.
Still to do: support negative values (offset or mirror modes).

Fixes #152.
2011-05-21 10:24:23 +01:00
Mike Bostock a5586726f0 Merge branch 'master' into jasondavies-immediate-transitions 2011-04-30 21:53:01 -07:00
Mike Bostock 1893d286e7 Rename `immediate` to `flush`. 2011-04-30 21:52:14 -07:00
Mike Bostock 71622b7cdb Improvements to qq chart. 2011-04-30 21:16:58 -07:00
Jason Davies 8e0bc6342f Add d3.timer.immediate() for immediate transitions.
This applies any queued zero-delay d3.timer callbacks immediately.  This is
useful in situations where zero-duration transitions are used e.g. in generic
visualisations that have a configurable transition duration.

It's often desirable to have zero-duration transitions for the initial setup
phase (so that the visualisation displays immediately).  Immediate application
(rather than waiting for the setTimeout callback to fire) avoids a delay of some
milliseconds as well as an extra redraw.

See issue #48.
2011-04-28 00:33:09 +01:00
Jason Davies 07674c286f Add x- and y-scales to Q-Q plot. 2011-04-25 12:59:11 +01:00
Jason Davies 82153e60b5 Add Q-Q plot. 2011-04-25 11:44:34 +01:00
Mike Bostock 4356e4fb21 Fix some ordering issues with transitions.
By default, `append` will go to the end. This could cause the center line to be
rendered on top of the box rect if whiskers were removed then re-added. By using
the `insert` operator, we can preserve the correct order.
2011-04-13 23:28:04 -07:00
Mike Bostock 222629a7a7 Text transitions.
You can now use the `text` operator on transitions, which has the same effect as
setting the text value at the start of the transition. This is nice if you have
a delayed transition, and avoids a common gotcha.

This commit also simplifies the implementation of the `text` operator using the
standard `textContent` property. This isn't supported on IE8-, but we could
potentially add support in the future using `innerText`.
2011-04-13 18:50:26 -07:00
Mike Bostock c29d4dc1a7 Better box chart transitions.
Preserving object constancy across transitions is tricky! For example, what
happens if we remove the whiskers in a transition? How do we join outliers? This
commit makes a few assumptions explicit:

1. The `quartiles` function must return exactly three elements. This property
must be specified as a function.

2. The `whiskers` function must return exactly 2 elements, or null if no
whiskers are to be displayed. This property must be specified as a function.

3. The `domain` function must return exactly 2 elements, or null if the default
domain should be used. This property can be specified either as a constant or as
a function.

We could generalize this chart to support more than two whiskers, but it doesn't
seem urgent, and it would complicate the transition if the number of whiskers
changes. In a related change, the `whiskers` function does not receive a third
argument containing the quartiles; instead, this is made available by the
`quartiles` property on the values array (the first argument).

The outliers are joined using the `Number` key function. The outlier data is now
stored as indices; this allows reasonable object constancy across transitions
with outliers. Similarly, the tick labels for the quartiles are whiskers are now
separated, such that the whisker labels can be added or removed without spurious
transition.
2011-04-13 17:44:20 -07:00
Jason Davies 12663738d9 Fix quartile calculation.
The outliers were being incorrectly excluded when computing the quartiles.  I've
also added a +/-1.5 IQR whiskers computation for the Morley-Michelson example,
so it replicates the R plot exactly.
2011-04-13 23:40:00 +01:00
Jason Davies e7d359ea6c Optimise; and fix typo. 2011-04-13 23:27:25 +01:00
Jason Davies 0b8aa07ed2 Rename "boxplot" to "box". 2011-04-13 22:31:53 +01:00
Jason Davies 54756f4d32 Fix central dashed line. 2011-04-13 22:29:44 +01:00
Jason Davies d288e69016 Remove `outlierSymbol` property.
Circles are simpler.
2011-04-13 22:27:25 +01:00
Jason Davies b693e0514e Make quartiles computation configurable.
The `quartiles` property takes the sorted data array (excluding outliers) and
returns the three quartiles.
2011-04-13 22:21:29 +01:00
Jason Davies 9721e6f045 Display outliers.
The symbol can be specified using the `outlierSymbol` property, which specifies
the `d` attribute for an SVG path.
2011-04-13 21:59:37 +01:00
Jason Davies 755529dba8 Add `whiskers` property to box plot.
This specifies a function that takes the sorted data array, and returns an array
of datum positions that should marked with whiskers.  The default implementation
is to return `[0, length-1]` i.e. the minimum and maximum.

Data outside of the whiskers are considered outliers, and are not included in
the quartile calculation.
2011-04-13 21:23:49 +01:00
Jason Davies 9518fec14a Replace `sort` property with `value`.
Much more useful, as we'll always want to sort by ascending value anyway.
2011-04-13 20:39:12 +01:00
Jason Davies 8fc521cb02 Add function support to the `domain` property.
This allows us to specify different domains across multiple box plots.  Thanks
Mike for the suggestion!
2011-04-13 20:35:33 +01:00
Jason Davies 5719f19223 Make boxplot sort configurable. 2011-04-13 20:14:29 +01:00
Jason Davies 2e8cd200df Add boxplot chart. 2011-04-13 19:57:57 +01:00
Mike Bostock bf180dc9af Fix a transition bug in bullet chart.
We were computing the tick join based on the (new) format function, but doesn't
produce the desired effect: the new format is applied on the old data. Thus, the
wrong join occurs if, say, the value 0.5 with the new format results in "0". The
correct join compares the old text content to the new format value.
2011-04-09 13:56:28 -07:00
Mike Bostock acb5fbe9cc Separate scales per bullet.
Rather sharing the x-scale across bullet multiples, compute a separate scale per multiple. This
gives the user more control over the scale: by setting the range values across multiples (in data),
the user can precisely control the resulting scales. For transitions, we cache the old scale value
in a hidden __chart__ attribute. This is a bit of a hack (it might be cleaner to persist it in the
data of a child element), but it might provide a sticky way for charts to communicate with each
other in the future, say for performing transitions across chart types.
2011-04-09 10:43:09 -07:00
Jason Davies ef7b5ccb3c Push bullet chart state into ticks element data.
This means chart state (the original x-scale) is no longer bound to the
chart instance, so a single instance can be reused on multiple elements.
2011-04-09 16:41:26 +01:00
Michael Bostock 5e42387a05 Use the x-scale's tick format by default. 2011-04-08 15:35:26 -07:00
Michael Bostock 33260423a3 Extract title & subtitle from bullet chart.
It's nice, but I think it's a bit more flexible to not have it as part of the
chart specification. This way, people can define titles however they like. It
might be nice to take a similar approach with reference ticks in the future.
2011-04-08 14:40:29 -07:00
Jason Davies e1399b1182 Another minor optimisation. 2011-04-08 19:17:09 +01:00
Jason Davies 3e63dead40 Minor optimisation and avoid variable shadow. 2011-04-08 19:15:55 +01:00
Jason Davies c7835ba4c8 Use reversed scales instead of startpos/pos. 2011-04-08 19:12:18 +01:00
Jason Davies 598f47e1c9 Simplify bullet charts as per Mike's suggestions. 2011-04-08 18:37:59 +01:00
Jason Davies 21c7ec3c26 Bullet charts: title and subtitle support. 2011-04-08 11:24:51 +01:00
Jason Davies 6aba18bc61 Bullet charts: support for "right" orientation. 2011-04-08 10:54:12 +01:00
Michael Bostock 1b1a9485cb Bullet chart transitions.
We now preserve object constancy for ticks across transitions. By caching a
reference to the previous x-scale, we can initialize entering objects in the
correct location, then transition them to the new scale as they fade in. Also,
we use the `map` operator to convert the data to a standard representation that
is suitable for the bullet chart, and compute derivate data needed across
multiples.
2011-04-07 16:57:33 -07:00
Jason Davies 7fba63734f Minor optimisation. 2011-04-07 22:38:50 +01:00
Jason Davies 34ffbbf1d0 Define bullet chart duration as property. 2011-04-07 22:36:25 +01:00
Jason Davies 34a055adc4 Add optional duration for bullet chart transitions. 2011-04-07 22:29:04 +01:00
Jason Davies f0f146715d Bullet charts: add transitions for dynamic data. 2011-04-07 19:39:43 +01:00
Jason Davies 28c54a822f Bullet charts: support dynamic data. 2011-04-07 19:32:48 +01:00
Jason Davies 73de44469b Add example and fixes for bullet multiples. 2011-04-07 18:54:31 +01:00
Jason Davies 344d7da26d Use bound data for bullet chart.
As per Mike's suggestion.
2011-04-07 18:39:35 +01:00
Jason Davies edf75a3c36 Move bullet to new `chart` module. 2011-04-07 17:54:03 +01:00