折线图为例,核心代码
<script src="/assets/webmaster/js/jquery.min.js"></script> <script src="/assets/webmaster/js/echarts.min.js"></script> <script type="text/javascript"> // 基于准备好的dom,初始化echarts实例 var myChart = echarts.init(document.getElementById('latest_pv')); // 指定图表的配置项和数据 var option = { xAxis: { type: 'category', data: ['{$d1}', '{$d2}', '{$d3}', '{$d4}', '{$d5}', '{$d6}', '{$d7}'] }, yAxis: { type: 'value' }, series: [{ data: [{$uv1}, {$uv2}, {$uv3}, {$uv4}, {$uv5}, {$uv6}, {$uv7}], type: 'line' }], tooltip : { trigger: 'axis', axisPointer: { type: 'cross', label: { backgroundColor: '#6a7985' } } } }; // 使用刚指定的配置项和数据显示图表。 myChart.setOption(option); </script>
效果