欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 文旅 > 明星 > uniapp__微信小程序使用秋云ucharts折线图双轴

uniapp__微信小程序使用秋云ucharts折线图双轴

2024/10/25 3:32:45 来源:https://blog.csdn.net/apple_70049717/article/details/142874311  浏览:    关键词:uniapp__微信小程序使用秋云ucharts折线图双轴

1、子组件

<template><view class="charts-box"><qiun-data-charts type="line":opts="computedOpts":chartData="chartData"/></view>
</template><script>
export default {props: {chartData: {type: Object,required: true},color: {type: Array,default: () => ["#1890FF", "#91CB74"]},yAxisMax: {type: Number,default: 5},yAxisMin: {type: Number,default: 0}},computed: {computedOpts() {// 在这里封装 opts,并根据父组件传入的 props 动态修改return {color: this.color, // 使用父组件传入的颜色padding: [15, 10, 0, 15],enableScroll: false,xAxis: {disableGrid: true,rotateLabel: true},yAxis: {data: [{type: "value",position: "left",},{type: "value",position: "right",min: this.yAxisMin, // 父组件传入的最小值max: this.yAxisMax  // 父组件传入的最大值}]},extra: {line: {type: "straight",width: 2,activeType: "hollow"},tooltip: {legendShape: "circle"}}};}}
};
</script><style scoped>
.charts-box {width: 715rpx;height: 300px;margin-left: -51rpx;
}
</style>

2、父组件

<lineecharts :chartData="chartData" :color="['#1890FF', '#91CB74']" :yAxisMax="10" :yAxisMin="0">getChartData() {const startTime = new Date();let timePoints = [];for (let i = 0; i < 6; i++) {const time = new Date(startTime.getTime() + i * 5000);const formattedTime = `${time.getHours()}:${time.getMinutes()}:${time.getSeconds()}`;timePoints.push(formattedTime);}setTimeout(() => {this.chartData = {categories: timePoints,series: [{name: "心率",data: [35, 8, 25, 37, 4, 20],index: 0},{name: "呼吸",data: [2, 4, 3, 1, 4, 1],index: 1}]};}, 100);},

 双轴series: [{
                                name: "心率",
                                data: [35, 8, 25, 37, 4, 20],
                                index: 0
                            },
                            {
                                name: "呼吸",
                                data: [2, 4, 3, 1, 4, 1],
                                index: 1
                            }
                        ]数据区分使用index

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com