标签:canvas color 微信 ec height width 折线图 type echarts
实现效果:
index.json文件:
{
"component": true,
"usingComponents": {
"ec-canvas":"../../components/ec-canvas/ec-canvas"
}
}
index.wxss 文件:
<view class="pie-charts">
<view class="lengendTitle">
<image src="{{tipImg}}" class="tipLineImg" />
<text class="tipTitle">时/分</text>
</view>
<ec-canvas
id="mychart-dom-bar"
canvas-id="mychart-bar"
ec="{{ ec }}"
></ec-canvas>
</view>
inex.js 文件配置:
import * as echarts from '../ec-canvas/echarts';
function initChart(canvas, width, height) {
const chart = echarts.init(canvas, null, {
width: width,
height: height
});
canvas.setChart(chart);
var option = {
grid: {
show: false,
top: '9%',
right: '5%',
left: '10%'
},
xAxis: {
type: 'category',
axisLine: {
show: true,
lineStyle: {
type: "dashed"
}
},
data: ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12', '13', '14']
},
yAxis: {
type: 'value',
splitLine: {
show: false,
},
axisLine: {
show: true,
lineStyle: {
type: "dashed"
}
}
},
series: [{
data: [0, 40, 10, 40, 25, 60, 40, 10, 60, 25, 0, 40, 10, 40, 25],
type: 'line',
smooth: true,
itemStyle: {
normal: {
color: '#ffb71b',
lineStyle: { // 系列级个性化折线样式
width: 4,
type: 'solid',
color: new echarts.graphic.LinearGradient(0, 0.4, 0.7, 1, [{
offset: 0,
color: '#ffb71b'
} , {
offset: 0.4,
color: '#b75cee'
}, {
offset: 0.7,
color: '#66acfc'
}, {
offset: 1,
color: '#3843fa'
}]),//线条渐变色
}
},
}
}]
};
chart.setOption(option);
return chart;
}
Component({
/**
* 组件的属性列表
*/
properties: {
},
/**
* 组件的初始数据
*/
data: {
ec: {
onInit: initChart
},
tipImg: '../../img/lineTip.png'
},
index.wxss文件:
.pie-charts {
width: 100%;
height: 500rpx;
margin: 20px 0 0 10px;
}
.lengendTitle {
display: flex;
align-items: center;
justify-content: center;
padding-top: 20rpx;
}
.tipTitle {
font-size: 28rpx;
color: #ffffff;
margin-left: 10rpx;
letter-spacing: 5rpx;
}
.tipLineImg {
width: 20rpx;
height: 20rpx;
padding-top: 7rpx;
}
标签:canvas,color,微信,ec,height,width,折线图,type,echarts 来源: https://blog.csdn.net/Maxueyingying/article/details/122539715
本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享; 2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关; 3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关; 4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除; 5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。