Chart.js 画布调整大小 [英] Chart.js canvas resize

查看:37
本文介绍了Chart.js 画布调整大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在(Android WebView HTML5 画布错误)中,我发布了一个关于绘图的问题使用 Graph.js 库.我现在遇到的问题是,如果我多次调用该函数来绘制图形,则画布每次都会调整大小.每次将图形重新绘制到同一画布上时,其大小也会发生变化.我也尝试过设置画布的大小,但没有成功.

In (Android WebView HTML5 canvas error) i posted a question regarding plotting graphs using Graph.js library. The problem i have now is that if i call the function to plot the graph multiple times, the canvas resizes every time. Each time the graph is redrawn to the same canvas, its size also changes. I also tried setting the size of the canvas but without success.

可能是什么原因?为什么画布每次都调整大小?

What could be the reason? Why does the canvas resize every time?

推荐答案

我遇到了很多问题,因为毕竟当鼠标悬停时我的线条图形看起来很糟糕,我找到了一种更简单的方法来做到这一点,希望它会有所帮助:)

I had a lot of problems with that, because after all of that my line graphic looked terrible when mouse hovering and I found a simpler way to do it, hope it will help :)

使用这些 Chart.js 选项:

Use these Chart.js options:

// Boolean - whether or not the chart should be responsive and resize when the browser does.

responsive: true,

// Boolean - whether to maintain the starting aspect ratio or not when responsive, if set to false, will take up entire container

maintainAspectRatio: false,

这篇关于Chart.js 画布调整大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆