This example shows how an inline SVG tag can be used to embed dynamic graphics.
<svg id="mydvg">...</svg>
<script>
const mydvg = new dvg.DVG(document.getElementById('mysvg'))
mydvg.update({
values: [['Foo', 42]],
columns: ['Char', 'Num {{0..100|f:dollar}}'],
})
</script>
Change the names and values of the variables used by the graphic:
This example shows how an external svg can be used to embed dynamic graphics.
<div id="mydvg"></svg>
<script>
const mydvg = new dvg.DVG(
document.getElementById('mydvg'),
{ svg: 'path/to/file.svg' }
)
mydvg.update({
values: [['Foo', 42]],
columns: ['Char', 'Num {{0..100|f:dollar}}'],
})
</script>
Change the names and values of the variables used by the graphic below:
This example shows how a csv string can represent the data. Change CSV used by the graphic:
This example shows how a structured model represent the data.
<div id="mydvg"></svg>
<script>
const mydvg = new dvg.DVG(
document.getElementById('mydvg'),
{ svg: 'path/to/file.svg' }
)
mydvg.update({
values: [['Foo', 42]],
columns: ['Char', 'Num {{0..100}}'],
})
</script>
Change the names and values of the variables used by the graphic below:
Change the formats for numberic columns below:
If a DVG class is initialized with no element it will replace the body of the page. And if it is provided no URL to an svg it will look for "./index.svg".
<script>
const mydvg = new dvg.DVG()
mydvg.update({
values: [['Foo', 42]],
columns: ['Char', 'Num {{0..100|f:dollar}}'],
})
</script>
This can be convenient for cases where the entire page is an infographic. The link below is to a page using the defaults:
This example utilizes many of the features of the DVG library. Change the names and values of the variables used by the graphic below: