Skip to content

Commit

Permalink
ESM import of d3 in examples
Browse files Browse the repository at this point in the history
  • Loading branch information
vasturiano committed Dec 13, 2024
1 parent 50afbba commit 0fb5e91
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 16 deletions.
9 changes: 5 additions & 4 deletions example/flare/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<head>
<script src="//unpkg.com/d3"></script>

<script src="//unpkg.com/sunburst-chart"></script>
<!--<script src="../../dist/sunburst-chart.js"></script>-->

Expand All @@ -9,8 +7,11 @@
<body>
<div id="chart"></div>

<script>
const color = d3.scaleOrdinal(d3.schemePaired);
<script type="module">
import { scaleOrdinal } from 'https://esm.sh/d3-scale';
import { schemePaired } from 'https://esm.sh/d3-scale-chromatic';

const color = scaleOrdinal(schemePaired);

fetch('flare.json').then(res => res.json()).then(data => {
new Sunburst(document.getElementById('chart'))
Expand Down
9 changes: 5 additions & 4 deletions example/large-data/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<head>
<script src="//unpkg.com/d3"></script>

<script src="//unpkg.com/sunburst-chart"></script>
<!--<script src="../../dist/sunburst-chart.js"></script>-->

Expand All @@ -9,7 +7,10 @@
<body>
<div id="chart"></div>

<script>
<script type="module">
import { scaleOrdinal } from 'https://esm.sh/d3-scale';
import { schemePaired } from 'https://esm.sh/d3-scale-chromatic';

const CHILDREN_PROB_DECAY = 0.15; // per level
const MAX_CHILDREN = 20;
const MAX_VALUE = 100;
Expand All @@ -29,7 +30,7 @@
}
}

const color = d3.scaleOrdinal(d3.schemePaired);
const color = scaleOrdinal(schemePaired);

new Sunburst(document.getElementById('chart'))
.data(genNode())
Expand Down
9 changes: 5 additions & 4 deletions example/sort-by-size/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<head>
<script src="//unpkg.com/d3"></script>

<script src="//unpkg.com/sunburst-chart"></script>
<!--<script src="../../dist/sunburst-chart.js"></script>-->

Expand All @@ -9,7 +7,10 @@
<body>
<div id="chart"></div>

<script>
<script type="module">
import { scaleOrdinal } from 'https://esm.sh/d3-scale';
import { schemePaired } from 'https://esm.sh/d3-scale-chromatic';

const CHILDREN_PROB_DECAY = 0.5; // per level
const MAX_CHILDREN = 40;
const MAX_VALUE = 100;
Expand All @@ -29,7 +30,7 @@
}
}

const color = d3.scaleOrdinal(d3.schemePaired);
const color = scaleOrdinal(schemePaired);

new Sunburst(document.getElementById('chart'))
.data(genNode())
Expand Down
9 changes: 5 additions & 4 deletions example/truncate-labels/index.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
<head>
<script src="//unpkg.com/d3"></script>

<script src="//unpkg.com/sunburst-chart"></script>
<!-- <script src="../../dist/sunburst-chart.js"></script>-->

Expand All @@ -9,8 +7,11 @@
<body>
<div id="chart"></div>

<script>
const color = d3.scaleOrdinal(d3.schemePaired);
<script type="module">
import { scaleOrdinal } from 'https://esm.sh/d3-scale';
import { schemePaired } from 'https://esm.sh/d3-scale-chromatic';

const color = scaleOrdinal(schemePaired);

fetch('flare.json').then(res => res.json()).then(data => {
new Sunburst(document.getElementById('chart'))
Expand Down

0 comments on commit 0fb5e91

Please sign in to comment.