admin管理员组文章数量:1406177
we have two kinds of highcharts graphs one line chart and one bar chart, we were required to draw lines on the chart based on some calculations. we used renderer to draw SVG Paths on both charts. the problem was when exporting (SVG, PNG, and PDF) the line charts export properly - includes our rendered lines. however, the bar chart doesnt, we used very similar code for the lines.
following is the code we used for the bar chart. it is very similar to the code we use for the line chart the only difference is the orientation and that the line chart has multiple series'
is there a difference between export for line charts and bar charts? can you pls advise what we can do to troubleshoot this?
here is a link to a jsfiddle. enter link description here
i do understand that highcharts now has error bars, but there are other specific requirements where we cant use it. the sample ive added above just shows a basic line render for your test thanks edwin
//this is the code we used for the line chart:
function (chart) {
//this disables interaction with the legend entries if trend
$.each(chart.series, function(i, series){
series.group.element.onmouseover = null;
});
const strokeWidth=1;
//this adds confidence intervals
if(ChartData.Configuration.IncludeConfidenceLevels=='Yes' && ChartData.Configuration.MetricHasConfidenceLevels=="Yes" ){
ChartData.HighChartData.forEach((row, index)=>{
row.Descriptors.forEach((item, itemSeries)=>{
let plotYLCI, plotYUCI, point1;
if(item.SuppressionFlag=='No'){
plotYLCI = chart.yAxis[0].toPixels(item.ConfidenceLow);
plotYUCI = chart.yAxis[0].toPixels(item.ConfidenceHigh);
point1=chart.series[index].data[itemSeries];
chart.renderer.path(['M', point1.plotX+ chart.plotLeft, plotYLCI, 'L', point1.plotX+ chart.plotLeft, plotYUCI])
.attr({'stroke-width': strokeWidth, stroke: row.color })//"black"})
.add()
chart.renderer.path(['M', point1.plotX+ chart.plotLeft-10, plotYLCI, 'L', point1.plotX+ chart.plotLeft+10, plotYLCI])
.attr({'stroke-width': strokeWidth, stroke: row.color })//"black"})
.add()
chart.renderer.path(['M', point1.plotX+ chart.plotLeft-10, plotYUCI, 'L', point1.plotX+ chart.plotLeft+10, plotYUCI])
.attr({'stroke-width': strokeWidth, stroke: row.color })//"black"})
.add()
}
})
})//end trend confidence intervals
}//ends confidence level IF
}//closes function chart
//this is the code we used for the comparison chart
function (chart) {
//this adds confidence intervals
if(ChartData.Configuration.IncludeConfidenceLevels=='Yes' && ChartData.Configuration.MetricHasConfidenceLevels=="Yes" ){
let i = 0,
yAxis = chart.yAxis[0],
r = chart.renderer,
tickWidth = ((ChartData.Configuration.ChartOrientation=='Horizontal') ? chart.plotHeight : chart.plotWidth) / chart.series[0].data.length,
len = ChartData.HighChartData[0].data.length;
for (i = 0; i < len; i++) {
if(ChartData.HighChartData[0].IsSuppressed[i]=='No'){
let confidenceIntervalLine= (ChartData.Configuration.ChartOrientation=='Horizontal')
? {
x1:chart.plotLeft + yAxis.translate(ChartData.HighChartData[0].Descriptors[i].ConfidenceLow),
y1:chart.plotTop + (i+0.5)*tickWidth,
x2:chart.plotLeft + yAxis.translate(ChartData.HighChartData[0].Descriptors[i].ConfidenceHigh),
y2:chart.plotTop + (i+0.5)*tickWidth
}
: {
x1:chart.plotLeft + (i+0.5)*tickWidth,
y1:chart.plotTop + chart.plotHeight - yAxis.translate(ChartData.HighChartData[0].Descriptors[i].ConfidenceLow),
x2:chart.plotLeft + (i+0.5)*tickWidth,
y2:chart.plotTop + chart.plotHeight - yAxis.translate(ChartData.HighChartData[0].Descriptors[i].ConfidenceHigh)
}
let
x1=confidenceIntervalLine.x1, y1=confidenceIntervalLine.y1, x2=confidenceIntervalLine.x2, y2=confidenceIntervalLine.y2, w=0.125*tickWidth;
//horizontal bar:
chart.renderer.path(['M', x1-1, y1-w-1, 'L', x1+1, y1-w-1,
'L', x1+1, y1-1, 'L', x2-1, y2-1,
'L', x2-1, y2-w-1, 'L', x2+1, y2-w-1,
'L', x2+1, y2+w+1, 'L', x2-1, y2+w+1,
'L', x2-1, y2+1, 'L', x1+1, y1+1,
'L', x1+1, y1+w+1, 'L', x1-1, y1+w+1,
'L', x1-1, y1-w-1
])
.attr({
//'stroke-width': strokeWidth,
//stroke: strokeColor,
zIndex:4
})
.addClass('confidenceClass')
.add();
}
}//ends the for loop
//ends bar confidence interval
}//ends confidence level IF
}//closes function chart
we have two kinds of highcharts graphs one line chart and one bar chart, we were required to draw lines on the chart based on some calculations. we used renderer to draw SVG Paths on both charts. the problem was when exporting (SVG, PNG, and PDF) the line charts export properly - includes our rendered lines. however, the bar chart doesnt, we used very similar code for the lines.
following is the code we used for the bar chart. it is very similar to the code we use for the line chart the only difference is the orientation and that the line chart has multiple series'
is there a difference between export for line charts and bar charts? can you pls advise what we can do to troubleshoot this?
here is a link to a jsfiddle. enter link description here
i do understand that highcharts now has error bars, but there are other specific requirements where we cant use it. the sample ive added above just shows a basic line render for your test thanks edwin
//this is the code we used for the line chart:
function (chart) {
//this disables interaction with the legend entries if trend
$.each(chart.series, function(i, series){
series.group.element.onmouseover = null;
});
const strokeWidth=1;
//this adds confidence intervals
if(ChartData.Configuration.IncludeConfidenceLevels=='Yes' && ChartData.Configuration.MetricHasConfidenceLevels=="Yes" ){
ChartData.HighChartData.forEach((row, index)=>{
row.Descriptors.forEach((item, itemSeries)=>{
let plotYLCI, plotYUCI, point1;
if(item.SuppressionFlag=='No'){
plotYLCI = chart.yAxis[0].toPixels(item.ConfidenceLow);
plotYUCI = chart.yAxis[0].toPixels(item.ConfidenceHigh);
point1=chart.series[index].data[itemSeries];
chart.renderer.path(['M', point1.plotX+ chart.plotLeft, plotYLCI, 'L', point1.plotX+ chart.plotLeft, plotYUCI])
.attr({'stroke-width': strokeWidth, stroke: row.color })//"black"})
.add()
chart.renderer.path(['M', point1.plotX+ chart.plotLeft-10, plotYLCI, 'L', point1.plotX+ chart.plotLeft+10, plotYLCI])
.attr({'stroke-width': strokeWidth, stroke: row.color })//"black"})
.add()
chart.renderer.path(['M', point1.plotX+ chart.plotLeft-10, plotYUCI, 'L', point1.plotX+ chart.plotLeft+10, plotYUCI])
.attr({'stroke-width': strokeWidth, stroke: row.color })//"black"})
.add()
}
})
})//end trend confidence intervals
}//ends confidence level IF
}//closes function chart
//this is the code we used for the comparison chart
function (chart) {
//this adds confidence intervals
if(ChartData.Configuration.IncludeConfidenceLevels=='Yes' && ChartData.Configuration.MetricHasConfidenceLevels=="Yes" ){
let i = 0,
yAxis = chart.yAxis[0],
r = chart.renderer,
tickWidth = ((ChartData.Configuration.ChartOrientation=='Horizontal') ? chart.plotHeight : chart.plotWidth) / chart.series[0].data.length,
len = ChartData.HighChartData[0].data.length;
for (i = 0; i < len; i++) {
if(ChartData.HighChartData[0].IsSuppressed[i]=='No'){
let confidenceIntervalLine= (ChartData.Configuration.ChartOrientation=='Horizontal')
? {
x1:chart.plotLeft + yAxis.translate(ChartData.HighChartData[0].Descriptors[i].ConfidenceLow),
y1:chart.plotTop + (i+0.5)*tickWidth,
x2:chart.plotLeft + yAxis.translate(ChartData.HighChartData[0].Descriptors[i].ConfidenceHigh),
y2:chart.plotTop + (i+0.5)*tickWidth
}
: {
x1:chart.plotLeft + (i+0.5)*tickWidth,
y1:chart.plotTop + chart.plotHeight - yAxis.translate(ChartData.HighChartData[0].Descriptors[i].ConfidenceLow),
x2:chart.plotLeft + (i+0.5)*tickWidth,
y2:chart.plotTop + chart.plotHeight - yAxis.translate(ChartData.HighChartData[0].Descriptors[i].ConfidenceHigh)
}
let
x1=confidenceIntervalLine.x1, y1=confidenceIntervalLine.y1, x2=confidenceIntervalLine.x2, y2=confidenceIntervalLine.y2, w=0.125*tickWidth;
//horizontal bar:
chart.renderer.path(['M', x1-1, y1-w-1, 'L', x1+1, y1-w-1,
'L', x1+1, y1-1, 'L', x2-1, y2-1,
'L', x2-1, y2-w-1, 'L', x2+1, y2-w-1,
'L', x2+1, y2+w+1, 'L', x2-1, y2+w+1,
'L', x2-1, y2+1, 'L', x1+1, y1+1,
'L', x1+1, y1+w+1, 'L', x1-1, y1+w+1,
'L', x1-1, y1-w-1
])
.attr({
//'stroke-width': strokeWidth,
//stroke: strokeColor,
zIndex:4
})
.addClass('confidenceClass')
.add();
}
}//ends the for loop
//ends bar confidence interval
}//ends confidence level IF
}//closes function chart
Share
Improve this question
edited Mar 6 at 14:38
edwin.koh
asked Mar 6 at 13:29
edwin.kohedwin.koh
33 bronze badges
0
1 Answer
Reset to default 0To fix the issue, update your .attr()
method to include:
.attr({
zIndex: 4,
fill: 'black',
stroke: 'white',
"stroke-width": 0.75
})
Demo:
https://jsfiddle/BlackLabel/ycxvfpoe/
本文标签: Highcharts export not including rendered linesStack Overflow
版权声明:本文标题:Highcharts export not including rendered lines - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744973154a2635356.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论