Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scaling problem #70

Closed
Erwin4 opened this issue Mar 21, 2016 · 1 comment
Closed

Scaling problem #70

Erwin4 opened this issue Mar 21, 2016 · 1 comment

Comments

@Erwin4
Copy link

Erwin4 commented Mar 21, 2016

Hey i was using your library for a little project and i just couldn't get the chart to fit in the container. This was only when the container was set with a percentage. When i used absolute numbers there wasn't an issue.

After exploring a little bit through your library i found that it couldn't get the height and width attributes.

I fixed the problem by just getting the width and height from the id's, but this ofcourse isn't a fix for the library.

In Smoothiechart.prototyppe.resize = function() -at line 438

var dpr = window.devicePixelRatio;
//var width = parseInt(this.canvas.getAttribute('width')); //getting NaN
//var height = parseInt(this.canvas.getAttribute('height')); //getting NaN

var width = document.getElementById("chart-div").width; //added these as a fix
var height = document.getElementById("chart-div").height; //added these as a fix

if (!this.originalWidth || (Math.floor(this.originalWidth * dpr) !== width)) {
  this.originalWidth = width;
  this.canvas.setAttribute('width', (Math.floor(width * dpr)).toString());
  this.canvas.style.width = width + 'px';
  this.canvas.getContext('2d').scale(dpr, dpr);
}

if (!this.originalHeight || (Math.floor(this.originalHeight * dpr) !== height)) {
  this.originalHeight = height;
  this.canvas.setAttribute('height', (Math.floor(height * dpr)).toString());
  this.canvas.style.height = height + 'px';
  this.canvas.getContext('2d').scale(dpr, dpr);
}
drewnoakes added a commit that referenced this issue May 2, 2017
The old behaviour (still the default) is to size the element to
the canvas size. This doesn't work with dynamically sized,
responsive applications.

See issues #64, #70, #78, #81
drewnoakes added a commit that referenced this issue May 2, 2017
When selected, size canvas to its element size.

The old behaviour (still the default) is to size the element to
the canvas size. This doesn't work with dynamically sized,
responsive applications.

Closes issues #64, #70, #78, #81
@drewnoakes
Copy link
Collaborator

This is now supported. See http://smoothiecharts.org/examples/responsive.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants