@flourish/chart-layout
Advanced tools
Comparing version 2.0.0 to 2.0.1
{ | ||
"name": "@flourish/chart-layout", | ||
"version": "2.0.0", | ||
"version": "2.0.1", | ||
"description": "Create axes", | ||
@@ -5,0 +5,0 @@ "main": "chart-layout.js", |
@@ -97,13 +97,13 @@ # Flourish chart layout | ||
These two methods get d3-scales suitable for plotting data. Because this module uses SVG transforms then, in general by default, the scale will be useful for plotting data only within the `chart_layout.chart` container, and particularly the `chart_layout.data_background` or `chart_layout.data_foreground` containers. However, if the `form` object is present and has a `global` property that is truthy, the scale is suitable for use outside the `chart_layout.chart` object (and, generally, not inside it), anywhere that has the same calculated transform as `chart_layout.container`. The `domain_only` property of `form` specifies that a suitable range for the scale should not be calculated. This can be useful if you want to extract the domain for one axis before you specify the data for the other. | ||
These three methods get d3-scales suitable for plotting data. Because this module uses SVG transforms then, in general by default, the scale will be useful for plotting data only within the `chart_layout.chart` container, and particularly the `chart_layout.data_background` or `chart_layout.data_foreground` containers. However, if the `options` object is present and has a `global` property that is truthy, the scale is suitable for use outside the `chart_layout.chart` object (and, generally, not inside it), anywhere that has the same calculated transform as `chart_layout.container`. The `domain_only` property of `options` specifies that a suitable range for the scale should not be calculated. This can be useful if you want to extract the domain for one axis before you specify the data for the other. | ||
### `chart_layout.xScale([form])` | ||
### `chart_layout.xScale([options])` | ||
Gets a scale function for calculating x-coordinates. | ||
### `chart_layout.yScale([form])` | ||
### `chart_layout.yScale([oprions])` | ||
Gets a scale function for calculating primary y-coordinates. | ||
### `chart_layout.y2Scale([form])` | ||
### `chart_layout.y2Scale([options])` | ||
@@ -110,0 +110,0 @@ Gets a scale function for calculating secondary y-coordinates. |
@@ -0,1 +1,4 @@ | ||
# 2.0.1 | ||
* Fix global option for scales | ||
# 2.0.0 | ||
@@ -2,0 +5,0 @@ * Add background object |
@@ -85,4 +85,4 @@ import { scaleLinear, scaleLog, scalePoint } from "d3-scale"; | ||
function initXScale(instance, state) { | ||
return function(form) { | ||
form = form || {}; | ||
return function(opts) { | ||
opts = opts || {}; | ||
var xScale; | ||
@@ -97,7 +97,7 @@ var x_data = instance.xData(); | ||
} | ||
if (form.domain_only) return xScale; | ||
if (opts.domain_only) return xScale; | ||
var x_width = instance.plot_width; | ||
var left_margin = instance.margins.left; | ||
var range = [ left_margin, left_margin + x_width ]; | ||
var offset = form === "global" && instance.offsetLeft(); | ||
var offset = opts.global && instance.offsetLeft(); | ||
if (offset) range = range.map(function(x) { return x + offset; }); | ||
@@ -111,4 +111,4 @@ return xScale.range(range); | ||
var y = state.y; | ||
return function(form) { | ||
form = form || {}; | ||
return function(opts) { | ||
opts = opts || {}; | ||
var yScale; | ||
@@ -123,7 +123,7 @@ var y_data = instance.yData(); | ||
} | ||
if (form.domain_only) return yScale; | ||
if (opts.domain_only) return yScale; | ||
var y_height = instance.plot_height; | ||
var top_margin = instance.margins.top; | ||
var range = [ top_margin, top_margin + y_height ]; | ||
var offset = form === "global" && instance.offsetTop(); | ||
var offset = opts.global && instance.offsetTop(); | ||
if (offset) range = range.map(function(y) { return y + offset; }); | ||
@@ -137,4 +137,4 @@ return yScale.range(range.reverse()); | ||
var y = state.y2; | ||
return function(form) { | ||
form = form || {}; | ||
return function(opts) { | ||
opts = opts || {}; | ||
var yScale; | ||
@@ -149,7 +149,7 @@ var y_data = instance.y2Data(); | ||
} | ||
if (form.domain_only) return yScale; | ||
if (opts.domain_only) return yScale; | ||
var y_height = instance.plot_height; | ||
var top_margin = instance.margins.top; | ||
var range = [ top_margin, top_margin + y_height ]; | ||
var offset = form === "global" && instance.offsetTop(); | ||
var offset = opts.global && instance.offsetTop(); | ||
if (offset) range = range.map(function(y) { return y + offset; }); | ||
@@ -156,0 +156,0 @@ return yScale.range(range.reverse()); |
Sorry, the diff of this file is too big to display
314625