I want to create a Chart in js. I get the value for labels line x from Label
by selecting data from sql and get condition, but when I set labels = Label
, the Chart does not show.
Please help me, I tried to try every suggestion.
lbldate.Text = lbldate.Text + D1 + "," + D2 + "," + D3 + "," + D4+",";
<script type="text/javascript">
var ldate = $('[id*=lbldate]').val();
var config = {
type: 'line',
data: {
labels: ldate,
datasets: [{
label: "My First dataset",
data: [65, 40, 80, 81, 56, 85, 45],
backgroundColor: "rgba(255,99,132,0.2)",
}, {
label: "My Second dataset",
data: [40, 80, 21, 56, 85, 45, 65],
backgroundColor: "rgba(99,255,132,0.2)",
}]
},
scales: {
xAxes: [{
gridLines: {
display: false,
lineWidth: 1,
zeroLineWidth: 1,
zeroLineColor: '#666666',
drawTicks: false
},
ticks: {
display: true,
stepSize: 0,
min: 0,
autoSkip: false,
fontSize: 11,
padding: 12
}
}],
yAxes: [{
ticks: {
padding: 5
},
gridLines: {
display: true,
lineWidth: 1,
zeroLineWidth: 2,
zeroLineColor: '#666666'
}
}]
},
spanGaps: true,
responsive: true,
maintainAspectRatio: true
};
var ctx = document.getElementById("myChart").getContext("2d");
new Chart(ctx, config);
</script>
<asp:Label ID="lbldate" runat="server" Text=""></asp:Label>
<div class="myChart">
<canvas id="myChart"></canvas>
</div>