4

Whenever I am setting height and width of ZingChart in percentage, so that it's compatible with all screen sizes, it has no effect. Example: If I set 1% height and 1% width, nothing as such happens. I am changing height and width as:

zingchart.render({ 
id : 'myChart', 
data : myConfig, 
height: '1%', 
width: '1%' 
 });

You can view the complete code here: http://jsfiddle.net/xbh2ap18/

4

1 回答 1

7

ZingChart 的高度和宽度继承自您要附加到的父容器。实际图表是 myChart 的子图表,因此您需要将 css 应用于您的容器。

zingchart.render({
  id  : 'myChart',
  data : {
    type:"line",
    series :[
      { values : [1,2,3,4] } 
    ]
  },
  height: "100%",
  width: "100%"
  
});
html,body,#myChart{
  height: 100%;
  width: 100%;
}
<!DOCTYPE html>
<html>
	<head>
		<script src= "https://cdn.zingchart.com/zingchart.min.js"></script>

	</head>
	<body>
		<div id='myChart'></div>
	</body>
</html>

于 2015-10-16T15:33:12.917 回答