I am trying to draw a pie chart using JavaScript, The challenge here is I don't know how many slices the chart will have so, I have to read the chart values in the database. So, How do I put PHP code inside values: [10,12,78,15,45, 55], to get the live values??
<script type="text/javascript">
var data = [{
values: [10,12,78,15,45, 55],
labels: ['OK', 'NO','MAYBE', 'SOMETIMES','NEVER', 'I DONT KNOW'],
type: 'pie'
}];
var layout = {
height: 380,
width: 480
};
Plotly.newPlot(graph, data, layout);
</script>
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
<!-- Numeric JS -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/numeric/1.2.6/numeric.min.js"> //Hosted Scripts
<div id="graph" style="width: 480px; height: 380px;"> </div>