【发布时间】:2021-07-23 10:27:16
【问题描述】:
我正在使用 EXTJS 7.3.1 制作面积图,我希望能够根据数据值自定义标记颜色。
我该怎么做。
目前,标记是为整个图表设置的。像这样enter image description here
我想在值
请告诉我
【问题讨论】:
-
请提供小提琴样本。
标签: extjs charts colors markers
我正在使用 EXTJS 7.3.1 制作面积图,我希望能够根据数据值自定义标记颜色。
我该怎么做。
目前,标记是为整个图表设置的。像这样enter image description here
我想在值
请告诉我
【问题讨论】:
标签: extjs charts colors markers
您需要为系列创建自定义渲染器函数see here in the documentation。
类似这样的:
series: [{
// your series definition, including marker etc.
,renderer: function(sprite, config, rendererData, index) {
// renderer function must return the changes
var changes = {};
// get current record in the chart's store
var record = rendererData.store.getData().items[index];
// check value only when it is a marker
if (config.type === 'marker') {
// replace 'fieldName' with your fieldname
// and color1 color2 with the desired colors
changes.fillStyle = record.data.fieldName < 75 ?
'color1' : 'color2';
}
return changes;
}
}],
【讨论】: