A Pen by ApexCharts on CodePen.
Last active
September 11, 2019 15:54
-
-
Save Miliks/eec89c68c38c36b493017d8c6f933731 to your computer and use it in GitHub Desktop.
Creating your first ApexChart
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div id="chart"> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var arr = new Array(); | |
var data = []; | |
arr.push({x:5,y:10}); | |
arr.push({x:10,y:20}); | |
arr.push({x:15,y:20}); | |
arr.push({x:25,y:20}); | |
function getCoordinates() | |
{ | |
var i= 0; | |
for (var i = 0; i < arr.length; i+=1) { | |
var x = arr[i]; | |
var y = arr[i+1]; | |
console.log(arr[i]); | |
} | |
data.push({ x, y | |
}); | |
} | |
var options = { | |
chart: { | |
height: 350, | |
type: 'line', | |
animations: { | |
enabled: true, | |
easing: 'linear', | |
}, | |
toolbar: { | |
show: false | |
}, | |
zoom: { | |
enabled: false | |
} | |
}, | |
dataLabels: { | |
enabled: false | |
}, | |
stroke: { | |
curve: 'smooth' | |
}, | |
series: [{ | |
data: data | |
}], | |
title: { | |
text: 'Dynamic Updating Chart', | |
align: 'left' | |
}, | |
markers: { | |
size: 2 | |
}, | |
xaxis: { | |
min:0, | |
max: 100, | |
}, | |
yaxis: { | |
min:0, | |
max: 100 | |
}, | |
legend: { | |
show: false | |
}, | |
} | |
var chart = new ApexCharts( | |
document.querySelector("#chart"), | |
options | |
); | |
chart.render(); | |
window.setInterval(function () { | |
getCoordinates() | |
chart.updateSeries([{ | |
data: data | |
}]) | |
}, 60000) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script src="https://cdn.jsdelivr.net/npm/apexcharts"></script> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@import url(https://fonts.googleapis.com/css?family=Roboto); | |
body { | |
font-family: Roboto, sans-serif; | |
} | |
#chart { | |
max-width: 650px; | |
margin: 35px auto; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment