Giter VIP home page Giter VIP logo

echarts-liquidfill's Introduction

Liquid Fill Chart

Liquid Fill Chart plugin for Apache ECharts, which is usually used to represent data in percentage.

Rendering Results

Install ECharts

To use ECharts plugins, you need to include the plugin JavaScript file after ECharts file.

<script src='echarts.js'></script>
<script src='echarts-liquidfill.js'></script>

ECharts can be downloaded at GitHub dist directory or Download page of Official Website (in Chinese).

NOTE

The minimum package of ECharts required by LiquidFill Chart is simple version on GitHub, or selecting nothing in online builder (in Chinese). If you need other chart types or components in your other chart, you should include them accordingly.

Install echarts-liquidfill with npm

# install echarts as peer dependency
npm install echarts
npm install echarts-liquidfill

NOTE:

echarts-liquidfill@3 is compitable with echarts@5 echarts-liquidfill@2 is compitable with echarts@4

Import:

import * as echarts from 'echarts';
import 'echarts-liquidfill'

Or:

import * as echarts from 'echarts/core';
import 'echarts-liquidfill'

Here is the basic example on CodeSandbox

Download echarts-liquidfill from GitHub

You may download the lastest ECharts files on ECharts official site and download this plugin in dist directory.

Note that if you need tooltip for Liquid Fill Chart, you need the complete ECharts version. Otherwise, the simple version will be competent.

Important Notes

Omitted normal

Since ECharts v4.0.0, normal is no longer needed for itemStyle or label.

Flatten textStyle

Since ECharts v3.7.0, textStyle option is flatten, so that series.label[normal|emphasis].textStyle.xxx is now can be written in series.label[normal|emphasis].textStyle. This is supported from echarts-liquidfill v1.0.6. So if you found examples with textStyle in old demo, don't be too surprised.

Quick Start

Here are some common uses:

To ask a question, you may fork Liquid Fill Chart Example on Gallery and copy your code there. Then you may open an issue in this project.

Examples

A Simple Example

To create a Liquid Fill Chart, you need to have a series with type of 'liquidFill'. A basic option may be:

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6]
    }]
};

A simple liquid fill chart

Run

Multiple Waves

It is easy to create a liquid fill chart will multiple waves, either to represent multiple data, or to improve the visual effect of the chart.

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6, 0.5, 0.4, 0.3]
    }]
};

This creates a chart wit waves at position of 60%, 50%, 40%, and 30%.

Multiple waves

Run

Color and Opacity

To set colors for liquid fill chart series, set color to be an array of colors. To set opacity, use itemStyle.opacity and itemStyle.emphasis.opacity for normal style and hover style.

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.5, 0.4, 0.3],
        color: ['red', '#0f0', 'rgb(0, 0, 255)'],
        itemStyle: {
                opacity: 0.6
        },
        emphasis: {
            itemStyle: {
                opacity: 0.9
            }
        }
    }]
};

Color and opacity

Run

You may also set the color and opacity of a single data item by:

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.5, 0.4, {
            value: 0.3,
            itemStyle: {
                color: 'red',
                opacity: 0.6
            },
            emphasis: {
                itemStyle: {
                    opacity: 0.9
                }
            }
        }]
    }]
};

Color and opacity of a single data item

Run

Static Waves

To provent the waves from moving left or right, you may simply set waveAnimation to be false. To disable the animation of waves raising, set animationDuration and animationDurationUpdate to be 0.

var option = {
    series: [{
        type: 'liquidFill',
        waveAnimation: false,
        animationDuration: 0,
        animationDurationUpdate: 0,
        data: [0.6, 0.5, 0.4, 0.3]
    }]
};

Static waves

Run

Still Water

You may set the amplitude to be 0 to make still waves.

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6, 0.5, 0.4, 0.3],
        amplitude: 0,
        waveAnimation: 0
    }]
};

It is recommended to set waveAnimation to be false in this case to disable animation for performance consideration.

Still water

Run

Change A Single Wave

To change a single wave, overwrite the options in data item.

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6, {
            value: 0.5,
            direction: 'left',
            itemStyle: {
                color: 'red'
            }
        }, 0.4, 0.3]
    }]
};

Change a single wave

Run

Background Style

You can use backgroundStyle option to set the stroke, fill style of background shape.

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6, 0.5, 0.4, 0.3],
        backgroundStyle: {
            borderWidth: 5,
            borderColor: 'red',
            color: 'yellow'
        }
    }]
};

Change border width and color

Run

Outline Style

To hide the outline, just set outline.show to be false.

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6, 0.5, 0.4, 0.3],
        outline: {
            show: false
        }
    }]
};

No outline

Run

Shape

Shape of water fill chart. It can be:

  • one of the default symbols: 'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow';
  • 'container': a shape that fully fills the container.
  • an SVG path starting with 'path://'.
var options = [{
    series: [{
        type: 'liquidFill',
        data: [0.6, 0.5, 0.4, 0.3],
        shape: 'diamond'
    }]
}];

Diamond wave

Run

option = {
    series: [{
        type: 'liquidFill',
        data: [0.5, 0.4, 0.3, 0.2],
        shape: 'container',
        outline: {
            show: false
        }
    }]
};

Fill the container

Run

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6, 0.55, 0.4, 0.25],
        radius: '60%',
        outline: {
            show: false
        },
        backgroundStyle: {
            borderColor: '#156ACF',
            borderWidth: 1,
            shadowColor: 'rgba(0, 0, 0, 0.4)',
            shadowBlur: 20
        },
        shape: 'path://M367.855,428.202c-3.674-1.385-7.452-1.966-11.146-1.794c0.659-2.922,0.844-5.85,0.58-8.719 c-0.937-10.407-7.663-19.864-18.063-23.834c-10.697-4.043-22.298-1.168-29.902,6.403c3.015,0.026,6.074,0.594,9.035,1.728 c13.626,5.151,20.465,20.379,15.32,34.004c-1.905,5.02-5.177,9.115-9.22,12.05c-6.951,4.992-16.19,6.536-24.777,3.271 c-13.625-5.137-20.471-20.371-15.32-34.004c0.673-1.768,1.523-3.423,2.526-4.992h-0.014c0,0,0,0,0,0.014 c4.386-6.853,8.145-14.279,11.146-22.187c23.294-61.505-7.689-130.278-69.215-153.579c-61.532-23.293-130.279,7.69-153.579,69.202 c-6.371,16.785-8.679,34.097-7.426,50.901c0.026,0.554,0.079,1.121,0.132,1.688c4.973,57.107,41.767,109.148,98.945,130.793 c58.162,22.008,121.303,6.529,162.839-34.465c7.103-6.893,17.826-9.444,27.679-5.719c11.858,4.491,18.565,16.6,16.719,28.643 c4.438-3.126,8.033-7.564,10.117-13.045C389.751,449.992,382.411,433.709,367.855,428.202z',
        label: {
            position: ['38%', '40%'],
            formatter: function() {
                return 'ECharts\nLiquid Fill';
            },
            fontSize: 40,
            color: '#D94854'
        }
    }]
};

ECharts Liquid Fill

Run

Animation

Generally speaking, there are two types of animations in liquid fill charts.

The first type is initial animation, which has the effect of wave raising. The easing method of this animation is controlled with animationEasing and its duration with animationDuration.

The second type is the update animation, which is usually used when data changes and wave height changes. They are controlled with animationEasingUpdate and animationDurationUpdate.

For example, to disable the raising animation and set update animation time to be two seconds with cubicOut easing, you can use the following option:

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6, 0.5, 0.4, 0.3],
        animationDuration: 0,
        animationDurationUpdate: 2000,
        animationEasingUpdate: 'cubicOut'
    }]
};
chart.setOption(option);
setTimeout(function () {
    chart.setOption({
        series: [{
            type: 'liquidFill',
            data: [0.8, 0.6, 0.4, 0.2]
        }]
    })
}, 3000);

Update animation

Run

Change Text

By default, the text label of liquid fill chart displays percentage of the first data. For example, for a chart with data [0.6, 0.5, 0.4, 0.3], default text is 60%.

To change the text, you may use label.formatter, which can be set to a string or function.

If it is a string, {a} refers to series name, {b} to data name, and {c} to data value.

var option = {
    series: [{
        type: 'liquidFill',
        name: 'Liquid Fill',
        data: [{
            name: 'First Data',
            value: 0.6
        }, 0.5, 0.4, 0.3],
        label: {
            formatter: '{a}\n{b}\nValue: {c}',
            fontSize: 28
        }
    }]
};

Label text of this example is 'Liquid Fill\nFirst Data\nValue: 0.6'.

Label formatter as string

Run

This has the same result as using formatter as a function:

var option = {
    series: [{
        type: 'liquidFill',
        name: 'Liquid Fill',
        data: [{
            name: 'First Data',
            value: 0.6
        }, 0.5, 0.4, 0.3],
        label: {
            formatter: function(param) {
                return param.seriesName + '\n'
                    + param.name + '\n'
                    + 'Value:' + param.value;
            },
            fontSize: 28
        }
    }]
};

Run

Text position is at the center by default. label.position can be set to be 'inside', 'left', 'right', 'top', 'bottom', or horizontal and vertical positions like ['10%', '20%'], which means '10%' to the left (controlled by label.align, which can be 'left', 'center', or 'right') and '20%' to the top (controlled by label.baseline, which can be 'top', 'middle', or 'bottom').

Shadow

By default, waves and outline have shadow on them. Here's how to change them.

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6, 0.5, 0.4, 0.3],
        itemStyle: {
            shadowBlur: 0
        },
        outline: {
            borderDistance: 0,
            itemStyle: {
                borderWidth: 5,
                borderColor: '#156ACF',
                shadowBlur: 20,
                shadowColor: 'rgba(255, 0, 0, 1)'
            }
        }
    }]
};

Change shadow

Run

Tooltip

To add tooltip:

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6],
        name: 'Liquid Fill'
    }],
    tooltip: {
        show: true
    }
};

Tooltip

Run

Click Event

To add click event on waves:

chart.setOption(option);
chart.on('click', function() {
    console.log(arguments);
    // do something useful here
});

Like any other chart types, the above code will only trigger events on waves. If you want to track events on the whole canvas or specific elements, you may add listener to zrender like:

chart.getZr().on('click', function() {
       console.log(arguments);
});

Non-interactable

To make an element (e.g., a wave) non-interactable, simply set silent to be true.

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6, 0.5, 0.4, 0.3],
        silent: true
    }]
};

Run

API

Default option for liquid fill charts are:

{
    data: [],

    color: ['#294D99', '#156ACF', '#1598ED', '#45BDFF'],
    center: ['50%', '50%'],
    radius: '50%',
    amplitude: '8%',
    waveLength: '80%',
    phase: 'auto',
    period: 'auto',
    direction: 'right',
    shape: 'circle',

    waveAnimation: true,
    animationEasing: 'linear',
    animationEasingUpdate: 'linear',
    animationDuration: 2000,
    animationDurationUpdate: 1000,

    outline: {
        show: true,
        borderDistance: 8,
        itemStyle: {
            color: 'none',
            borderColor: '#294D99',
            borderWidth: 8,
            shadowBlur: 20,
            shadowColor: 'rgba(0, 0, 0, 0.25)'
        }
    },

    backgroundStyle: {
        color: '#E3F7FF'
    },

    itemStyle: {
        opacity: 0.95,
        shadowBlur: 50,
        shadowColor: 'rgba(0, 0, 0, 0.4)'
    },

    label: {
        show: true,
        color: '#294D99',
        insideColor: '#fff',
        fontSize: 50,
        fontWeight: 'bold',

        align: 'center',
        baseline: 'middle'
        position: 'inside'
    },

    emphasis: {
        itemStyle: {
            opacity: 0.8
        }
    }
}

data {(number|Object)[]}

Value of each data item should be between 0 and 1.

The data item can also be an object to configure the option for a single item.

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6, {
            value: 0.5,
            itemStyle: {
                color: 'red'
            }
        }, 0.4, 0.3]
    }]
};

This defines a chart with the second wave of red color.

color {string[]}

Wave colors.

shape {string}

Shape of water fill chart. It can be one of the default symbols: 'circle', 'rect', 'roundRect', 'triangle', 'diamond', 'pin', 'arrow'. Or, an SVG path starting with 'path://'.

center {string[]}

Position of the chart. The first value is x position, the second one is the y position. Each of the values can be a relative value like '50%', which is relative to the smaller value of container width and height, or an absolute value like 100px.

radius {string}

Radius of the chart, which can be a relative value like '50%', which is relative to the smaller value of container width and height, or an absolute value like 100px.

amplitude {number}

Amplitude of the wave, in pixels or percentage. If it is in percentage, it's relative to the diameter.

waveLength {string|number}

Wave length of the wave, which can be a relative value like '50%', which is relative to the diameter, or an absolute value like '100px' or 100.

phase {number}

Phase of wave, in radian system. By default, it is set to be 'auto', when each wave has a phase of Math.PI / 4 larger than the previous one.

period {number|'auto'|function}

Milliseconds that it takes to move forward a wave-length. By default, it is set to be 'auto', when the wave at the front has a greater speed.

It can also be a formatter function.

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6, 0.5, 0.4, 0.3],
        radius: '70%',
        phase: 0,
        period: function (value, index) {
            // This function is called four times, each for a data item in series.
            // `value` is 0.6, 0.5, 0.4, 0.3, and `index` is 0, 1, 2, 3.
            return 2000 * index + 1000;
        }
    }]
}

direction {string}

Direction that the waves moving in, which should either be 'right', or 'left'.

waveAnimation {boolean}

Whether to enable wave from moving left or right.

animationEasing {string}

Easing methods for initial animation, when waves raise from the bottom at the beginning.

animationEasingUpdate {string}

Easing methods for other animation, for example, when data value changes and wave position changes.

animationDuration {number}

Initial animation duration, in milliseconds.

animationDurationUpdate {number}

Other animation duration, in milliseconds.

outline.show {boolean}

Whether to display outline.

outline.borderDistance {number}

Distance between border and inner circle.

outline.itemStyle.borderColor {string}

Border color.

outline.itemStyle.borderWidth {number}

Border width.

outline.itemStyle.shadowBlur {number}

Outline shadow blur size.

outline.itemStyle.shadowColor {string}

Outline shadow color.

backgroundStyle.color {string}

Background fill color.

backgroundStyle.borderWidth {string}

Background stroke line width.

backgroundStyle.borderColor {string}

Background stroke line width.

backgroundStyle.itemStyle.shadowBlur {number}

Background shadow blur size.

backgroundStyle.itemStyle.shadowColor {string}

Background shadow color.

backgroundStyle.itemStyle.opacity {number}

Background opacity.

itemStyle.opacity {number}

Wave opacity.

itemStyle.shadowBlur {number}

Wave shadow width.

itemStyle.shadowColor {string}

Wave shadow color.

emphasis.itemStyle.opacity {number}

Wave opacity when hover.

label.show {boolean}

Whether to display label text.

label.color {string}

Color of text when display on background.

label.insideColor {string}

Color of text when display on wave.

label.fontSize {number}

Label font size.

label.fontWeight {string}

Label font weight.

label.align {string}

Text align, which should be 'left', 'center', or 'right'.

label.baseline {string}

Text vertical align, which should be 'top', 'middle', or 'bottom'.

label.position {string|string[]}

Text position is at the center by default. label.position can be set to be 'inside', 'left', 'right', 'top', 'bottom', or horizontal and vertical positions like ['10%', '20%'], which means '10%' to the left and '20%' to the top.

Build

For development:

$ webpack

For release:

$ webpack -p

Notice

The Apache Software Foundation Apache ECharts, ECharts, Apache, the Apache feather, and the Apache ECharts project logo are either registered trademarks or trademarks of the Apache Software Foundation.

echarts-liquidfill's People

Contributors

beadre avatar chriswong avatar ovilia avatar pissang avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

echarts-liquidfill's Issues

精简依赖?

建议这样,src 的版本依赖 echarts/lib/echarts,然后在 main 模块可以打包所有依赖。main 模块是 all-in-one 的包,src 模块只引用必要的。

否则我一个依赖 echarts/lib/echarts 的项目加载这个插件,不管怎么样都得重新加载一个 echarts 全集。

水球图导致的内存泄漏问题

One-line summary [问题简述]
水球图放置24小时的时间后, 会导致页面崩溃的等问题, 进一步观测, 其内存增长飞快, 怀疑是内存泄漏问题.

Version & Environment [版本及环境]
测试环境: win7.
chrome 浏览器:
image
开始记录时间: 20170921 11:17
开始时的内存: 78316k
如图所示:
image
结束时间: 20170921 13:30
结束时的内存: 792,328k
如图所示:
image

总结: 2个多小时, 内存增长了700多兆. 如果放置一个晚上, 会导致页面崩溃等问题.
Expected behaviour [期望结果]
内存不泄露, 水球图放置24小时不会导致页面崩溃.
ECharts option [ECharts配置项]

var  options = [
            {
                series: [{
                    type: 'liquidFill',
                    data: [0.6, 0.5, 0.4, 0.3],
                    outline: {
                        show: false
                    },
                    shape: 'container'
                }]
            }
            ];

4.0.2版本下水球图无法改变字体大小

var option = {
       series: [{
           type: 'liquidFill',
           name: 'Liquid Fill',
           data: [{
               name: 'xxISmart'
               //value: 0.6
           },1,0.9,0.8,0.7,0.6, 0.5, 0.4, 0.3],
           radius : '40%',
           label: {
               normal: {
                   //formatter: '{a}\n{b}\nValue: {c}',
                   textStyle: {
                       fontSize: 20
                   }
               }
           }
       }]
   };

series.data 的itemStyle.color 为图片时,图片显示不全。

如下代码:

series: [{
        type: 'liquidFill',
        data: [ {
          value: 0.74,
          direction: 'left',
          itemStyle: {
            shadowBlur:0,
            color: {
              image: wlimg, // 支持为 HTMLImageElement, HTMLCanvasElement,不支持路径字符串
              repeat: 'repeat-x' // 是否平铺, 可以是 'repeat-x', 'repeat-y', 'no-repeat'
            }
          }
        }],

mac电脑,chrome上只显示一半(下半部分),上半部分不显示。火狐浏览器下半部分为要渲染的图片,上半部分为纯色。

另外color使用渐变色时控制台报错。图表不显示。
如:

color:new echarts.graphic.LinearGradient(
                        0, 0, 0, 1,
                        [
                            {offset: 0, color: '#83bff6'},
                            {offset: 0.5, color: '#188df0'},
                            {offset: 1, color: '#188df0'}
                        ]
                    )

谢谢您共享了这么好的插件,我在使用中就差这一个小问题了。希望您能帮忙提供个解决方案。谢谢。

演示地址:渐变色的那一层就是图片。显示了一半。

https://ngdly.github.io/ngdly/echarts-liquidfill/water_ball.html

水位图在svg模式下出现波浪溢出的情况

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6]
    }]
};

水位图在svg模式下如果echarts租价过多的话出现波浪溢出的情况,现在水位图支持svg模式吗?
echarts:3.8.3;
浏览器:chrome62

require无法引用liquidFill.js

已加载echart4和liquidfill:

paths: {
"jquery" 		: 	jbasepath+ "/scripts/jquery-1.11.1.min",
'echarts4'         :    basepath+ "/js/echarts/echarts4",
'liquidfill'          :    basepath+ "/js/echarts/echarts-liquidfill"
},
 shim: {
		'jquery' : {
			exports: 'jquery'
		},
               'echarts4' : {
			deps:['jquery'],
			exports: 'echarts4'
		},
		'liquidfill' : {
			deps:['jquery','echarts4'],
			exports: 'liquidfill'
		}
      }

引入插件之后,生成水滴图报错

define(['jquery','echarts4','liquidfill'],function($, echarts, liquidfill) {
        var option = {
                series: [{
                    type: 'liquidFill',
                    data: [0.6],
                    radius: '70%'
                }]
            };
	   chart = echarts.init(document.getElementById('chart'));
	   chart.setOption(option);
}

报错内容

echarts4.js:11646 Uncaught Error: Component series.liquidFill not exists. Load it first.
    at Function.entity.getClass (echarts4.js:11646)
    at ExtendedClass.<anonymous> (echarts4.js:19832)
    at Array.forEach (<anonymous>)
    at each$1 (echarts4.js:505)
    at ExtendedClass.visitComponent (echarts4.js:19815)
    at Function.entity.topologicalTravel (echarts4.js:17240)
    at ExtendedClass.mergeOption (echarts4.js:19785)
    at ExtendedClass.initBase (echarts4.js:20316)
    at ExtendedClass.resetOption (echarts4.js:19727)
    at ExtendedClass.setOption (echarts4.js:19709)

webpack中引入echarts-liquidfill,运行报错

错误:Uncaught DOMException: Failed to execute 'arc' on 'CanvasRenderingContext2D': The radius provided (-12) is negative.
image

代码:

import echarts from 'echarts'
import 'echarts-liquidfill'
let option = {
series: [{
            type: 'liquidFill',
            data: [0.20, 0.30, 0.15, 0.10],
            radius: '19%'
        }]
}
humidityDashboard = echarts.init(document.getElementById('humidity-dashboard'))
humidityDashboard.setOption(option)

使用formatter无法设置label的不同样式

        label: {
            normal: {
                position: ['38%', '40%'],
                formatter: function() {
                    return 'ECharts\nLiquid Fill';
                },
                fontSize: 40,
                color: '#D94854'
            }
        }

可以让EChartsLiquid Fill的字体大小不同吗?

import 问题会出现 Cannot read property 'extendSeriesModel' of undefined

<template>
  <div class="water">
    <!-- <chart :options="option" auto-resize></chart> -->
    <div id="1" class ="water-body"></div>
  </div>
</template>
<style lang="scss">
.water {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  &-body {
    width: 100%;
    height: 100%;
  }
}
</style>
<script>
var echarts = require('echarts')
// import './echarts-liquidfill.js'
require('./echarts-liquidfill.js')
export default {
  name: 'b-water',
  data () {
    return {
    }
  },
  methods: {
    draw () {
      let id = '1'
      var chart = echarts.init(document.getElementById('' + id))
      let option = {
        series: [{
          type: 'liquidFill',
          // radius: '80%',
          data: [0.5, 0.45, 0.4, 0.3],
          // label: {
          //   normal: {
          //     // textStyle: {
          //     color: 'red',
          //     insideColor: 'yellow',
          //     fontSize: 40
          //     // }
          //   }
          // }
        }]
      }
      chart.setOption(option)
    }
  },
  mounted () {
    this.draw()
  }
}
</script>

echarts-for-react 使用echarts-liquidfill 报错 Uncaught Error: Component series.liquidFill not exists. Load it first.

import echarts from 'echarts'
import 'echarts-liquidfill';
import ReactCharts from 'echarts-for-react'


const liquidoption = {
            series: [{
                type: 'liquidFill',
                data: [0.6, 0.5, 0.4, 0.3],
                radius: '80%'
            }]
        }


<ReactCharts
            option={liquidoption}
            style={{ height: '340px', width: '100%', }} />


用的create-react-app 创建的项目,不管修改版本还是把js文件放到html里面都不行

一直报错
 Uncaught Error: Component series.liquidFill not exists. Load it first.

echarts 3.6.1 console 存在错误信息

代码

var option = {
    series: [{
        type: 'liquidFill',
        data: [0.6]
    }]
};

错误信息

如下图所示:
image

复现步骤

这个项目的 example 代码应该就可以看到错误。

或者

git clone git@github.com:hustcc/echarts-for-react.git

cd echarts-for-react

npm i

npm run build

然后打开项目根目录 index.html,查看 Liquidfill 这个实例。

## 原因

大概是因为本项目依赖 echarts 的版本号是直接写的大于,所以 echarts 升级之后,导致自动安装最新的 3.6.1,然后兼容出错,我在本地 node_modules 中删除 3.6.1 版本,重新 build 就可以了。

如何关闭点击事件?

hello,现在在项目可以很好的展示,但是点击的时候水球内填充的颜色会改变,请问博主如何禁止掉?

指定轮廓 SVG 时报错

经测试只发生于自定义 SVG 轮廓且 ECharts 版本 ≥ 3.4.0 (依赖的 zrender 版本从 3.2.2 切换为 3.3.0 了,估计是 zrender 3.3.0 造成的)时。

TypeError: path.setData is not a function

位置在 zrender/lib/tool/path.js 第 334 行。

disponse 警告

调用disponse 方法时报如下警告,望解决,谢谢
Method dispose should be implemented in liquidFill.

如何设置波浪淹没label后label的字体颜色

         var options= {
                    series: [{
                        type: 'liquidFill',
                        data: [{
                            name: 'demo',
                            value: 0.6,
                            itemStyle: {
                                normal: {
                                    color: 'rgb(12,78,117)'
                                }
                            }
                        }, {
                            value: 0.6,
                            itemStyle: {
                                normal: {
                                    color: 'rgb(0,170,255)'
                                }
                            }
                        }],
                        radius: '70%',
                        outline: {
                            show: false
                        },
                        label: {
                            normal: {
                                formatter: '{b}',
                                fontSize: 20,
                                color: 'yellow'
                            }
                        },
                        backgroundStyle: {
                            color: 'rgb(9,34,57)',
                            borderColor: 'rgb(0,170,255)',
                            borderWidth: 1
                        }
                    }]
                };

在webpack环境下,无法加载插件

import echarts from 'echarts';
import 'echarts-liquidfill';



var myChart2 = echarts.init(document.getElementById('main1'));

    myChart2.setOption({
      series: [{
        type: 'liquidFill',
        data: [0.6, 0.5, 0.4, 0.3],
        radius: '80%'
      }]
    });

代码引入如上 但还是报错
image

只能显示一种颜色

var option = {
        series: [{
          type: 'liquidFill',
          data: [0.5, 0.4, 0.3],
          color: ['gray', 'green', 'blue'],
          shape: 'container',
          outline: {
            show: false
          },
          label: {
            normal: {
              formatter: ''
            }
          },
          backgroundStyle: {
            color: '#FFF0'
          }
        }]
};

在echarts4.0中使用这个插件,发现只会显示一种颜色. 只显示color中的第一个颜色
透明度的修改也没有明显变化

image

click事件怎么写?

单击 或者其他事件怎么写. 使用官方的on方法绑定的事件对这个无效.如果能单独实现也可以, 能否给个示例?

echarts 4.0 upgrade

何时会对echarts 4.0进行支持,官方中说使用svg对水球图更合适,期待解决内存泄漏问题 ~

在webpack环境下,无法加载插件

// 引入 ECharts 主模块
var echarts = require('echarts/lib/echarts')
require('echarts/lib/chart/line')
// 引入提示框和标题组件
require('echarts/lib/component/tooltip')
require('echarts/lib/component/title')
require('echarts/lib/component/legend')

import 'echarts-liquidfill'

export default{
  methods:{
     buildChart (){
       if(this.taskChart==null)
           this.taskChart = echarts.init(document.getElementById("d_todayTask"))
        this.taskChart.setOption({
             series: [{
                 type: 'liquidFill',
                 data: [{
                                value: 1,
                                itemStyle: {
                                    normal: {
                                        color: '#f55',
                                        opacity: 0.6
                                    }
                                }
                            }],
                            name: 'Liquid Fill',
                            outline: {
                                show: false
                            }
                        }],
                        tooltip: {
                            show: true
                        },
         })
     }
  }
}

报错信息如下:
Error: Component series.liquidFill not exists. Load it first.

请问是否是我的引入资源方式不对(使用 echarts 自带的图表都是正常的)

非常感谢!

调用能显示但是报错

var option = {
tooltip: {
formatter: "{a}
{b} : {c}"
},
toolbox: {
show : true,
feature : {
mark : {show: false},
dataView : {show: true, readOnly: true},
//magicType : {show: true, type: ['line', 'bar']},
restore : {show: false},
saveAsImage : {show: true}
}
},
series: [{
type: 'liquidFill',
shape: 'circle',
data: [0.8, {
value: 0.75,
direction: 'left'
}],
radius: '70%',
outline: {
show: false
},
backgroundStyle: {
borderWidth: 2,
borderColor: '#156ACF'
},
amplitude: 10,
waveAnimation: true,
silent: false
}]
};

require 报错?

报错如下:
Uncaught Error: Mismatched anonymous define() module: function (WEBPACK_EXTERNAL_MODULE_2) ....

感觉这个 js 的插件化不够啊

萌新 落落的问 个问题

在vue中怎么引入 这个气泡球插件

Error: Component series.liquidFill not exists. Load it first.
堆栈跟踪:
clazz.enableClassManagement/entity.getClass@webpack-internal:///23:166:23
visitComponent/<@webpack-internal:///440:195:51
each@webpack-internal:///0:263:13
visitComponent@webpack-internal:///440:178:17
componentUtil.enableTopologicalTravel/entity.topologicalTravel@webpack-internal:///89:89:21
mergeOption@webpack-internal:///440:147:13
initBase@webpack-internal:///440:642:9
resetOption@webpack-internal:///440:92:21
setOption@webpack-internal:///440:74:13
echartsProto.setOption@webpack-internal:///1:279:9
initChart@webpack-internal:///208:65:7
boundFn@webpack-internal:///17:184:9
mounted@webpack-internal:///208:27:5
callHook@webpack-internal:///17:2666:9
insert@webpack-internal:///17:3527:7
invokeInsertHook@webpack-internal:///17:5470:9
patch@webpack-internal:///17:5640:5
lifecycleMixin/Vue.prototype._update@webpack-internal:///17:2425:16
updateComponent@webpack-internal:///17:2539:7
get@webpack-internal:///17:2882:13
run@webpack-internal:///17:2959:17
flushSchedulerQueue@webpack-internal:///17:2725:5
queueNextTick/<@webpack-internal:///17:702:11
nextTickHandler@webpack-internal:///17:649:7

Opinion

产品不错 [/赞]
波峰略高,希望能留有控制项可调节波峰

是否支持iOS开发呢?

您好,我这边用iOS的webview加载水球图是一块黑色的,没有出现需要的图。该插件是否支持移动端的开发呢?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.