Quite good looking graph derived from d3.js http://c3js.org
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.

216 lines
4.4 KiB

<html>
<head>
<link rel="stylesheet" type="text/css" href="/css/c3.css">
10 years ago
<style>
.c3-region-1 {
fill: #dd3333;
fill-opacity: 0.8
}
</style>
</head>
<body>
<div id="chart"></div>
<script src="http://d3js.org/d3.v3.min.js" charset="utf-8"></script>
<script src="/js/c3.js"></script>
<script>
10 years ago
var padding = {}, chart, generate = function () { return c3.generate({
data: {
columns: [
10 years ago
['data1'],
['data2'],
],
types: {
data2: 'area',
data3: 'bar',
},
labels: true
},
bar: {
width: 10
},
axis: {
x: {
10 years ago
padding: padding
},
y: {
/*
min: -100,
max: 1000
*/
}
10 years ago
},
grid: {
x: {
show: true,
lines: [{value: 3, text:'Label 3'}, {value: 4.5, text: 'Label 4.5'}]
10 years ago
},
y: {
show: true
}
10 years ago
},
regions: [
{start:2, end:4, class:'region1'},
{start:100, end:200, axis:'y'},
],
});
10 years ago
};
10 years ago
function run() {
10 years ago
chart = generate();
setTimeout(function () {
10 years ago
// Load only one data
chart.flow({
columns: [
['data1', 500, 200, 100],
['data2', 100, null, 50],
['data3', 200, null, null],
],
10 years ago
duration: 1500,
10 years ago
onend: function () {
// Load 2 data without data2 and remove 1 data
chart.flow({
columns: [
['data1', 200, 300],
['data3', 100, 100]
],
length: 0,
10 years ago
duration: 1500,
onend: function () {
10 years ago
chart.flow({
columns: [
['data1', 200, 300],
['data2', 200, 300],
['data3', 100, 100]
],
length: 2,
duration: 1500,
onend: function () {
chart.flow({
columns: [
['data1', 500],
['data2', 100],
['data3', 200]
],
length: 1,
duration: 1500,
});
}
});
}// onend
10 years ago
});
},
10 years ago
});
}, 1000);
setTimeout(function () {
chart.flow({
columns: [
['data1', 250],
['data2', 350],
['data3', 150]
],
length: 0
});
}, 9000);
10 years ago
setTimeout(function () {
chart.flow({
columns: [
['data1', 100],
['data2', 50],
['data3', 300]
],
length: 2
});
}, 10000);
10 years ago
setTimeout(function () {
chart.flow({
columns: [
['data1', 600],
['data2', 400],
['data3', 500]
],
to: 2,
});
}, 11000);
10 years ago
setTimeout(function () {
chart.flow({
columns: [
['data1', 100],
['data2', 200],
['data3', 300]
]
});
}, 12000);
10 years ago
setTimeout(function () {
chart = generate();
}, 13000);
10 years ago
setTimeout(function () {
chart.flow({
columns: [
['data1', 500, 100],
['data2', 100, 200],
['data3', 200, 300],
],
duration: 1500,
onend: function () {
chart.flow({
columns: [
['data1', 200],
['data3', 100]
],
10 years ago
// duration: 1000,
length: 1
});
},
});
}, 14000);
setTimeout(function () {
chart.flow({
columns: [
['data1', 200],
10 years ago
['data2', 300],
['data3', 100]
],
10 years ago
to: 1,
});
10 years ago
}, 18000);
setTimeout(function () {
chart.flow({
columns: [
['data1', 200],
['data2', 300],
['data3', 400]
]
});
10 years ago
}, 19000);
}
run();
setTimeout(function () {
padding = {left: 0, right: 0};
run();
}, 22000);
</script>
</body>
</html>