Solve the problem of Echart (1.4.1) column chart not changing color with value

Source: Internet
Author: User

Echart1.4.1



If it is the latest 2.2.7, you can refer to the website provided by Http://echarts.baidu.com/doc/example/bar15.html

If it is 1.4.1, then if the function (params) is written in color, the params does not have so many parameters to the 2.2.7, and if the color changes with the value, this can be done

var Zrcolor = require (' Zrender/tool/color ');


var colorno=0;//set Column chart function Setcolumnchart (x_value,y_value,colorbegin,colorend) {option_column.xaxis[0].data=x_ value;option_column.series[0].data=y_value;option_column.series[0].itemstyle.normal.color= function (params) {// Gets the array of gradient colors between the two colors var colorlist = zrcolor.getstepcolors (colorbegin,colorend, 100);//Gets the number of values in the array var item=parseint (y_value[ Colorno]) var curcolor=colorlist[item];//is used to iterate through the numeric array colorno++;//the completion value, reset the control variable if (colorno==y_value.length) {colorno=0 ;}                        return curcolor;                    } Mychart_column.setoption (Option_column);  }


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Solve the problem of Echart (1.4.1) column chart not changing color with value

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.