Currently, I am facing an issue with my graphs. I have a line graph and a boxplot, but the boxplot is appearing below the line graph when I want it to be next to it. Any suggestions on how I can achieve this layout? Thank you!
I attempted to use 2 different SVGs, but that approach did not work for me. Here is the code snippet I tried:
<!DOCTYPE html>
<meta charset="utf-8">
<style>
.line {
fill: none;
stroke: url(#grad);
stroke-width: 2px;
}
.zoom {
cursor: move;
fill: none;
pointer-events: all;
}
</style>
<svg width="900" height="700">
</svg>
<script src="https://d3js.org/d3.v4.min.js"></script>
<script>
var svg = d3.select("svg"),
margin = {top: 90, right: 50, bottom: 100, left: 40},
margin2 = {top: 630, right: 50, bottom: 30, left: 40},
width = +svg.attr("width") - margin.left - margin.right,
height = +svg.attr("height") - margin.top - margin.bottom,
height2 = +svg.attr("height") - margin2.top - margin2.bottom;
...more code
</script>
//end of line graph
//beginning of boxplot
<!-- Load d3.js -->
<script src="https://d3js.org/d3.v4.js"></script>
<!-- Create a div where the graph will take place -->
<div id="svg2"></div>
<!-- To use the monochrome scale -->
<script src="https://d3js.org/d3-scale-chromatic.v1.min.js"></script>
<!-- Tooltip style -->
<style>
.tooltip {
background-color: black;
border: 1px black solid;
display: inline-block;
border-radius: 5px;
padding: 15px;
min-width: 1000px;
text-align: left;
color: white;
}
</style>
<script>
// set the dimensions and margins of the graph
var margin = {top: 70, right: 30, bottom: 50, left: 80},
width = 460 - margin.left - margin.right,
height = 400 - margin.top - margin.bottom;
...more code, end of boxplot
</script>