Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can i use linearGradient #5

Closed
Anehta opened this issue Jun 21, 2017 · 8 comments
Closed

How can i use linearGradient #5

Anehta opened this issue Jun 21, 2017 · 8 comments
Assignees
Labels

Comments

@Anehta
Copy link

Anehta commented Jun 21, 2017

like this :
color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: '#5bcee2', }, { offset: 1, color: '#045d69', }]),

@xiguaxigua
Copy link
Contributor

@Anehta What kind of scene do you need to use this or where you want to set this prop?

And I guess the following example may be helpful to you.🙂

<template>
  <div>
    <ve-line :data="chartData" :colors="chartColor"></ve-line>
  </div>
</template>
<script>
import VeLine from 'v-charts/lib/line'
import echarts from 'echarts/lib/echarts'
export default {
  data () {
    this.chartColor = [new echarts.graphic.LinearGradient(0, 0, 0, 1, [{ offset: 0, color: '#5bcee2' }, { offset: 1, color: '#045d69' }])]
    return {
      chartData: {
        columns: ['日期', '余额', '比率'],
        rows: [
          { '日期': '1月1日', '余额': 123, '比率': 0.3 },
          { '日期': '1月2日', '余额': 1223, '比率': 0.6 }
        ]
      }
    }
  },
  components: { VeLine }
}
</script>

@xiguaxigua
Copy link
Contributor

xiguaxigua commented Jun 21, 2017

Another example may be useful:

<template>
  <div>
    <ve-line
      :data="chartData"
      :settings="chartSettings"
      :after-config="afterConfig">
    </ve-line>
  </div>
</template>
<script>
import VeLine from 'v-charts/lib/line'
import echarts from 'echarts/lib/echarts'
export default {
  data () {
    return {
      chartData: {
        columns: ['日期', '余额', '比率'],
        rows: [
          { '日期': '1月1日', '余额': 123, '比率': 0.3 },
          { '日期': '1月2日', '余额': 1223, '比率': 0.6 }
        ]
      },
      chartSettings: {
        area: true
      }
    }
  },
  methods: {
    afterConfig (options) {
      options.series[0].areaStyle = {
        normal: {
          color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
            offset: 0,
            color: 'rgb(255, 158, 68)'
          }, {
            offset: 1,
            color: 'rgb(255, 70, 131)'
          }])
        }
      }
      return options
    }
  },
  components: { VeLine }
}
</script>

@xiguaxigua xiguaxigua self-assigned this Jun 21, 2017
@Anehta
Copy link
Author

Anehta commented Jun 22, 2017

Thank you for answering this question so seriously. And use this prop isn't normal?

@Anehta
Copy link
Author

Anehta commented Jun 22, 2017

em....i encountered an bug
<div style="display: flex"> <ve-line :data="chartData"></ve-line> </div>
In this code , chart will be disappear. @xiguaxigua

@xiguaxigua
Copy link
Contributor

xiguaxigua commented Jun 22, 2017

Because the default width of V-Charts box is auto, and in your current scene, you need set width such as

<ve-line
  width="100%"
  :data="chartData"
  :settings="chartSettings"
  :after-config="afterConfig">
</ve-line>

@xiguaxigua
Copy link
Contributor

xiguaxigua commented Jun 22, 2017

This problem is caused by flex-basis, as you knew, If you don't set the flex-basis, flex-basis value will be the width, and flex: 0 0 auto is the same as flex: none. So, echarts can't get dom width and won't draw anything. @Anehta

@Anehta
Copy link
Author

Anehta commented Jun 22, 2017

thhhk u bro. im a newbee....

@xiguaxigua
Copy link
Contributor

You're welcome! Every question you meet can be asked here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants