脚本宝典收集整理的这篇文章主要介绍了echarts Dataset 对多数据动态图示化展示,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
echarts官网资源地址: https://echarts.apache.org/examples/zh/index.htML @*前端图形创建*@ <div class="layui-card-body" style=" height: 360px; text-align: center;"> <div class="layui-col-md12 layui-col-xs12"> <div class="layui-card-body" id="chartdiv" style="height: 400px; background: #ffffff; "></div> </div> </div>
VAR mySBChart = echarts.inIT(document.getElementById('chartshebeidiv'), 'macarons');
官方案例: setTimeout(function () { option = { legend: {}, tooltip: { trigger: 'axis', showContent: false }, dataset: { source: [ ['PRoduct', '2012', '2013', '2014', '2015', '2016', '2017'], ['Milk Tea', 56.5, 82.1, 88.7, 70.1, 53.4, 85.1], ['Matcha Latte', 51.1, 51.4, 55.1, 53.3, 73.8, 68.7], ['Cheese Cocoa', 40.1, 62.2, 69.5, 36.4, 45.2, 32.5], ['Walnut brownie', 25.2, 37.1, 41.2, 18, 33.9, 49.1] ] }, xAxis: { tyPE: 'category' }, yAxis: { gridIndex: 0 }, grid: { top: '55%' }, series: [ { type: 'line', smooth: true, seriesLayoutBy: 'row', emphasis: { focus: 'series' } }, { type: 'line', smooth: true, seriesLayoutBy: 'row', emphasis: { focus: 'series' } }, { type: 'line', smooth: true, seriesLayoutBy: 'row', emphasis: { focus: 'series' } }, { type: 'line', smooth: true, seriesLayoutBy: 'row', emphasis: { focus: 'series' } }, { type: 'pie', id: 'pie', radius: '30%', center: ['50%', '25%'], emphasis: { focus: 'self' }, label: { formatter: '{b}: {@2012} ({d}%)' }, encode: { itemName: 'product', value: '2012', tooltip: '2012' } } ] }; myChart.on('updateAxisPointer', function (event) { const xAxisInfo = event.axesInfo[0]; if (xAxisInfo) { const dimension = xAxisInfo.value + 1; myChart.setOption({ series: { id: 'pie', label: { formatter: '{b}: {@[' + dimension + ']} ({d}%)' }, encode: { value: dimension, tooltip: dimension } } }); } }); myChart.setOption(option); });项目动态填充数据:
function setBZChart() { var timestart = document.getElementById("timeyearBZ").value; $.ajax({ //ajax动态取值 url: "/FSUManage/Sumstatistics/JsonAuditIndex", data: { CityId: 0, Areaid: 0, Month: timestart }, type: "post", success: function (res) { var returnres = $.parseJSON(res); if (returnres.code == 0) { setTimeout(function () { option = { legend: {}, tooltip: { trigger: 'axis', showContent: true }, dataset: { source: [ //后台动态拼接好json字符串直接赋值source returnres.xaxis, returnres.data, returnres.data1, returnres.data2 ] }, xAxis: { type: 'category' }, yAxis: { gridIndex: 0 }, grid: { top: '45%', containlable: true }, series: [ { type: 'line', smooth: true, seriesLayoutBy: 'row', emphasis: { focus: 'series' } }, { type: 'line', smooth: true, seriesLayoutBy: 'row', emphasis: { focus: 'series' } }, { type: 'line', smooth: true, seriesLayoutBy: 'row', emphasis: { focus: 'series' } }, { type: 'pie', id: 'pie', radius: '30%', center: ['50%', '25%'], emphasis: { focus: 'data' }, label: { formatter: '{b}: ({d}%)' }, encode: { itemName: 'product', value: '1月', tooltip: '1月' } } ] }; myChart.on('updateAxisPointer', function (event) { var xAxisInfo = event.axesInfo[0]; if (xAxisInfo) { var dimension = xAxisInfo.value + 1; myChart.setOption({ series: { id: 'pie', label: { formatter: '{b}: ({d}%)' }, encode: { value: dimension, tooltip: dimension } } }); } });
myChart.setOption(option); }) } else { layer.msg("获取失败", { icon: 5 }); } } });
}
</script>
官方案例图案示例:<官网详细案例地址:https://echarts.apache.org/examples/zh/editor.html?c=dataset-link>
项目案例图案示例:
个人笔记内容:
var LOGJSON = [@{ @Html.Raw(SmartNet.Core.JsonHelper.dtToJson(dtList).ToString().TrimEnd(']').TrimStart('[')); }];
@Html.Raw(isDealNameOne)
以上是脚本宝典为你收集整理的echarts Dataset 对多数据动态图示化展示全部内容,希望文章能够帮你解决echarts Dataset 对多数据动态图示化展示所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。