Skip to content

Commit 89ef108

Browse files
craigloewen-msftkt3k
authored andcommitted
Fixed chart height determination issue number 2467 (#2541)
* Fixed chart height determination issue number 2467 * Added sample resize.html
1 parent 878933b commit 89ef108

File tree

3 files changed

+51
-4
lines changed

3 files changed

+51
-4
lines changed

htdocs/samples/resize.html

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
<html>
2+
3+
<head>
4+
<link href="../css/c3.css" rel="stylesheet" type="text/css">
5+
<style>
6+
.chartcontainer {
7+
background-color: #EEE;
8+
height: 80%;
9+
width: 90%;
10+
border: 1px solid black;
11+
}
12+
13+
#chart {
14+
height: 100%;
15+
}
16+
</style>
17+
</head>
18+
19+
<body>
20+
<h3>Please drag the window around to watch the chart resize.</h3>
21+
<div class="chartContainer">
22+
<div id="chart"></div>
23+
24+
</div>
25+
26+
<script src="https://d3js.org/d3.v5.min.js" charset="utf-8"></script>
27+
<script src="../js/c3.js"></script>
28+
<script>
29+
var chart = c3.generate({
30+
data: {
31+
bindto: '#chart',
32+
columns: [
33+
['data1', 30, 200, 100, 400, 150, 250],
34+
['data2', 130, 100, 140, 200, 150, 50]
35+
],
36+
types: {
37+
data1: 'spline',
38+
data2: 'spline'
39+
}
40+
},
41+
spline: {
42+
interpolation: {
43+
type: 'monotone', // 'cardinal' is default
44+
},
45+
},
46+
});
47+
</script>
48+
</body>
49+
50+
</html>

src/core.js

-2
Original file line numberDiff line numberDiff line change
@@ -919,8 +919,6 @@ ChartInternal.prototype.updateSvgSize = function() {
919919
$$.svg.select('#' + $$.clipIdForSubchart).select('rect')
920920
.attr('width', $$.width)
921921
.attr('height', brush.size() ? brush.attr('height') : 0);
922-
// MEMO: parent div's height will be bigger than svg when <!DOCTYPE html>
923-
$$.selectChart.style('max-height', $$.currentHeight + "px");
924922
};
925923

926924
ChartInternal.prototype.updateDimension = function(withoutAxis) {

src/size.js

+1-2
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@ ChartInternal.prototype.getParentWidth = function () {
7373
return this.getParentRectValue('width');
7474
};
7575
ChartInternal.prototype.getParentHeight = function () {
76-
var h = this.selectChart.style('height');
77-
return h.indexOf('px') > 0 ? +h.replace('px', '') : 0;
76+
return this.getParentRectValue('height');
7877
};
7978

8079

0 commit comments

Comments
 (0)