Highcharts multiple series line charter, markers become invisible - highcharts

I have a need with HighCharts graphs to display a line chart with 3 series and triangle markers on the same line. I have this a JSFiddle that seems to be working ok, but if the points are too close together a whole series becomes invisible.
$(function () {
$('#container').highcharts({
title: {
text: null
},
chart: {
type: 'line',
plotBackgroundImage: null,
backgroundColor: 'transparent',
width: 350,
height: 520,
borderWidth: 0,
marginTop: 0,
marginBottom: 50,
marginLeft: 140,
},
legend: {
align: 'left',
verticalAlign: 'top',
layout: 'vertical',
x: 0,
y: 20
},
xAxis: {
type: 'datetime',
lineWidth: 2,
lineColor: "#FF0000",
label: {
enabled: true,
format: "{value}"
}
},
yAxis: {
labels: {
enabled: false
},
gridLineColor: '#197F07',
title: {
text: null
}
},
plotOptions: {
series: {
marker: {
radius: 8,
symbol: "triangle"
}
},
line: {
lineWidth: 0
}
},
series: [{
data: [
[Date.UTC(2010, 0, 1), 0],
[Date.UTC(2010, 5, 1), 0],
[Date.UTC(2010, 11, 1), 0]
],
color: "#FF0000",
name: 'Group 1',
}, {
data: [
[Date.UTC(2010, 2, 1), 0],
[Date.UTC(2010, 3, 1), 0],
[Date.UTC(2010, 8, 1), 0]
],
color: "#00FF00",
name: 'Group 2'
}, {
data: [
[Date.UTC(2010, 1, 1), 0],
[Date.UTC(2010, 6, 1), 0],
[Date.UTC(2010, 9, 1), 0],
[Date.UTC(2011, 5, 1), 0]
],
color: "#0000FF",
name: 'Group 3'
}]
});
});
In this case, on the jsfiddle, the green triangles are invisible unless you hover over them. If the chart width is set to 550, the green triangles become visible.
I'd like to find a way to make these visible at all times. Thanks!

I'm not sure why this problem occurs originally, but it seems to be solved by explicitly stating enabled: true for plotOptions.series.marker. Like this:
plotOptions: {
series: {
marker: {
enabled: true, // Added
radius: 8,
symbol: "triangle"
}
},
line: {
lineWidth: 0
}
}
See this updated JSFiddle demonstration.

Related

Highcharts:Remove the color area below the 2 series

I want fill color in between the 2 series.I tried setting the white color for the second series but the transparent first series color is visible.
yAxis: {
title: {
text: 'Billions'
},
},
tooltip: {
split: true,
},
plotOptions: {
area: {
lineColor: '#666666',
lineWidth: 1,
marker: {
lineWidth: 1,
lineColor: '#666666'
}
}
},
series: [{
name: 'Asia',
data: [502, 635, 809, 947, 1402, 3634, 5268],
color: '#A5E1D2',
lineColor: '#008484',
lineWidth: 2,
}, {
name: 'Africa',
data: [106, 107, 111, 133, 221, 767, 1766],
color: 'white',
lineColor: '#002E2E',
lineWidth: 2,
}
jsfiddle
You can use a linearGradient for the color of the first series and set the color to 'transparent' for the second series
series: [{
name: 'Asia',
data: [502, 635, 809, 947, 1402, 3634, 5268],
color: {
linearGradient: { x1: 0.02, x2: 0.98, y1: 0, y2: 1 },
stops: [
[0, 'green'],
[0.8, 'transparent'],
]
},
lineColor: '#008484',
lineWidth: 2,
}, {
name: 'Africa',
data: [106, 107, 111, 133, 221, 767, 1766],
color: 'transparent',
lineColor: '#002E2E',
lineWidth: 2,
}]
Here is a working fiddle:
https://jsfiddle.net/3k5t0r4v/
Here you can read more about how linearGradient works and other methods to style your highcharts:
Colors in Highcharts
This post helped
This is the updated jsfiddle
https://jsfiddle.net/diasraphael88/hdg83Lpw/
{
color: '#A5E1D2',
data: [3, 3, 2, 3, 3, 6, 3]
},{
color: '#A5E1D2',
data: [0, 0, 0, 0, 0, 0, 0]
},{
id: 'transparent',
color: 'rgba(255,255,255,0)',
data: [27,25,16,13,9,17,11]
}]
}, function(chart){
chart.get('transparent').area.hide();
});

Milestone Trendanalysis with Highcharts

Is it possible to make the following chart with Highcharts library?
It's a simple line chart but with inverted triangle shaped grid. Is there any predefined type or a way to customize the grid shape? Any pointers which will guide me to a proper direction would help. Thank you!
Another method of how to create this type of chart:
Demo
Highcharts.chart('container', {
chart: {
width: 500,
},
xAxis: {
opposite: true,
title: {
text: 'Report Date'
},
gridLineWidth: 1,
type: 'datetime',
categories: ['01/01/2012', '02/01/2012', '03/01/2012', '04/01/2012', '05/01/2012', '06/01/2012', '07/01/2012', '08/01/2012', '09/01/2012', '10/01/2012'],
tickmarkPlacement: 'on',
labels: {
rotation: -90,
y: -18
},
offset: -13,
lineWidth: 0,
max: 8.6,
},
legend: {
enabled: false
},
yAxis: {
title: {
text: 'Milestones'
},
categories: ['01/01/2012', '02/01/2012', '03/01/2012', '04/01/2012', '05/01/2012', '06/01/2012', '07/01/2012', '08/01/2012', '09/01/2012', '10/01/2012'],
tickmarkPlacement: 'on',
gridLineWidth: 1,
tickPosition: 'inside',
min: 0,
minPadding: 0,
startOnTick: false
},
series: [{
data: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9],
marker: {
enabled: false
},
color: 'grey',
enableMouseTracking: false,
animation: false
}, {
data: [6, 6, 6, 7, 8, 7, 7, 8, 8.5, 9]
}, {
data: [5, 5, 5, 6, 6.5, 6, 6.5, 7.5, 8]
}, {
data: [4, 4, 4, 5, 5.5, 5.5, 6]
}, {
data: [2, 2.5, 2.5, 3.5, 4]
}, {
data: [1, 1.5, 2]
}, {
type: 'arearange',
data: [[0, 0, -5], [9.2, 9, -5]],
color: 'white',
fillOpacity: 1,
marker: {
enabled: false
},
zIndex: -1,
enableMouseTracking: false,
animation: false
}]
});
There is no such series type. However, you can make it with fake polygon series that will hide half of the chart. Check demo and code posted below.
Code:
Highcharts.chart('container', {
chart: {
height: 500,
width: 500,
events: {
load: function() {
var chart = this,
polygon = chart.series[2].group,
x = polygon.translateX,
y = polygon.translateY;
polygon.translate(x + 3, y + 3);
}
}
},
legend: {
enabled: false
},
credits: {
enabled: false
},
xAxis: {
opposite: true,
gridLineWidth: 1,
gridLineColor: '#ddd',
tickInterval: 1,
maxPadding: 0,
lineWidth: 0,
max: 10,
min: 0
},
yAxis: {
maxPadding: 0,
tickInterval: 1,
gridLineColor: '#ddd',
max: 10,
min: 0
},
series: [{
name: 'Installation',
data: [8, 6, 7, 8, 7, 6]
}, {
name: 'Manufacturing',
data: [3, 2, 4, 4]
}, {
type: 'polygon',
animation: false,
showInLegend: false,
enableMouseTracking: false,
color: '#fff',
lineWidth: 10,
data: [
[0, 0],
[10, 0],
[10, 10]
]
}, {
type: 'line',
showInLegend: false,
enableMouseTracking: false,
data: [
[0, 0],
[10, 10]
],
color: '#ddd',
lineWidth: 1,
marker: {
enabled: false
}
}]
});
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/highcharts-more.js"></script>
<div id="container"></div>
Demo:
https://jsfiddle.net/BlackLabel/xL9taoym/1/
You can use Highcharts SVG Renderer to render triangle that covers half of the chart.
Check this demo: https://jsfiddle.net/BlackLabel/2boma9zs
events: {
load: function() {
var chart = this,
left = chart.plotLeft,
top = chart.plotTop,
width = chart.plotSizeX,
height = chart.plotSizeY;
chart.renderer.path([
'M', left + 1, top + height,
'L', left + width + 1, top,
left + width + 3, top,
left + width + 3, top + height + 3,
left + 1, top + height + 3,
left + 1, top + height
])
.attr({
fill: '#fff'
})
.add()
.toFront();
}
}
API Reference: https://api.highcharts.com/class-reference/Highcharts.SVGRenderer#path
https://api.highcharts.com/class-reference/Highcharts.SVGElement#toFront
https://api.highcharts.com/highcharts/chart.events.load

HighCharts Polar Labels in between of sectors of circle

I am working ReactHigh charts on polar graphs, I want my labels to come in between the sectors of the circle, they are coming on points but i dont want them to come there.
JSfiddle : https://jsfiddle.net/ra73mp0c/12/
Also I want a background color on each of the labels.
Graph as of now :
Desried Outcome :
Please help me .
Config of graph :
const config = {
chart: {
polar: true,
type: 'line',
width: 700,
backgroundColor: 'transparent',
plotBorderWidth: null,
margin: [0, 0, 0, 0],
spacingTop: 0,
spacingBottom: 0,
spacingLeft: 0,
spacingRight: 0
},
title: {
text: null
},
pane: {
size: '80%'
},
xAxis: {
categories: [
'Sales',
'Sales',
'Sales',
'Sales',
'Marketing',
'Development',
'Customer Support',
'Customer Support',
'Customer Support',
'Information Technology'
],
labels: {
style: {
fontSize: '13px',
fontFamily: 'Verdana, sans-serif'
}
},
tickmarkPlacement: 'on'
},
yAxis: {
gridLineInterpolation: 'polygon',
min: 0,
tickInterval: 1,
max: 6
},
tooltip: {
shared: true
},
legend: {
enabled: false
},
credits: { enabled: false },
series: [
{
name: 'Allocated Budget',
data: [1, 2, 3, 1, 4, 3, 1, 2, 4, 1],
pointPlacement: 'between'
},
{
name: 'Actual Spending',
data: [2, 4, 2, 1, 3, 4, 2, 2, 1, 4],
pointPlacement: 'between'
}
]
}
Thanks a lot, It would be helpful ig you can edit the fiddle Link https://jsfiddle.net/ra73mp0c/12/
Creating that kind of background for x axis labels is not supported in Highcharts.
As a workaround you can create a phantom series that mimics their look:
{
showInLegend: false,
type: 'polygon',
name: 'Labels background',
data: [
[1, 5],
[2, 5],
[2, 6],
[1, 6]
],
zIndex: -9999
}
labels.distance should be a negative value to make it work.
Demo: https://jsfiddle.net/BlackLabel/63nc1csv/

Center tooltip for highcharts area chart

Since highcharts does not have a column chart where I can set height and width of each column, I have to use an area chart to accomplish this. So basically I am using area charts to draw rectangles. The problem with area charts is that the tooltip is not centered but is always shown above one edge of the rectangle. Plus, I am drawing multiple rectangles on top of each other causing to show the tooltip of the wrong rectangle.
$('#container').highcharts({
chart: {
type: 'area',
zoomType: 'x'
},
xAxis: {
type: 'datetime'
},
yAxis: {
title: {
enabled: false
}
},
plotOptions: {
area: {
marker: {
enabled: false,
states: {
hover: {
enabled: false
}
}
},
fillOpacity: 1
}
},
tooltip: {
enabled: true
},
series: [{
name: 'Year',
color: '#0d233a',
data: [
[Date.UTC(2017, 0, 1), 0],
[Date.UTC(2017, 0, 1), 4],
[Date.UTC(2017, 11, 31), 4],
[Date.UTC(2017, 11, 31), 0]
],
zIndex: 4,
fillColor: '#0d233a',
lineColor: '#fff'
}, {
name: 'Half year',
id: 'Half',
color: '#2f7ed8',
data: [
[Date.UTC(2017, 0, 1), 0],
[Date.UTC(2017, 0, 1), 10],
[Date.UTC(2017, 5, 31), 10],
[Date.UTC(2017, 5, 31), 0]
],
zIndex: 3,
fillColor: '#2f7ed8',
lineColor: '#fff'
}, {
name: 'Half year',
linkedTo: 'Half',
data: [
[Date.UTC(2017, 6, 1), 0],
[Date.UTC(2017, 6, 1), 6],
[Date.UTC(2017, 11, 31), 6],
[Date.UTC(2017, 11, 31), 0]
],
zIndex: 3,
fillColor: '#2f7ed8',
lineColor: '#fff'
}]
});
For an example see this fiddle.
You can see that the tooltip is not centered and that a wrong tooltip is shown when hovering the dark blue rectangle. Does anyone know how to fix this?
If all the columns within one series are the same width, you can try to do this with a normal column chart, using tightly packed columns and multiple xAxis:
...
xAxis: [{
type: 'datetime',
}, {
type: 'datetime',
}],
plotOptions: {
column: {
grouping: false,
groupPadding: 0,
pointPadding: 0,
pointPlacement: 'between',
},
},
series: [{
name: 'Year',
data: [
[Date.UTC(2016, 0, 1), 3],
[Date.UTC(2017, 0, 1), 4],
],
zIndex: 4,
color: '#222'
}, {
name: 'Half year',
xAxis: 1,
data: [
[Date.UTC(2016, 0, 1), 8],
[Date.UTC(2016, 6, 1), 11],
[Date.UTC(2017, 0, 1), 10],
[Date.UTC(2017, 6, 1), 6],
],
zIndex: 3,
color: 'royalblue',
}],
http://jsfiddle.net/j1fnkt01/3/
Note: Zooming won't work properly until the x-axes can be properly linked (linkedTo), and this issue prevents us from doing that right now.
You can use tooltip.followPointer to get desired result
Whether the tooltip should follow the mouse as it moves across columns, pie slices and other point types with an extent. By default it behaves this way for scatter, bubble and pie series by override in the plotOptions for those series types.
For touch moves to behave the same way, followTouchMove must be true also.
Defaults to false.
Tooltip will be
tooltip: {
enabled: true,
followPointer: true
},
Fiddle demo
Update
Use plotOptions.area.trackByArea to show tooltip properly
So plotOptions will be
plotOptions: {
area: {
marker: {
enabled: false,
states: {
hover: {
enabled: false
}
}
},
fillOpacity: 1
},
series: {
trackByArea: true,
stickyTracking: false,
}
},
updated fiddle

Show the chart on IE7?

I have some problem with IE 7 to show the chart I designed by Highstock.
When I've tried to design the chart and see it on Chrome, it does not have any problem.
Here is the chart which is exactly I want to see.
http://211.47.191.60/temp/Cap_origin_from_chrome
However, when I've tried to see it on IE 7, it shows like this.
http://211.47.191.60/temp/Cap_from_IE7
Here is the javascript source I've designed through using Fiddle.
$(function () {
// Create the chart
window.chart = new Highcharts.StockChart({
chart: {
renderTo: 'container',
type: 'areaspline',
backgroundColor: '#FFFFFF',
shadow: true
},
credits: {
enabled: false
},
rangeSelector: {
buttons: [{
type: 'day',
count: 1,
text: '1D'
}, {
type: 'day',
count: 15,
text: '2W'
}, {
type: 'month',
count: 1,
text: '1M'
}, {
type: 'month',
count: 3,
text: '3M'
}, {
type: 'month',
count: 6,
text: '6M'
}, {
type: 'year',
count: 1,
text: '1Y'
}, {
type: 'all',
text: '전체'
}],
inputStyle: {
color: '#039'
},
labelStyle: {
color: 'silver'
},
selected: 1
},
navigator: {
enabled: false
},
xAxis: {
//categories: ['1회차', '2회차', '3회차', '4회차', '5회차', '6회차', '7회차'], // 동적으로 늘려야 함
showFirstLabel: false,
showLastLabel: true,
tickPixelInterval: 150,
tickColor: 'green',
tickLength: 10,
tickWidth: 2,
tickPosition: 'inside',
//type: 'datetime',
//dateTimeLabelFormats: {
// day: '%Y<br/>%m-%d',
// week: '%Y<br/>%m-%d',
// month: '%Y-%m',
// year: '%Y'
//},
labels: {
rotation: -30,
y: 10
}
},
yAxis: {
tickPixelInterval: 40,
tickColor: 'gray',
tickLength: 10,
tickWidth: 2,
tickPosition: 'inside',
gridLineWidth: 1,
gridLineDashStyle: 'longdash',
minorGridLineColor: '#FFF0F0',
minorGridLineWidth: 1,
minorTickInterval: 'auto',
min: 0,
max: 100,
plotLines: [{
value: 90, // DB 에서 평가 기준 받아와 저장 필요
width: 3,
color: 'red',
dashStyle: 'dash',
label: {
text: '평가기준',
align: 'top',
y: -4,
x: 12
}
}],
title: {
align: 'high',
offset: 0,
text: '종합품질점수',
rotation: 0,
y: -10
},
labels: {
formatter: function () {
return this.value + ' 점';
},
x: -30
}
},
plotOptions: {
series: {
marker: {
enabled: true
}
}
},
scrollbar: {
enabled: true,
minWidth: 5,
barBackgroundColor: 'gray',
barBorderRadius: 7,
barBorderWidth: 0,
buttonBackgroundColor: 'gray',
buttonBorderWidth: 0,
buttonArrowColor: 'yellow',
buttonBorderRadius: 7,
rifleColor: 'yellow',
trackBackgroundColor: 'white',
trackBorderWidth: 1,
trackBorderColor: 'silver',
trackBorderRadius: 7
},
series: [{
name: '종합품질점수',
data: [{
name: '1회차',
color: 'red', //평가 기준 만족 시 blue, 불만족시 red
events: {
click: function () {
alert("!!!!");
}
},
x: Date.UTC(2013, 0, 1),
y: 32
}, {
name: '2회차',
color: 'red', //평가 기준 만족 시 blue, 불만족시 red
events: {
click: function () {
alert("####");
}
},
x: Date.UTC(2013, 0, 2),
y: 41
}, {
name: '3회차',
color: 'red', //평가 기준 만족 시 blue, 불만족시 red
events: {
click: function () {
alert("####");
}
},
x: Date.UTC(2013, 0, 3),
y: 54
}, {
name: '4회차',
color: 'red', //평가 기준 만족 시 blue, 불만족시 red
events: {
click: function () {
alert("$$$$");
}
},
x: Date.UTC(2013, 0, 4),
y: 67
}, {
name: '5회차',
color: 'red', //평가 기준 만족 시 blue, 불만족시 red
events: {
click: function () {
alert("%%%%");
}
},
x: Date.UTC(2013, 0, 5),
y: 74
}, {
name: '6회차',
color: 'blue', //평가 기준 만족 시 blue, 불만족시 red
events: {
click: function () {
alert("^^^^");
}
},
x: Date.UTC(2013, 0, 6),
y: 85
}, {
name: '7회차',
color: 'blue', //평가 기준 만족 시 blue, 불만족시 red
events: {
click: function () {
alert("&&&&");
}
},
x: Date.UTC(2013, 0, 7),
y: 91
}],
type: 'area',
pointStart: Date.UTC(2013, 0, 1),
pointInterval: 24 * 3600 * 1000,
showInLegend: true,
threshold: null,
tooltip: {
valueDecimals: 2
},
fillColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 1,
y2: 1
},
stops: [
[0, Highcharts.getOptions().colors[0]],
[1, 'rgba(0,0,0,0)']
]
}
}]
});
});
There is some Korean character, please do not mind about it.
Can anyone help me to solve this problem?
It looks like bug with plotLines in Highcharts, reported: https://github.com/highslide-software/highcharts.com/issues/1478
Possible workaround is to add plotLine in callback, see example: http://jsfiddle.net/f9aTL/12/ (still not perfect solution)
Callback:
function (chart) {
chart.yAxis[0].addPlotLine({
value: 90, // DB 에서 평가 기준 받아와 저장 필요
width: 3,
color: 'red',
dashStyle: 'Dash',
label: {
text: '평가기준',
align: 'top',
y: -4,
x: 12
}
});
});

Resources