我正在使用chartjs,我的javascript数据与div id在同一页面上,但是它从另一个来源选择图表。但是,我希望从同一页面中选择数据
下面是我的javascript
<script>
if($("#line-chartjsid2").length){
var lineChartData = {
labels: ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul" , "Aug","Sep","Oct","Nov","Dec"],
datasets: [{
label: "Income",
fillColor: "rgba(63,81,181,0.5)",
strokeColor: "rgba(63,81,181,1)",
pointColor: "rgba(63,81,181,1)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(63,81,181,1)",
data: [<?php echo $jantotinc; ?>,<?php echo $febtotinc ?>,<?php echo $martotinc ?>,<?php echo $aprtotinc ?>,<?php echo $maytotinc ?>,<?php echo $juntotinc ?>,<?php echo $jultotinc ?>,<?php echo $augtotinc ?>,<?php echo $septotinc ?>,<?php echo $octtotinc ?>,<?php echo $novtotinc ?>,<?php echo $dectotinc ?>]
}, {
label: "Expense",
fillColor: "rgba(255,58,183,0.5)",
strokeColor: "rgba(255,58,183,1.0)",
pointColor: "rgba(255,58,183,1.0)",
pointStrokeColor: "#fff",
pointHighlightFill: "#fff",
pointHighlightStroke: "rgba(255,58,183,1.0)",
data: [<?php echo $jantotbill; ?>,<?php echo $febtotbill; ?>,<?php echo $martotbill; ?>,<?php echo $aprtotbill; ?>,<?php echo $maytotbill; ?>,<?php echo $juntotbill; ?>,<?php echo $jultotbill; ?>,<?php echo $augtotbill; ?>,<?php echo $septotbill; ?>,<?php echo $octtotbill; ?>,<?php echo $novtotbill; ?>,<?php echo $dectotbill; ?>]
}]
}
var ctx = document.getElementById("line-chartjsid2").getContext("2d");
window.myLine = new Chart(ctx).Line(lineChartData, {
responsive: true
});
}
</script>
这是我的代码
<div class="col-xs-12 col-md-6 col-lg-4">
<section class="box ">
<header class="panel_header">
<h2 class="title pull-left">Expenses</h2>
<div class="actions panel_actions pull-right">
<a class="box_toggle fa fa-chevron-down"></a>
<!--<a class="box_setting fa fa-cog" data-toggle="modal" href="#section-settings"></a>
<a class="box_close fa fa-times"></a> -->
</div>
</header>
<div class="content-body"> <div class="row">
<div class="col-xs-12">
<div class="chart-container">
<!-- <div class="" style="height:200px" id="platform_type_dates"></div>-->
<canvas id="line-chartjsid2" style="height: 200px; width: 100%;"></canvas>
</div>
</div>
</div> <!-- End .row -->
</div>
</section></div>
我想从我的页面中选择相同的数据