score:0
In your HTML file, add:
<script src="https://code.highcharts.com/maps/modules/map.src.js"></script>
Above your chart code add:
Highcharts.addEvent(Highcharts.Chart.prototype, 'render', function() {
this.series.forEach(function(series) {
if (series.legendLine) {
var pathDef = series.legendLine.attr('d').split(' ');
pathDef[5] = parseFloat(pathDef[2]) + 0.0001;
series.legendLine.attr({
d: pathDef
});
}
})
});
The fix is in adding a smidge to your path definition (you can test this by going into the svg path element in dev tools and changing the last number in the 'd' attribute to a float:
<path fill="none" d="M 0 11 L 16 11" ... ></path>
becomes:
<path fill="none" d="M 0 11 L 16 11.1" ... ></path>
The function above goes through each series and massages the line data adding the fractional value in the right place. Total hack. However why the line does not appear if it does have this fractional value, I don't know. I would also test this across browsers to see that it works consistently as it may not (I tested in Chrome).
Here is a somewhat related issue where I cribbed the fix: https://www.highcharts.com/forum/viewtopic.php?t=38588 (Most of it is addressing a completely different problem, but the legend lines did show up so I investigated why).
If you don't want to use the extra library, you could probably write a native js function to find the legend lines and manipulate them in the same way.
score:0
In addition to @Katharine's solution, here's another I discovered.
If I enable the marker in one series (setting the radius to 0) and then put the data in a second series which is linked to the previous, it works. (If I do it all in one series, there is again no legend color.)
series: [{
name: 'purple', lineWidth: 3, color: {
linearGradient: [ 00, 00, 00, 350 ],
//linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1, },
stops: [
[0, 'purple'], // start
[1, 'black'] // end
],
},
data: [ 100, 95, 80, 60, 35, 50, 20, 10, 3, 2, 30, 40, ],
},{
marker: {
enabled: true,
radius: 0,
},
name: 'green', color: 'green', lineWidth: 3,
},{
linkedTo: ':previous',
lineWidth: 3, color: {
//linearGradient: [ 00, 00, 00, 350 ],
linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1, },
stops: [
[0, 'green'], // start
[1, 'black'] // end
],
},
data: [ 100, 100, 95, 80, 60, 35, 50, 20, 10, 3, 2, 30, ],
}],
Here's the "fixed" fiddle: https://jsfiddle.net/jwinkle/wztq78n1/6/
I reported the original issue as a possible bug to Highcharts, and they confirmed that it's an SVG rendering problem out of their control.
score:0
Here, you can find a nice explanation of the problem.
The difference results from the fact that Highcharts uses 'userSpaceOnUse'
as a default value for gradientUnits
if a gradient is defined as an array.
// Keep < 2.2 kompatibility
if (isArray(gradAttr)) {
(colorOptions as any)[gradName] = gradAttr = {
x1: gradAttr[0] as number,
y1: gradAttr[1] as number,
x2: gradAttr[2] as number,
y2: gradAttr[3] as number,
gradientUnits: 'userSpaceOnUse'
};
}
As a possible solution, you can set gradientUnits
also for linearGradient
defined as an object:
color: {
linearGradient: {
...,
gradientUnits: 'userSpaceOnUse'
},
...
}
Live demo: http://jsfiddle.net/BlackLabel/yz6sagxj/
Or modify the paths very slightly so that they are not perfectly horizontal
chart: {
events: {
render: function() {
this.series.forEach(function(series) {
if (series.legendLine) {
var pathDef = series.legendLine.attr('d').split(' ');
pathDef[5] = parseFloat(pathDef[2]) + 0.0001;
series.legendLine.attr({
d: pathDef
});
}
})
}
}
}
Live demo: http://jsfiddle.net/BlackLabel/L1kzg0cn/
Github thread: https://github.com/highcharts/highcharts/issues/1936
Source: stackoverflow.com
Related Query
- How to make legend color show up in Highcharts for a line graph under certain conditions?
- HIGHCHARTS How to to make separate colors for shaded region and the line in Area Graph
- How to change area graph color above certain value in Highcharts
- How do I use dates from a LinkedHashMap for the x-axis on a Highcharts line graph (using Thymeleaf)?
- Highcharts - Show a string category label in the tooltip for a line graph
- How to show horizontal line instead of a dot for a single value data in highcharts
- How to show labels selectively in certain points in Line chart of HighCharts
- How can I show colorAxis color in Highcharts legend as series color?
- How to show real time HighCharts Line Graph data which is receiving by an API?
- How to make highcharts default to 0 for missing data
- How to make stacked column graph to show total data value on top
- How do I set highcharts line graph point colors to an array of colors?
- Highcharts - Color coded legend for solid gauge
- How do I remove the color swatch from my HighCharts legend without affecting the column?
- How to customize the crosshair Line for Highcharts
- Make stack label disabled for a column in stacked column graph in Highcharts
- How to show 0 for incomplete Series in Highcharts
- How to color series legend in highcharts when colorbypoint is set to true
- In highcharts how do I change the color of the line above the categories?
- How To Show All Data Labels For Datetime Axis In Highcharts
- How To Call A Function To Make A Graph Using HighCharts in PHP
- How can I make a graph with highcharts from csv file?
- Highcharts - In area chart how to use gradient color for multiple series?
- how can i add in highcharts a different dashStyle just for a part of the graph
- How to change the color of highcharts series graph to black & white during downloading it as an image?
- HighCharts - how to set labels font color for printing?
- How to make two charts using highchart show up in the same line side by side using div
- How to display line break for irregular time series with highcharts
- Why does this Highcharts graph only show tooltip for the first and last nodes?
- How to show the legend in HighCharts
More Query from same tag
- HighChart Line Graph not Showing
- highcharter animation in flexdashboard
- Why can't my code access this variable?
- Set custom image from bottom to top inside bars of bar graph (using highcharts)?
- Recveived error from phantomjs:ERROR: While rendering, there's is a timeout reached
- Binding empty array to chart
- Highcharts Scatter Chart Data Point Hover
- Angular.js, Highcharts, Phantomjs PDF printer - graphs not showing up
- Highcharts update chart scroll issue- scroll to initial position
- How to call a plugin in CakePHP 2.x Shell?
- Highcharts return undefined value at a lot of data
- How to change time in hours on HighChart xAxis from Military to Standard time?
- How to increase weight of wordcloud for weight value less than 5 in highcharts
- Custom Highcharts Context Menu Button Appearing in Every Chart on Page
- Is there a way of implementing shades of colors in treemap for childs of specific parent
- highcharts tick position incorrect when categories specified
- highcharter both nominal and percentage values
- Highcharts series data select point video sync
- Can highcharts heatmap zone pattenObjects respect colors applied by color axis?
- Highcharts Grouped Column with Time Series
- How to elegantly plot charts in ASP.NET MVC 3 using Highcharts?
- Highcharts :Cannot read property 'parentGroup' of undefined with AngularJS
- Highcharts showing points on hovering over the line which are outside the chart area when the chart is zoomed in
- Highchart is not defining angular 9
- highchart created using value from mysql, how to export it using phantomjs
- Highcharts: Custom area outline for line joining each marker
- Highcharts more and highcharts guage issue
- Highcharts - is it possible to maintain grouping in scatter chart
- Add more data to High-chart X axis
- highcharts x-axis irregular date intervals issue