echart在微信小程序的使用簡(jiǎn)單示例
echarts不顯示在微信小程序
<!-- 微信小程序的echart的使用 -->
<view class="container">
<ec-canvas id="mychart-dom-bar" canvas-id="mychart-bar" ec="{{ ec }}"></ec-canvas>
</view>
css樣式
ec-canvas {
width: 100%;
height: 100%;
}
.container {
position: absolute;
top: 0;
bottom: 0;
left: 0;
right: 0;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
box-sizing: border-box;
}
echarts的grid屬性詳解
- grid配置項(xiàng):圖標(biāo)離容器的距離
- show:是否顯示直角坐標(biāo)系網(wǎng)格-----------值:true?false
- left:圖表離容器左側(cè)的距離-----------------值:number?百分比
- top:圖表離容器頂部的距離-----------------值:number?百分比
- right:圖表離容器右側(cè)的距離---------------值:number?百分比
- bottom:圖表離容器底部的距離------------值:number?百分比
- backgroundColor:網(wǎng)格背景色-------------值:rgba或#000000
- borderColor:網(wǎng)格的邊框顏色--------------值:rgba或#000000
- borderWidth:網(wǎng)格的邊框線寬-------------值:number
- 備注:背景色-邊框-線寬生效前提:設(shè)置了show:true,邊距不受show影響
js
import * as echarts from '../../base-ui/ec-canvas/echarts';
let chart = null;
function initChart(canvas, width, height, dpr) {
chart = echarts.init(canvas, null, {
width: width,
height: height,
devicePixelRatio: dpr // new
});
canvas.setChart(chart);
var option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
xAxis: {
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
axisLabel:{
fontSize:10
},
},
yAxis: {
type: 'value',
},
series: [
{
data: [-120, 200, 150, 80, -70, 110, 130],
type: 'bar'
}
]
};
chart.setOption(option);
return chart;
}
Page({
onShareAppMessage: function (res) {
return {
title: 'ECharts 可以在微信小程序中使用啦!',
path: '/pages/index/index',
success: function () { },
fail: function () { }
}
},
data: {
ec: {
onInit: initChart
}
},
onReady() {
setTimeout(function () {
// 獲取 chart 實(shí)例的方式
// console.log(chart)
}, 2000);
}
});
總結(jié)
到此這篇關(guān)于echart在微信小程序的使用的文章就介紹到這了,更多相關(guān)echart在微信小程序的使用內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
微信小程序?qū)崿F(xiàn)倒計(jì)時(shí)功能
這篇文章主要為大家詳細(xì)介紹了微信小程序?qū)崿F(xiàn)倒計(jì)時(shí)功能,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-11-11
js實(shí)現(xiàn)簡(jiǎn)單隨機(jī)抽獎(jiǎng)的方法
這篇文章主要介紹了js實(shí)現(xiàn)簡(jiǎn)單隨機(jī)抽獎(jiǎng)的方法,涉及字符串的操作、setInterval定時(shí)調(diào)用等技巧,需要的朋友可以參考下2015-01-01
js中requestAnimationFrame()解讀與使用示例
requestAnimationFrame()是JavaScript中用于創(chuàng)建高效、流暢動(dòng)畫的核心方法,它與瀏覽器的重繪過程同步,確保每次動(dòng)畫更新都與顯示器刷新率同步,下面就來一起了解一下2024-09-09
(currentStyle)javascript為何有時(shí)用style得不到已設(shè)定的CSS的屬性
(currentStyle)javascript為何有時(shí)用style得不到已設(shè)定的CSS的屬性...2007-08-08
Javascript 實(shí)現(xiàn)的數(shù)獨(dú)解題算法網(wǎng)頁實(shí)例
此算法的實(shí)現(xiàn),就是模擬人腦的思考和計(jì)算過程,有需要的朋友可以參考一下2013-10-10
antd項(xiàng)目實(shí)現(xiàn)彩蛋效果的詳細(xì)代碼
這篇文章主要介紹了antd項(xiàng)目如何實(shí)現(xiàn)彩蛋效果,首先在components目錄下創(chuàng)建Transform目錄,包括index.css、index.js,index.js是主要的邏輯代碼,下面對(duì)代碼進(jìn)行分析,需要的朋友可以參考下2022-09-09
JS中的substring和substr函數(shù)的區(qū)別說明
stringObject.substring(start,stop)與substr(start,length)有什么區(qū)別,下面為大家詳細(xì)介紹下,感興趣的朋友可以參考下哈2013-05-05

