tnblog
首页
视频
资源
登录

echarts 图表颜色设置,饼图颜色渐变

2197人阅读 2024/3/16 11:05 总访问:837929 评论:0 收藏:0 手机
分类: .net

echarts 图表颜色设置

在外层加一个color数组就行了

  1. color:["#1890FF","#91CB74","#FAC858","#EE6666","#73C0DE","#3CA272"],

color数组在顶层位置的

  1. option = {
  2. title: {
  3. text: '消息来源',
  4. subtext: '',
  5. left: 'center'
  6. },
  7. tooltip: {
  8. trigger: 'item'
  9. },
  10. legend: {
  11. orient: 'vertical',
  12. left: 'left'
  13. },
  14. // 这里设置
  15. color:["#1890FF","#91CB74","#FAC858","#EE6666","#73C0DE","#3CA272"],
  16. series: [{}{}]
  17. ...

echarts饼图颜色渐变代码如下:

  1. series: [
  2. {
  3. name: 'Access From',
  4. type: 'pie',
  5. radius: ['30%', '50%'],
  6. center: ['30%', '50%'],
  7. top: 50,
  8. itemStyle: {
  9. normal: {
  10. color: (list) => {
  11. // 这里设置颜色与渐变色,注意 !! 这里的数组一定要和实际的类目长度相等或大于,不然会缺少颜色报错
  12. var colorList = [
  13. {
  14. colorStart:'#488BFF',
  15. colorEnd:'#9abffd'
  16. },
  17. {
  18. colorStart:'#26CEBA',
  19. colorEnd:'#8efaed'
  20. },
  21. {
  22. colorStart:'#FFC069',
  23. colorEnd:'#fadfba'
  24. },
  25. {
  26. colorStart:' #FD6865',
  27. colorEnd:'#f8b2b1'
  28. }
  29. ]
  30. return new echarts.graphic.LinearGradient(1, 0, 0, 0, [{ //左、下、右、上
  31. offset: 0,
  32. color: colorList[list.dataIndex]['colorStart']
  33. }, {
  34. offset: 1,
  35. color: colorList[list.dataIndex]['colorEnd']
  36. }])
  37. }
  38. }
  39. },
  40. data: [
  41. { value: 335, name: '苹果' },
  42. { value: 310, name: '三星' },
  43. { value: 234, name: '香蕉' },
  44. { value: 135, name: '西瓜' }
  45. ]
  46. }
  47. ]
更多颜色搭配
  1. itemStyle: {
  2. normal: {
  3. color: (list) => {
  4. // 注意 !!!!! 这里的数组一定要和实际的类目长度相等或大于,不然会缺少颜色报错
  5. var colorList = [
  6. {
  7. colorStart: '#488BFF',
  8. colorEnd: '#9abffd'
  9. },
  10. {
  11. colorStart: '#26CEBA',
  12. colorEnd: '#8efaed'
  13. },
  14. {
  15. colorStart: '#FFC069',
  16. colorEnd: '#fadfba'
  17. },
  18. {
  19. colorStart: '#FD6865',
  20. colorEnd: '#f8b2b1'
  21. },
  22. {
  23. colorStart: '#bdc2e8',
  24. colorEnd: '#e6dee9'
  25. },
  26. {
  27. colorStart: '#faada6',
  28. colorEnd: '#f5efef'
  29. },
  30. {
  31. colorStart: '#ef025e',
  32. colorEnd: '#ef025e'
  33. },
  34. {
  35. colorStart: '#a7876d',
  36. colorEnd: '#bdc0a8'
  37. },
  38. {
  39. colorStart: '#a6bce8',
  40. colorEnd: '#a6bce8'
  41. },
  42. {
  43. colorStart: '#6dc1f1',
  44. colorEnd: '#bcf1f2'
  45. },
  46. {
  47. colorStart: '#55abc1',
  48. colorEnd: '#77cbb1'
  49. }
  50. ]
  51. return new echarts.graphic.LinearGradient(1, 0, 0, 0, [{ // 左、下、右、上
  52. offset: 0,
  53. color: colorList[list.dataIndex]['colorStart']
  54. }, {
  55. offset: 1,
  56. color: colorList[list.dataIndex]['colorEnd']
  57. }])
  58. }
  59. }

温柔梦幻的渐变配色

  1. #feada6-->#f5efef
  2. #a8edea-->#fed6e3
  3. #bdc2e8-->#e6dee9
  4. #a1c4fd-->#c2e9fb
  5. #E3FDF5-->#FFE6FA
  6. #fddb92-->#d1fdff
  7. #fff1eb-->#ace0f9
  8. #e9defa-->#fbfcdb

欢迎加群讨论技术,1群:677373950(满了,可以加,但通过不了),2群:656732739。有需要软件开发,或者学习软件技术的朋友可以和我联系~(Q:815170684)

评价

echarts中tooltip 基本样式问题处理

在echarts中遇到几个样式问题,现总结如下:1、tooltip中样式中 值换行在tooltip中修改加上一句代码formatter:'{b0}:{c...

ionic3实战使用echarts图表(柱状图)

在公司有些东西需要投到大屏幕上去显示,也就是电视显示屏(安卓版的),但是我没普通的html代码并不能打包到上去安装使用...

echarts 显示坐标点。echarts 自定义显示坐标点。echarts 个性化坐标提升显示

最简单的显示出来,直接在series中对应的数据项里边设置一下label即可label: { show: true, position: 'top&...

echarts自定义图表提示框。鼠标指上去显示。echarts tooltip的使用

官方文档:https://echarts.apache.org/zh/option.html#tooltip 使用的是tooltip,如果只是要显示出来,直接设置trigger: ...

echarts修改横纵坐标颜色。修改折线图线的宽度

echarts修改横坐标颜色代码主要是这样的 axisLine:{ lineStyle:{ ...

echarts图例legend颜色各不相同图例legend空心圆

代码如下:legend: { // x:'right', //可设定图例在左、右、居中 // padding:[0,50,0,0], //...

echarts折线图使用示例。包含颜色渐变节点样式图例legend样式等

设计图如下 代码如下<!-- 学习趋势图 --> <template> <div class="learnTrendChartContainer&q...

echarts提示框tooltip属性

tooltip: { show: true, // 是否显示提示框组件 trigger: 'axis', // 触发类型('item',...

echarts 仪表盘gauge颜色渐变。echarts圆环进度条。echarts圆环进度条弧形

效果如下: 配置项代码如下// 基于准备好的dom,初始化echarts实例 const myChart = this.$echarts.init(document.getEl...

echarts 设置x坐标刻度的颜色

是使用axisLabel下面的颜色设置,不是nameTextStyle不要搞混了。nameTextStyle官方解释是坐标轴名称的文字样式,要和坐标轴...

echarts setoption 不重新渲染

Echarts渲染的逻辑如果 echarts 未实例化则进⾏实例化过程,⼀旦实例化,便会在div容器⽣成⼀个 echarts_instance属性,该...

echarts饼图通过grid设置位置不生效。饼图设置位置

grid 记得是平面直角坐标系的意思,而仪表盘、饼图这种,是通过设置中心点位置的方式定位的。所以仪表盘、饼图这种应该这样...

css弹性盒子flex布局

css弹性盒子由于版本不同浏览器问题造成了一些不同的写法display:flexbox;在google浏览器中如果使用下面的写法就不行displa...

可输入下拉文本框据输入动态加载数据 jquery-editable-select

用到一个jquery-editable-select的控件github地址:https://github.com/indrimuska/jquery-editable-select这个插件的原理是...

.net mvc分部页.net core分部页

.net分部页的三种方式第一种:@Html.Partial("_分部页")第二种:@{ Html.RenderPartial("分部页");}...
这一生多幸运赶上过你.
排名
8
文章
224
粉丝
7
评论
7
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:50010702506256
欢迎加群交流技术