angular - 基于百分比的高图背景
问题描述
我从 2 天开始使用角离子中的高图尝试这种设计除了价值,什么都没有显示有没有其他选择,或者我们也可以在高位图表中实现它
this.moistureGraphOptions = {
chart: {
events: {
load: function () {
var chart = this,
xAxis = chart.xAxis[0],
plotLines = xAxis.plotLinesAndBands,
newOptions,
coordinates = [];
plotLines.forEach(function (plot, index) {
if (plot.id === 'gradient-plot-line') {
var plotLine = plot,
path = plot.svgElem.d.split(' ');
coordinates = [
+path[1],
+path[2],
+path[4],
+path[5]
];
newOptions = plotLine.options;
newOptions.color = {
linearGradient: [0, 0, 0, coordinates[1] + 247],
stops: [
[0, '#F7A35C'],
[1, '#7ACCC8']
]
};
}
xAxis.removePlotLine('gradient-plot-line');
});
xAxis.addPlotLine(newOptions);
}
}
},
title: {
text: null
},
xAxis: {
categories: [],
labels: {
style: {
fontSize: '13px',
fontFamily: 'Helvetica-light'
}
},
plotLines: [{
id: 'gradient-plot-line',
width: 400,
value: 5.5
}]
},
yAxis: [
{
title: {
text: 'Value',
},
},
],
credits: { enabled: false },
legend: {
layout: 'horizontal',
align: 'center',
verticalAlign: 'bottom',
},
series: [
{
name: 'Values',
yAxis: 0,
data: [],
color: '#d03c3f'
}
],
exporting: {
enabled: false
},
};
解决方案
您可以在事件中使用yAxis.plotBands
而不是自定义代码。load
yAxis: [{
reversed: true,
title: {
text: 'Value',
},
plotBands: [...]
}]
现场演示:http: //jsfiddle.net/BlackLabel/qdwp843m/
API 参考: https ://api.highcharts.com/highcharts/yAxis.plotBands
推荐阅读
- java - 如何将多模块项目从 eclipse 移动到 IDEA
- javascript - 如何在非字母字符上拆分字符串。正则表达式 JavaScript
- kotlin - Kotlin Flow:如何取消订阅/停止
- laravel - Bangla unicode 字体未在 mpdf 中显示
- azure-stream-analytics - 是否可以使用 azure 流分析基于给定的超时检测相关事件的缺失?
- php - 将数据保存到sql server时如何将符号'更改为`
- java - 违反了唯一约束 - 应该不可能,但仍然......为什么?
- vba - PL/SQL 数据库值未正确反映到 SSIS 脚本
- mysql - 如何将我的 Android 应用程序连接到存储在服务器中的 MySQL 数据库?
- go - 如何根据请求 URL 使用 golang GIN 路由 HTTP 请求