Home > front end >  According to conditions set colors problem echarts graphics
According to conditions set colors problem echarts graphics

Time:11-27

Has a set of target data, and a set of real data, a total of two sets of data, the corresponding comparison to size, if the actual value target size shows green, how to implement

CodePudding user response:

 



<meta HTTP - equiv="content-type" Content="text/HTML. Charset=utf-8 "/& gt;
_ & lt;/title> <br/><script SRC="https://cdn.bootcss.com/echarts/4.2.1/echarts.js" & gt; </script> <br/></head> <br/><body> <br/><Div id="chart" style="width: 800 px; Height: 480 px "& gt; </div> <br/><The script type="text/javascript" & gt; <br/>Var chart=echarts. Init (document. GetElementById (" chart ")); <br/>Var target=[120, 120, 120, 120, 120, 120, 120]. <br/>Var data=https://bbs.csdn.net/topics/[120, 200, 150, 80, 70, 110, 130]. <br/>For (var I=0; i <Data. The length; I++) {<br/>Data [I]={<br/>Value: data [I], <br/>ItemStyle: {<br/>Color: data [I] & gt;=target [I]? '# 0 a0' : '# c00' <br/>} <br/>} <br/>} <br/>Var option={<br/>XAxis: {<br/>Type: 'category', <br/>Data: [' Mon, Tue, Wed, Thu, Fri, Sat, 'Sun'] <br/>}, <br/>YAxis: {<br/>Type: 'value' <br/>}, <br/>Series: [{<br/>Data: data, <br/>Type: 'bar' <br/>}] <br/>}; <br/><br/>Chart. SetOption (option); <br/></script> <br/></body> <br/></html> <br/><br/></pre><p class="article - content rp"> CodePudding user response: </p>Thanks brother, if you can use color: the function implementation, to learn from you,<p class="article - content rp"> CodePudding user response: </p>The <fieldset> <legend> reference 1/f, sorry reply: </legend> <blockquote> <pre> <br/><! DOCTYPE html> <br/><html> <br/><head> <br/><meta HTTP - equiv="content-type" Content="text/HTML. Charset=utf-8 "/& gt; <br/><title> _ & lt;/title> <br/><script SRC="https://cdn.bootcss.com/echarts/4.2.1/echarts.js" & gt; </script> <br/></head> <br/><body> <br/><Div id="chart" style="width: 800 px; Height: 480 px "& gt; </div> <br/><The script type="text/javascript" & gt; <br/>Var chart=echarts. Init (document. GetElementById (" chart ")); <br/>Var target=[120, 120, 120, 120, 120, 120, 120]. <br/>Var data=https://bbs.csdn.net/topics/[120, 200, 150, 80, 70, 110, 130]. <br/>For (var I=0; i <Data. The length; I++) {<br/>Data [I]={<br/>Value: data [I], <br/>ItemStyle: {<br/>Color: data [I] & gt;=target [I]? '# 0 a0' : '# c00' <br/>} <br/>} <br/>} <br/>Var option={<br/>XAxis: {<br/>Type: 'category', <br/>Data: [' Mon, Tue, Wed, Thu, Fri, Sat, 'Sun'] <br/>}, <br/>YAxis: {<br/>Type: 'value' <br/>}, <br/>Series: [{<br/>Data: data, <br/>Type: 'bar' <br/>}] <br/>}; <br/><br/>Chart. SetOption (option); <br/></script> <br/></body> <br/></html> <br/><br/></pre> </blockquote> <fieldset> <br/>Thanks brother, if you can use color: the function implementation, to learn from you,<p class="article - content rp"> CodePudding user response: </p>Color tired skill function<p class="article - content rp"> CodePudding user response: </p>The <fieldset> <legend> reference 4 floor sorry reply: <legend> <blockquote> color tired skill function </blockquote> <fieldset> <br/>I wrote a paragraph can be realized, but I don't know how to compare after array size <br/><br/>ItemStyle: {<br/>//color: function (d) {<br/>//if (d.d ata. Value> 10000) {<br/>//return 'red' <br/>//} else {<br/>//return 'green' <br/>//} <br/>//the console log (d) <br/>//} <br/>//}<p class="article - content rp"> CodePudding user response: </p>Directly on the inside than line <img SRC="https://img.codepudding.com/202011/170630270122301.jpg" Alt=""/> <img SRC=" https://img.codepudding.com/202011/170630270122302.jpg "Alt=" "/><p class="article - content rp"> CodePudding user response: </p>Ok thank you, finally understand<p class="article - content rp"> CodePudding user response: </p><img SRC="https://img.codepudding.com/202011/170630270122303.gif" Alt=""/> how I use the function not come<p class="article - content rp"> CodePudding user response: </p>Map legend color does not support the function that how according to the parameters change color?<p class="article - content rp"> CodePudding user response: </p>The parameters in this function params definition, how to find it? I didn't effect <br/> write </div> <div class="th_page th_page_color"></div> <div class="umCopyright"> <p>Page link:<a href="/frontend/88373.html" target="_blank" style="color:#999">https//www.codepudding.com/frontend/88373.html</a></p> </div> <div class="detail-arr"> <div class="detail-arr-left">Prev:<a href='/frontend/88372.html'>How is this 360 - degree image, please? Thank you very much!</a></div> <div class="detail-arr-right">Next:<a href='/frontend/88374.html'>Help, how to fill the background image with the full change along with the container size change</a></div> </div> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="hot-tags neitags"> <ul> <li><i class="iconfont icon-x-tags"></i> Tags:  </li> <a href='/e/tags/?tagname=HTML+%28CSS%29' target='_blank'>HTML (CSS)</a> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="xiangguan"> <ul class="msg msghead"> <li class="tbname">Related</li> </ul> <ul> </ul> </div> </div> </div> </div> <div class="container th_top"> <div class="row"> <div class="col-md-12"> <div class="flinks"> <ul> <li><i class="iconfont icon-x-tags"></i> Links:  </li> <li class="liflinks"><a target="_blank" href="/" title="CodePudding">CodePudding</a></li> </ul> </div> </div> </div> </div> <div class="footer"> <p><span style="font-size:16px;color:#666;font-weight: bold">About Us:</span>  <a href="https://www.codepudding.com/contact.html">Contact Us</a>      <a href="https://www.codepudding.com/service.html">Terms of Service</a>      <a href="https://www.codepudding.com/privacy.html"> Privacy Policy</a></p> <p class="foot_info">Copyright © 2010-2023,Powered By <a href="/" target="_blank">CodePudding</a> </p> </div> <script type="text/javascript" src="/skin/code/tianhu.js"></script> </body></html>