Skip to content

Commit

Permalink
docs: replace d3-zoom with d3fc-domain-zoom
Browse files Browse the repository at this point in the history
  • Loading branch information
cprice-scottlogic authored and chrisprice committed Oct 14, 2020
1 parent 94445e5 commit 344b468
Show file tree
Hide file tree
Showing 7 changed files with 5 additions and 18 deletions.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes
19 changes: 3 additions & 16 deletions examples/diamonds/index.js
Expand Up @@ -6,15 +6,9 @@ d3.tsv('diamond-data.tsv', d => ({
const yExtent = fc.extentLinear().accessors([d => d.price]);

const xScale = d3.scaleLog().domain(xExtent(data));
const xScaleCopy = xScale.copy();
const yScale = d3.scaleLog().domain(yExtent(data));
const yScaleCopy = yScale.copy();

const zoom = d3.zoom().on('zoom', event => {
xScale.domain(event.transform.rescaleX(xScaleCopy).domain());
yScale.domain(event.transform.rescaleY(yScaleCopy).domain());
render();
});
const zoom = fc.zoom().on('zoom', render);

const gridlines = fc.annotationSvgGridline();

Expand All @@ -23,10 +17,7 @@ d3.tsv('diamond-data.tsv', d => ({
.crossValue(d => d.carat)
.mainValue(d => d.price)
.size(d =>
Math.pow(
Math.max(2, xScaleCopy(d.carat + 0.01) - xScaleCopy(d.carat)),
2
)
Math.pow(Math.max(2, xScale(d.carat + 0.01) - xScale(d.carat)), 2)
)
.type(d3.symbolSquare)
.defined(() => true)
Expand Down Expand Up @@ -67,11 +58,7 @@ d3.tsv('diamond-data.tsv', d => ({
.enter()
.select('.webgl-plot-area')
.raise()
.on('measure.range', event => {
xScaleCopy.range([0, event.detail.width]);
yScaleCopy.range([event.detail.height, 0]);
})
.call(zoom);
.call(zoom, xScale, yScale);
});

function render() {
Expand Down
4 changes: 2 additions & 2 deletions site/index.html
Expand Up @@ -112,8 +112,8 @@ <h2>Featured Examples</h2>
<img src="https://d3fc.io/examples/brush-zoom/screenshot.png" />
Brush Zoom
</a>
<a href="https://d3fc.io/examples/chart-zoom/">
<img src="https://d3fc.io/examples/chart-zoom/screenshot.png" />
<a href="https://d3fc.io/examples/chart-d3fc-zoom/">
<img src="https://d3fc.io/examples/chart-d3fc-zoom/screenshot.png" />
Chart Zoom
</a>
<a href="https://d3fc.io/examples/stacked-bar-chart/">
Expand Down

0 comments on commit 344b468

Please sign in to comment.