英文:
Changing colors of ngx-echarts charts
问题
如何更改ngx-echarts中所有类型图表的颜色?
我已经尝试过(HTML):<div echarts [options]="chartOption" [theme]="colorScheme" class="demo-chart"></div>
(TypeScript):
colorScheme = {
domain: [
'#2FDF75',
'#246EB9',
'#BCD3F2',
'#323031',
'#FBFFF1',
'#CCFF90',
'#FFFF8D',
'#FF9E80'
]
};
颜色没有改变。我担心我的自定义主题格式可能不正确。我找不到关于如何轻松更改图表颜色的文档。
英文:
How to change the colors of all kind of charts in ngx-echarts?
Ive tried (html): <div echarts [options]="chartOption" [theme]="colorScheme" class="demo-chart"></div>
(ts):
colorScheme = {
domain: [
'#2FDF75',
'#246EB9',
'#BCD3F2',
'#323031',
'#FBFFF1',
'#CCFF90',
'#FFFF8D',
'#FF9E80'
]
};
The colors do not change. I am afraid that the format of my custom theme is not the right one. I couldnt find any documentation on how to change the colors of the charts in an easy way.
答案1
得分: 1
你可以在选项中使用 color 属性
import { Component } from '@angular/core';
@Component({
selector: 'app-your-component',
templateUrl: './your-component.component.html',
styleUrls: ['./your-component.component.css']
})
export class YourComponent {
chartOption: any;
constructor() {
this.chartOption = {
color: ['#2FDF75', '#246EB9', '#BCD3F2', '#323031', '#FBFFF1', '#CCFF90', '#FFFF8D', '#FF9E80'],
// 其他图表选项...
};
}
}
HTML
<div echarts [options]="chartOption" class="demo-chart"></div>
示例链接 点击..
希望对你有所帮助..
英文:
you can use the color property in the option
import { Component } from '@angular/core';
@Component({
selector: 'app-your-component',
templateUrl: './your-component.component.html',
styleUrls: ['./your-component.component.css']
})
export class YourComponent {
chartOption: any;
constructor() {
this.chartOption = {
color: ['#2FDF75', '#246EB9', '#BCD3F2', '#323031', '#FBFFF1', '#CCFF90', '#FFFF8D', '#FF9E80'],
// your other chart options...
};
}
}
HTML
<div echarts [options]="chartOption" class="demo-chart"></div>
example link click..
hope it helpful..
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论