var data = [];var dataCount = 10;var startTime = +new Date();var categories = ['categoryA', 'categoryB', 'categoryC'];var types = [ {name: 'JS Heap', color: '#7b9ce1'}, {name: 'Documents', color: '#bd6d6c'}, {name: 'Nodes', color: '#75d874'}, {name: 'Listeners', color: '#e0bc78'}, {name: 'GPU Memory', color: '#dc77dc'}, {name: 'GPU', color: '#72b362'}];// Generate mock dataecharts.util.each(categories, function (category, index) { var baseTime = startTime; for (var i = 0; i < dataCount; i++) { var typeItem = types[Math.round(Math.random() * (types.length - 1))]; var duration = Math.round(Math.random() * 10000); data.push({ name: typeItem.name, value: [ index, baseTime, baseTime += duration, duration ], itemStyle: { normal: { color: typeItem.color } } }); baseTime += Math.round(Math.random() * 2000); }});function renderItem(params, api) { var categoryIndex = api.value(0); var start = api.coord([api.value(1), categoryIndex]); var end = api.coord([api.value(2), categoryIndex]); var height = api.size([0, 1])[1] * 0.6; var rectShape = echarts.graphic.clipRectByRect({ x: start[0], y: start[1] - height / 2, width: end[0] - start[0], height: height }, { x: params.coordSys.x, y: params.coordSys.y, width: params.coordSys.width, height: params.coordSys.height }); return rectShape && { type: 'rect', shape: rectShape, style: api.style() };}大家好!!我正在处理 echarts 库,我唯一想更改数据的是 Xaxis 部分的axisLabel。我的意思是,例如,“2019-11-5、2019-11-6....”等等。所以,希望有人能帮帮我,非常感谢!!!大家好!!我正在处理 echarts 库,我唯一想更改数据的是 Xaxis 部分的axisLabel。我的意思是,例如,“2019-11-5、2019-11-6....”等等。所以,希望有人能帮帮我,非常感谢!!!
1 回答

慕的地10843
TA贡献1785条经验 获得超8个赞
首先,创建一个日期数组,如
var dates = ['2019-11-5','2019-10-3','2019-2-2','2019-1-4','2019-12-5'];
然后在 xAxis -> axisLabel 返回日期
axisLabel: {
formatter: function (val,index) {
return dates[index];
}
}
添加回答
举报
0/150
提交
取消