score:8
you can make a fake series as follows and provider marker to it.
$(function () {
var chart = new highcharts.chart({
chart: {
renderto: 'container',
type: 'line',
},
xaxis: {
categories: ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']
},
plotoptions: {
series: {
marker: {
enabled: true
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalalign: 'middle',
//borderwidth: 0
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4],
showinlegend : false,
marker:{enabled:false}
},{
name : "testing",
data : {},
marker : {symbol : 'square',radius : 12 }
}
]
});
});
working demo : demo
score:1
since highcharts 5 introduced styled mode, you can easily find the symbol elements, and change their attributes. to make the symbol square:
$(".highcharts-legend-item path").attr('stroke-width',16);
score:1
if you'd like a round symbol, you can use this: http://jsfiddle.net/kl5sghrx/3/
chart: {
events: {
load: function(){
$( ".highcharts-legend-item path" ).each(function( index ) {
$(this)
.attr('d','m10.1,15.3l10.1,15.3c-3,0-5.5-2.5-5.5-5.5v0c0-3,2.5-5.5,5.5-5.5h0c3,0,5.5,2.5,5.5,5.5v0 c15.6,12.8,13.2,15.3,10.1,15.3z')
.attr('fill', $( this ).attr('stroke'))
.attr('stroke-dasharray','0,0');
});
},
redraw: function(){
$( ".highcharts-legend-item path" ).each(function( index ) {
$(this)
.attr('d','m10.1,15.3l10.1,15.3c-3,0-5.5-2.5-5.5-5.5v0c0-3,2.5-5.5,5.5-5.5h0c3,0,5.5,2.5,5.5,5.5v0 c15.6,12.8,13.2,15.3,10.1,15.3z')
.attr('fill', $( this ).attr('stroke'))
.attr('stroke-dasharray','0,0');
});
}
},
}
score:2
for rectangular legend we need to set squaresymbol: false
.
highcharts.chart('container', {
chart: {
type: 'column'
},
title: {
text: 'round legend symbols'
},
xaxis: {
categories: ['jan', 'feb', 'mar', 'apr']
},
legend: {
symbolwidth: 16,
symbolradius: 0,
squaresymbol: false
},
series: [{
data: [1, 3, 2, 4]
}, {
data: [6, 4, 5, 3]
}, {
data: [2, 7, 6, 5]
}]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<div id="container" style="height: 400px"></div>
score:5
all answers are correct but i found a pretty hack method. replacing legend rectangle symbol with square:
legend: {
symbolheight: 12,
symbolwidth: 12,
symbolradius: 6
}
score:12
this is a copy of the question: how to access legendsymbols and change their shape in highcharts
it has a similar answer and two others:
first option:
highcharts.seriestypes.line.prototype.drawlegendsymbol =
highcharts.seriestypes.area.prototype.drawlegendsymbol;
second option:
you can change the stroke-width
attribute on the path element.
we can provide functions to highcharts that will be drawn whenever the chart is drawn. since redraw
is not called on the first drawing the load
event is needed
chart: {
events: {
load: function () {
$(".highcharts-legend-item path").attr('stroke-width', 10);
},
redraw: function () {
$(".highcharts-legend-item path").attr('stroke-width', 10);
}
}
},
score:25
it's possible to achieve square legend symbols via configuration. just set legend.symbolradius
value to 0
.
jsfiddle demo: https://jsfiddle.net/9bzy2qzq/
Source: stackoverflow.com
Related Query
- Highcharts: Make the legend symbol a square or rectangle
- Highcharts -> how to add vertical title to bar? how to make the symbol in the legend a rectangle?
- How do i color the highcharts legend square symbol when my chart has multiple color entries
- Highcharts - How to display legend symbol inside the tooltip
- Is it possible to hide the line & symbol next to Highcharts legend items?
- Make only one legend active in HighCharts at the start
- Make the legend disappear in Highcharts
- Highcharts - How to Make the legend item width half of the contianer?
- How to display legend in Highcharts Waterfall Chart and make the sum column of waterfall appear in multiple colors?
- HighCharts Hide Series Name from the Legend
- HighCharts - Make the pie chart 100% of the div
- Hiding a Highcharts series without using the legend
- Highcharts - Legend Positioning outside the chart
- How to Check and Uncheck all the Legend elements in HighCharts Linechart?
- Highcharts Symbol in Legend
- How do I remove the color swatch from my HighCharts legend without affecting the column?
- Highcharts legend symbol sizes for scatter charts
- highcharts legend items align to the left when width is set
- Changing the contents of Highcharts legend
- Custom Highcharts legend symbol
- Highcharts solidgauge legend symbol not taking series color
- Change legend symbol in Column Chart in highcharts
- Highcharts : How do I keep the marker formatting and make the click event fire with a 5K+ point scatter plot?
- Make highcharts fullscreen also fullscreen the div wrapping the chart
- how to display 2 same highcharts without duplicate the code
- Highcharts heatmap - disabling the legend results in different colors
- Set custom legend item symbol (or icon) in HIghcharts
- Use of DotNet HighCharts dll to make charts in code behind
- How to update the highcharts.js to make the export server to my own ipaddress,instead of connect to the highcharts server?
- How to make legend color show up in Highcharts for a line graph under certain conditions?
More Query from same tag
- HighCharts Export Hide Scrollbars
- How to align centre a custom label in highcharts
- Customise Highcharts Pie Chart Selection State so that slice does not animate out when selected
- combine column and splines highcharts using mysql
- Why won't my HighCharts chart render?
- Highcharts angular 2 with observables http request
- Incorrect JSON data format
- Pie chart properties
- Highcharts and highstock license with google ads web site
- How make a growth baby chart with data in mysql +PDO
- Highmaps Kentucky isn't highlighted when printing using US-All map
- Is it possible to plot a chat like the below screenshot using highcharts?
- Formatter Function not working in Highstocks
- Highcharts pie/variablepie align multilines label on plotedge
- How to add table on click over each column in Highcharts Reactjs?
- Highcharts Custom SVG Marker Symbol is Shaped Different in Legend
- Highcharts 'area' type with normal stacking looks weird
- R - arrange bars in grouped hchart
- Highcharts - show series values outside chart container?
- Changing the epoch to respective timezone in Highcharts and showing the time on x-axis
- Creating a responsive accumulated rain chart from a series containing individual rain fall data using Highcharts
- Set a Different Color Per Region/Province in a Country
- Highchart Data from HTML table with line series
- Area Chart with overlapping series in highcharts, overlap point behaving strangely
- give highchart correct parametr from directive angularjs
- How to set border on a 3d pie highchart?
- highcharts - show by month
- Hightcharts max 19 is rounded op to 20
- Use server-side json with Highchart
- How to plot horizontal lines over the some columns of columnrange chart in Highcharts