Johnathan Johnathan - 5 months ago 17
CSS Question

I am trying to make the second bootstrap row fill the remaining height

I am building an ASP.NET app that connects to a SQL database. Here is a screen shot:

enter image description here

I would like:

1) My graph to take all the blank space (i.e. second row height)

2) Add padding to the graph, so the date on the right full shows

I must not see the obvious. Thank you for your help!

Here is my code:

<!DOCTYPE html>

<html>
<head>
<title></title>
<link href="css/nv.d3.css" rel="stylesheet" type="text/css">
<link href="Content/bootstrap.min.css" rel="stylesheet"/>
<link href="css/pikaday.css" rel="stylesheet" type="text/css" />
<link href="css/theme.css" rel="stylesheet" type="text/css" />
<link href="css/site.css" rel="stylesheet" type="text/css" />
<script src="scripts/Pikaday/moment.js" type="text/javascript" ></script>
<script src="scripts/Pikaday/pikaday.js" type="text/javascript"></script>
<script src="scripts/jquery-1.9.1.js"></script>
<script src="scripts/d3.min.js" charset="utf-8"></script>
<script src="scripts/nv.d3.min.js"></script>

<style>
.singleLabel{
min-height: 20px;
text-align: left;
font-size: large;
margin-bottom:2px;
}
.textBox{
border-left-width: 1px;
min-height: 20px;
text-align: center;
font-size: large;
margin-bottom:2px;
}
.textbox.dropDown{
text-align: right;
}
text {
font: 12px sans-serif;
}
html, body, #chart, svg{
margin: 0px;
padding: 0px;
height: 100%
width: 100%;
}
.nv-x text{
font-size: 20px;
}
.nv-y text{
font-size: 20px;
}
.nv-series text {
font-size: 20px;
}
.row {
font-size: 30px;
}
.column{

}
</style>
</head>

<body>
<form id="form1" runat="server">
<div class="row">&emsp;Report from:&emsp;
<asp:TextBox ID="startDate" runat="server" columns="6" style="border:1px solid #ff0000"></asp:TextBox>
&emsp;To&emsp;
<asp:TextBox ID="endDate" runat="server" columns="6" style="border:1px solid #ff0000"></asp:TextBox>
&emsp;<input type="button" id="btGO" value="Go!" />


<%-- Date picker for start and end --%>
<script = "text/javascript">
var picker = new Pikaday({
field: document.getElementById("startDate"),
firstDay: 1,
format: "YYYY-MM-DD",
minDate: new Date('2000-01-01'),
maxDate: new Date('2020-12-31'),
yearRange: [2000,2020],
numberOfMonths: 2
});
</script>

<script = "text/javascript">
var picker = new Pikaday({
field: document.getElementById("endDate"),
firstDay: 1,
format: "YYYY-MM-DD",
minDate: new Date('2000-01-01'),
maxDate: new Date('2020-12-31'),
yearRange: [2000,2020],
numberOfMonths: 2
});
</script>
</div>
<div class="row">
<div class="col-lg-12">
<div id="chart">
<svg></svg>
</div>
</div>
</div>
<script>
d3.json('https://cdn.rawgit.com/novus/nvd3.org/master/ghpages/stackedAreaData.json', function (data) {
nv.addGraph(function () {
var chart = nv.models.stackedAreaChart()
.x(function (d) { return d[0] })
.y(function (d) { return d[1] })
.clipEdge(true)
.useInteractiveGuideline(true);

chart.xAxis
.showMaxMin(true)
.tickFormat(function (d) { return d3.time.format('%x')(new Date(d)) });

chart.yAxis
.tickFormat(d3.format(',.0f'));

d3.select('#chart svg')
.datum(data)
.transition().duration(500).call(chart);

nv.utils.windowResize(chart.update);

return chart;
});
})
</script>
</form>

</body>
</html>

Answer

Try for the height something like a fixed value. I think <div id="chart"> is the chart you want to take up space vertical?

Try in your CSS:

div.chart {
    height: 80vh;
}

VH stands for viewport height. So it will take 80% of your screens height.

For the row you could just try

padding: 0 10px;

Or another value, just the padding you like.

Comments