extra: {
area: {
type: "straight",
opacity: 0.8,
addLine: true,
width: 2,
gradient: true
},
},
以下是绘制该折线图(其实是区域图)的方法,完整配置如下:
showLine(canvasId, chartData) {
canvaLine = new uCharts({
$this: _self,
canvasId: canvasId,
type: "area",//type为area而不是line
legend: {
show: false,
},
fontSize: 11,
background: "#FFFFFF",
pixelRatio: _self.pixelRatio,
animation: true,
categories: chartData.categories,
series: chartData.series,
padding: [14, 10, 4, 15],
dataPointShape: false,
duration: 500,
xAxis: {
disableGrid: true, //不绘制纵向网格
fontColor: '#999999',
axisLineColor: '#E6E6E6',
fontSize: 9
},
yAxis: {
gridColor: "#EBEBEB",
gridType: "dash",
dashLength: '3',
data: [{
fontColor: '#999999',
min: this.getMin(),
max: this.getMax(),
axisLineColor: '#E6E6E6',
fontSize: 9,
format: (val) => {
return val.toFixed(0) //此处为保留一位小数
},
}]
},
dataLabel: false, //是否在图表中显示数据标签内容值
width: _self.cWidth * _self.pixelRatio,
height: _self.cHeight * _self.pixelRatio,
extra: {
area: {
type: "straight",
opacity: 0.8,
addLine: true,
width: 2,
gradient: true
},
},
});
},
yAxis: {
gridColor: "#EBEBEB",
gridType: "dash",
dashLength: '3',
data: [{
fontColor: '#999999',
min: this.getMin(),
max: this.getMax(),
axisLineColor: '#E6E6E6',
fontSize: 9,
format: (val) => {
return val.toFixed(0) //此处为保留一位小数
},
}]
},
getMax(){
return Math.max(...this.yData)
},
getMin(){
return Math.min(...this.yData)
},