Chart.js: trouble with resizing on window resize

时间:2015-05-12 22:44:31

标签: javascript jquery charts chart.js

With this code, my chart is resizing when I drag the window, but not when I press the maximize button on windows or the full screen button on mac. Is this just a chart.js problem? Here is my JS for resizing the chart.

import imp
ContemplateModulePath = os.path.join(os.path.dirname(__file__), '../src/python/')
try:
    ContemplateFp, ContemplatePath, ContemplateDesc  = imp.find_module('Contemplate', [ContemplateModulePath])
    Contemplate = getattr( imp.load_module('Contemplate', ContemplateFp, ContemplatePath, ContemplateDesc), 'Contemplate' )
except ImportError as exc:
    Contemplate = None
    sys.stderr.write("Error: failed to import module ({})".format(exc))
finally:
    if ContemplateFp: ContemplateFp.close()

if not Contemplate:
    print ('Could not load the Contemplate Engine Module')
    sys.exit(1)
else:    
    print ('Contemplate Engine Module loaded succesfully')

1 个答案:

答案 0 :(得分:0)

我从来没有调整过chart.js的问题,你也不需要订阅resize事件,因为resize已经由chart.js处理,具体取决于canvas容器的大小。当您使用此mac浏览工作chart.js网站时是否有此问题?

来自chartjs.org

  

如果浏览器更改大小,Chart.js将调整图表大小,同时为该大小提供完美的比例粒度

顺便看看你的控制台,$('##chart')不是一个有效的jQuery选择器,应该产生错误。我不知道你发布的代码是如何工作的。