Comments (3)
参考 #39 获取 echarts
对象。
from vue-echarts-v3.
我现在定义一个函数,里面放了全部的图标设置参数,然后赋给data中的一个变量,比如叫bar:{}
,结果不会报错了,但是我想给图表加的渐变色总是加不上去,图表一直显示红色,下面是我设置图表的代码
<template>
<div>
<div class="chart">
<label>{{title}}</label>
<IEcharts :option="bar" :loading="loadingFlag" @ready="onReady"></IEcharts>
</div>
</div>
</template>
<script>
import IEcharts from 'vue-echarts-v3/src/full.vue';
var data = {
name: ['党政', '经济', '农业', '政法', '信访', '扶贫', '财贸'],
value: [1, 3, 5, 7, 9, 11, 13],
};
export default {
props: ['title', 'chartData'],
data() {
return {
loadingFlag: true,
bar: {}
}
},
components: {
IEcharts
},
mounted() {
},
methods: {
onReady(instance, echarts) {
this.loadingFlag = false;
console.log(echarts)
this.getOptions(echarts)
},
getOptions(echarts){
let options = {
xAxis: {
data: data.name,
axisLabel: {
inside: false,
textStyle: {
interval: 0,
color: '#fff',
fontSize: 12
}
},
axisTick: {
show: false
},
axisLine: {
show: false
},
z: 10
},
yAxis: {
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
textStyle: {
color: '#999'
}
}
},
dataZoom: [
{
type: 'inside'
}
],
series: [
{
type: 'bar',
itemStyle: {
normal: {
color: echarts.graphic.LinearGradient(
0, 0, 0, 1,
[
{offset: 0, color: '#fff'},
{offset: 1, color: '#000'}
]
)
}
},
label: {
normal: {
fontWeight: 'bolder',
fontSize: 23
}
},
barWidth: 20,
data: data.value
}
]
}
this.bar = options;
return options;
}
}
}
</script>
from vue-echarts-v3.
<template>
<div class="echarts">
<IEcharts :option="bar" @ready="onReady" />
</div>
</template>
<script>
import IEcharts from 'vue-echarts-v3/src/full.vue'
export default {
name: 'view',
components: {
IEcharts
},
data () {
// const that = this
return {
ins: null,
echarts: null,
bar: {}
}
},
methods: {
onReady (instance, echarts) {
const that = this
that.ins = instance
that.echarts = echarts
that.bar = {
xAxis: {
data: ['衬衫', '羊毛衫', '雪纺衫', '裤子', '高跟鞋', '袜子'],
axisLabel: {
inside: false,
textStyle: {
interval: 0,
color: '#fff',
fontSize: 12
}
},
axisTick: {
show: false
},
axisLine: {
show: false
},
z: 10
},
yAxis: {
axisLine: {
show: false
},
axisTick: {
show: false
},
axisLabel: {
textStyle: {
color: '#999'
}
}
},
dataZoom: [
{
type: 'inside'
}
],
series: [
{
type: 'bar',
itemStyle: {
normal: {
color: new echarts.graphic.LinearGradient(
0, 0, 0, 1,
[
{ offset: 0, color: '#fff' },
{ offset: 1, color: '#000' }
]
)
}
},
label: {
normal: {
fontWeight: 'bolder',
fontSize: 23
}
},
barWidth: 20,
data: [5, 20, 36, 10, 10, 20]
}
]
}
}
}
// beforeMount () {
// const that = this
// },
// mounted () {
// const that = this
// },
// beforeDestroy () {
// const that = this
// }
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
.echarts {
width: 800px;
height: 800px;
}
</style>
from vue-echarts-v3.
Related Issues (20)
- "Error: Component legend.scroll not exists. Load it first." HOT 1
- is in the showLoading method ,the second argument custom setting is not work? HOT 1
- SVG renderer for lite version? HOT 1
- v3 run的时候文件很大,且build不出来如何解决? HOT 2
- trigger pie slice based on drop down value #10227
- 图表显示问题
- support echarts v4.2.1 HOT 1
- Tip for Quasar SSR users
- English Tooltips Issue
- Not be able to test the components used vue-echarts-v3 full.js HOT 2
- Can i change language "Chaina" to "English" in "toolbox" component ?
- support echarts v5.0.2 please HOT 3
- 在flex布局下,缩放出现的问题
- Support for Vue 3 please HOT 1
- When the symbol image is set on the tree type chart, it cannot be displayed HOT 1
- 地图钻取(全国钻取到省),省份返回全国地图后,再次点击,事件获取的值不正确 HOT 3
- 如何联动两个图形
- 结合echarts-gl怎么使用? HOT 1
- How to reduce bundle size HOT 4
- Remove lodash dependency HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vue-echarts-v3.