Echarts Line chart set gradient background color

Source: Internet
Author: User
In the process of fault probability prediction, a line chart using Echarts is designed to display the predicted value of probability. According to the predicted results, the background color of the line chart is divided into 3 layers, from lower to upper the value of the probability from low to high, the color in turn becomes deeper, the effect is as follows:

Mainly uses the Markarea to the color stratification, the main code is as follows:

var dom = document.getElementById ("container"), var mychart = Echarts.init (DOM), var app = {};option = Null;option = {title: {text: ' line failure probability prediction ', left: ' 50% ', Top: ' 5% '},tooltip: {trigger: ' axis ', Axispointer: {//Axis indicator, axis trigger valid type: ' lines '//default is Lines, Optional: ' Line ' | ' Shadow '}},legend: {orient: ' vertical ', left: ' Left ', Data:[{name: ' Low failure rate ', Icon: ' Bar '}, {name: ' Medium failure rate ', Icon: ' Bar '}, {Nam E: ' High failure rate ', Icon: ' Bar '}],selected: {' Low failure rate ': true, ' evaporation ': true, ' Medium failure rate ': true, ' high failure rate ': true,//do not want to display set to False}},color:[' # 81b22f ', ' #f3d71c ', ' #f4b9a9 '],xaxis: {namelocation: ' center ', type: ' Category ', boundarygap:true,data:[' 10kV Dragon double Line ', ' 10kV Ziyang line ', ' 10kV dragon Heap line ', ' 10kV Longtan line '],show:true,axistick: {show:true},},grid: {top: ' 15% ', bottom: ' 5% ', containlabel:true}, YAxis: {namegap:35,name: ' fault occurrence probability (%) ', Min:0,max:4,splitnumber:10,type: ' Value ', AxisLabel: {formatter: ' {value} ',},}, Series: [//The main use from this place is Markarea and legend{name: ' Low failure rate ', type: ' line ', Animation:false,areastyle: {normal: {}}, LineStyle: {normal: {Width:1}},markArea: {data: [{yaxis: ' 0 '}, {yaxis: ' 1 '}]]},},{name: ' Medium failure rate ', type: ' line ', Animation:false,areastyle: {normal: {}}, LineStyle: {normal: {width:1}},markarea: {data: [{yaxis: ' 1 '}, {yaxis: ' 2 '}]]}},{name: ' High failure rate ', type: ' line ', animation: False,areastyle: {normal: {}},linestyle: {normal: {width:1}},markarea: {data: [{yaxis: ' 2 '}, {yaxis: ' 4 '}]]}},{name: ' Fault occurrence probability ', type: ' line ', data:[2.3, 0.5, 1.5, 3.44]},],}

This article explains the Echarts line chart set gradient background color of knowledge, more information please focus on the PHP Chinese web.

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.