Skip to content
Snippets Groups Projects
Commit 58d0c0f9 authored by Tibo's avatar Tibo
Browse files

bubble view : responsive (adapt to size of window)

parent a413d428
No related branches found
No related tags found
1 merge request!6Bubble view
...@@ -3,17 +3,26 @@ ...@@ -3,17 +3,26 @@
@section('content') @section('content')
<h1 class="text-center">{{ $label }}</h1> <h1 class="text-center">{{ $label }}</h1>
<svg width="1200" height="800"></svg> <div style="width: 100%; height: 800px" id="svg-container">
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.1.1/d3.min.js" integrity="sha512-COTaPOlz12cG4fSfcBsxZsjauBAyldqp+8FQUM/dZHm+ts/jR4AFoJhCqxy8K10Jrf3pojfsbq7fAPTb1XaVkg==" crossorigin="anonymous" referrerpolicy="no-referrer"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/d3/7.1.1/d3.min.js"
integrity="sha512-COTaPOlz12cG4fSfcBsxZsjauBAyldqp+8FQUM/dZHm+ts/jR4AFoJhCqxy8K10Jrf3pojfsbq7fAPTb1XaVkg=="
crossorigin="anonymous" referrerpolicy="no-referrer"></script>
<script> <script>
var url = "/app/ranking/{{ $label }}/json"; var url = "/app/ranking/{{ $label }}/json";
var container = document.getElementById("svg-container");
var svg = d3.select(container).append("svg");
d3.json(url).then( data => { d3.json(url).then( data => {
var colors = d3.scaleLinear().domain([0, 1]).range(["blue", "orange"]); var colors = d3.scaleLinear().domain([0, 1]).range(["blue", "orange"]);
var svg = d3.select("svg"); var width = container.clientWidth;
var width = +svg.attr("width"), var height = container.clientHeight;
height = +svg.attr("height");
svg.attr("width", width);
svg.attr("height", height);
console.log(width);
svg.attr("font-size", 11) svg.attr("font-size", 11)
.attr("font-family", "sans-serif") .attr("font-family", "sans-serif")
...@@ -27,8 +36,6 @@ ...@@ -27,8 +36,6 @@
.sum(d => d.score)) .sum(d => d.score))
const root = pack(data); const root = pack(data);
console.log(root);
const leaf = svg.selectAll("g") const leaf = svg.selectAll("g")
.data(root.leaves()) .data(root.leaves())
.join("g") .join("g")
...@@ -56,7 +63,7 @@ ...@@ -56,7 +63,7 @@
leaf.append("title") leaf.append("title")
.text(d => d.score); .text(d => d.score);
}); });
</script> </script>
@endsection @endsection
\ No newline at end of file
  • Tibo @tibo

    mentioned in issue #39

    ·

    mentioned in issue #39

    Toggle commit list
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment