You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

45 lines
1.4 KiB

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://unpkg.com/chart.js@2.8.0/dist/Chart.bundle.js"></script>
<script type="text/javascript" src="https://unpkg.com/vue@2.5.13/dist/vue.js"></script>
<script src="https://www.gstatic.com/charts/loader.js"></script>
<script src="https://unpkg.com/chartkick@2.3.3"></script>
<script src="https://unpkg.com/vue-chartkick@0.2.1/dist/vue-chartkick.js"></script>
<style type="text/css">
</style>
<title>vuepie</title>
</head>
<body>
<div id="app">
<column-chart :data="chartData" :download="true" legend="bottom" label="Value"></line-chart>
</div>
<script>
new Vue({
el: '#app',
data: {
chartData: [{ "name": "Workout", "data": { "bla": 3, "blub": 4 } }, { "name": "ja", "data": { "linux": 5, "aws": 3 } }]
},
beforeMount(){
const dataRegexp = /data=(.*)/
let match = dataRegexp.exec(document.URL)
if (match) {
if (match.length === 2) {
try {
match = match[1].replace(/%22/g,'"')
this.chartData = JSON.parse(match)
} catch(e) {
console.error(match[1])
console.error('failed to treat input string as a json object')
}
}
}
}
})
</script>
</body>
</html>