我需要获取此图表https://cloud.mail.ru/public/Kajv/qPJtoerE5我遇到线条阴影问题。我尝试使用linerGradient,但我没有得到我需要的东西......拜托,帮助我吧。也许有人知道另一种创建这样一个图表的方法。
P.S。:我也试过Chart.js
Hightchart的代码
var myChart = Highcharts.chart('highchart', {
chart: {
type: 'spline',
zoomType: 'x',
backgroundColor: 'rgba(255,255,255,0)',
selectionMarkerFill: 'rgba(0,0,0,0.12)',
spacing: [30,32,6,32]
},
title: {
text: ''
},
xAxis: {
type: 'datetime',
lineColor: '#31313f',
tickColor: '#2c2c3a',
labels: {
format: '<text style="display: block; font: 600 8px/12px \'Graphik LCG\', sans-serif; text-transform: uppercase; color: rgba(255,255,255,0.6);">{value:%H:%M}</text>'
}
},
yAxis: {
title: {
text: null
},
gridLineColor: '#31313f',
min: 0,
max: 100,
labels: {
format: '<span style="font: 500 8px/12px \'Graphik LCG\', sans-serif; color: rgba(255,255,255,0.6);">{value}₽</span>',
align: 'left',
x: 0,
y: -2
}
},
plotOptions: {
series: {
marker: {
enabled: false
}
},
},
series: [{
data: [25,30,40,30,45,50,55,45,38],
pointStart: Date.UTC(2017, 10, 17, 10),
pointInterval: 3600 * 1000, // one hour
borderWidth: 2,
color: '#4974f5',
marker: {
fillColor: '#4974f5',
lineColor: '#2b2b38',
lineWidth: 2
}
}],
legend: {
enabled: false
},
tooltip: {
backgroundColor: '#32323f',
borderRadius: 10,
borderWidth: 0,
padding: 0,
shadow: false,
useHTML: true,
headerFormat: '<span style="display: block; margin-bottom: 2px; font: 600 8px/12px \'Graphik LCG\', sans-serif; text-align: center; text-transform: uppercase; color: rgba(255,255,255,0.6);">{point.key}</span>',
pointFormat: '<span style="display: block; font: 500 12px/16px \'Graphik LCG\', sans-serif; text-align: center; color: #fff;">{point.y}₽</span>',
footerFormat: '',
valueDecimals: 2
}
});
答案 0 :(得分:1)
此处的解决方案是在行系列中添加阴影并应用clipPath
。剪辑路径需要基于图形的路径。
现场演示: http://jsfiddle.net/kkulig/356gn4mv/
<强>影:强>
defs: {
shadow: {
tagName: 'filter',
id: 'shadow',
clipPath: 'url(#clipS)',
children: [{
tagName: 'feDropShadow',
dx: 0,
dy: 0,
stdDeviation: 10
}]
}
},
剪辑路径:
chart: {
events: {
load: function() {
var chart = this,
renderer = chart.renderer,
clipPathD = chart.series[0].graphPath.slice();
// modify the path so that it can be used as a clip (closed area)
clipPathD.splice(1, 0, 0, chart.chartHeight, "L", 0, clipPathD[2], 'L');
clipPathD.push("L", chart.chartWidth, clipPathD[clipPathD.length - 3], "L", chart.chartWidth, chart.chartHeight, "Z");
var clipPath = renderer.createElement('clipPath').add(renderer.defs).attr({
id: 'clipS'
});
renderer.path(clipPathD).add(clipPath);
}
}
},
<强> CSS:强>
.highcharts-graph {
filter: url(#shadow);
clip-path: url(#clipS);
}
有关SVG defs的文档: https://www.highcharts.com/docs/chart-design-and-style/gradients-shadows-and-patterns
API参考: https://api.highcharts.com/class-reference/Highcharts.SVGRenderer