score:1
Accepted answer
You should use the width and height instead of the canvasWidth and canvasHeight values for the ranges:
var xSVG = d3.scaleTime()
.range([0, width]);
var x = d3.scaleTime()
.range([0, width]);
var x2 = d3.scaleTime() // for zooming
.range([0, width]);
var ySVG = d3.scaleLinear()
.range([height, 0]);
var y = d3.scaleLinear()
.range([height, 0]);
In the draw logic, you can add a context.scale(2, 2) to draw everything twice as big. Again, swap all canvasWidth & canvasHeight values with width & height, as the context.scale will take care of the rest
function draw() {
context.save();
context.scale(2, 2);
context.clearRect(0, 0, width, height);
// clip path
context.beginPath()
context.rect(0, 0, width, height);
context.clip();
for (i=0; i<len; i++) {
context.beginPath();
area(sources[i].values);
context.fillStyle = color(sources[i].id);
context.fill();
}
context.restore();
}
Source: stackoverflow.com
Related Query
- d3: combining canvas + svg for retina
- HTML5 SVG vs Canvas for big number of lines?
- Pattern for using Meteor with advanced SVG or Canvas Ouput
- SVG vs Canvas for a "wind" chart
- Difference between svg and canvas in d3.js
- Title Attribute not working for an SVG Rect on Safari
- HTML5 canvas alternatives for d3.js, graph visualization library
- Auto width and height for SVG image
- Append SVG canvas to element other than body using D3
- SVG to Canvas with d3.js
- CSS padding property for svg elements
- how to use svg file for image source in D3
- maximum number of svg elements for the browser in a map
- D3 multi-line tooltip for SVG element
- dagre-d3 IE workaround for SVG foreignObject element?
- Javascript event listener for SVG transform
- Add region around SVG path for mouseover
- Suitable library for combining with D3js , to allowing drawing to webgl (2D)
- C3.js SVG visualization to Canvas with canvg - Line charts filled with black rectangles , "ERROR: Element 'parsererror' not yet implemented"
- D3: Zooming/Panning Line Graph in SVG is not working in Canvas
- Dual x-axes for line-graphs in SVG
- Angular svg or canvas to use colour gradients
- how to center SVG canvas in the window d3.js
- D3.js SVG drop shadow for fast transitions
- Deleting d3 svg elements for redraw
- How to get background color of SVG converted properly into Canvas
- Custom mouse interaction for SVG layer in Google Maps
- CSS transform-origin not working for svg in safari
- D3.js implement ellipsis for axis labels SVG
- Canvas image data on retina display (MPB)
More Query from same tag
- d3 force layout nodes always start at top-left of screen
- Multiple Y axis and paths in different scales
- D3 add more than one functions to an eventlistener
- D3 line graph mouseover issue
- d3-driven directive transition doesn't work inside ng-repeat
- Sort bars on nvd3 charts
- Unable to display a polygon using d3
- Using D3.js with NodeJs and Express
- Why do I get an attribute y="NaN" and height="NaN" in my d3.js stacked bar chart?
- programmatically access a d3 rectangle on click event
- What is the best way to create blocks of items in D3.JS
- d3.js draw line source and target is different (from an arc generated by d3.svg.arc() to the nodes with Cardinal position)
- Pass current element index to a function in D3
- dc.js chart redrawing with new group function with click event
- React native with d3 and webView
- Why is my D3.js tooltip not working
- D3 translation relative to rotation
- More efficient way to handle Mouseevent
- Appending clip path in d3js v4
- Closure or prototype model for charting library
- d3.js / CoffeeScript: Access execution context (this) of both class and path in mouseover
- D3: Stacked bar chart exit().remove() not removing bars
- javascript d3.js: initialize brush with brush.extent and stop data from spilling over margin
- D3JS - Horizontal highlight on scatter plot
- R Shiny HTML object is rendered on every tabPanel()
- Taking time duration in json
- D3 Mouseover for multiple elements
- Complex Tallies / Aggregation dc.js
- How to add fix vertical axis to focus + context zooming timeseries
- Specifying style of node through function