Highcharts Styling Questions - highcharts

I'm hoping for some help on styling a line Highchart.
I'm trying to get the graph here to look like the image:
Example of my graph
But I'm struggling to get the block colour lables?
Any help would be much appreciated!
Thanks
$('#container').highcharts({
chart: {
type: 'line',
plotBackgroundImage: 'images/fibre.jpg',
plotBorderWidth: 0,
/*,
marginRight: 130,
marginBottom: 25*/
},
title:
{
text : strTitle
},
tooltip:
{
enabled: false
},
xAxis:
{
categories: arrXAxis,
title:
{
text: strXTitle
},
},
yAxis:
{
title:
{
text: ''
},
labels: {
formatter: function() {
// return this.value +'?'
return('');
}
},
min: 0,
max: 10,
minorGridLineWidth: 0,
alternateGridColor: null,
gridLineWidth: 0,
plotBands:
[{
from: intRedStart,
to: intRedEnd,
color: 'rgba(229, 28, 36, 0.6)',
label:
{
text: 'High Risk',
style:
{
color: '#606060'
}
}
},
{
from: intAmberStart,
to: intAmberEnd,
color: 'rgba(239, 140, 30, 0.6)',
label:
{
text: 'Improvement',
style:
{
color: '#606060'
}
}
},
{
from: intGreenStart,
to: intGreenEnd,
color: 'rgba(43, 174, 115, 0.6)',
label:
{
text: 'Healthy',
style:
{
color: '#606060'
}
}
}
]
},
legend: {
/*
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -10,
y: 100,
borderWidth: 0*/
},
series:
[{
allowPointSelect: false,
showInLegend: false,
data: arrData
} /*, {
name: '1',
data: [10]
}, {
name: '2',
data: [0.9, 0.6, 3.5, 8.4, 13.5, 17.0, 18.6, 17.9, 14.3, 9.0, 3.9, 1.0]
}, {
name: '3',
data: [3.9, 4.2, 5.7, 8.5, 11.9, 15.2, 17.0, 16.6, 14.2, 10.3, 6.6, 4.8]
}*/]
});

You can set plotBackgroundImage for chart http://api.highcharts.com/highcharts#chart.plotBackgroundImage and then use plotBands
http://jsfiddle.net/JRhaS/2/
plotBands: [{ // mark the weekend
color: 'rgba(155,255,155,0.5)',
from: 0,
to: 100
},{ // mark the weekend
color: 'rgba(100,255,200,0.5)',
from:100,
to: 200
}],
},

If you look at the API doc for plotband labels, I think you should be able to do something similar to the image by playing around with the "style", "align" and "verticalAlign" properties. Hope this helps :)
Edit: It seems like the background color is not possible to set with the labels.style object. I guess this is because the label is an SVG element (a tspan to be more specific), so it does not support all the css that standard HTML elements does. You can however come closer to your goal by aligning the labels "top" and "left", and set the font color. If you really need the background color you may have a look at this: Background color of tspan element

Related

How we design 3d column chart in highcharts like in pic?

I want to design a chart as in pic in angular 8 highcharts.
I am able to design it in 2d. But i want it in 3d.
Can anyone give me a hint
My code for this is:
this.chartOptions = {
chart: {
// renderTo: "container",
type: "column",
options3d: {
enabled: true,
alpha: 20,
beta: 30,
depth: 200,
viewDistance: 5,
frame: {
bottom: {
size: 1,
color: 'rgba(0,0,0,0.05)'
}
}
}
},
credits: {
enabled:false
},
title: {
text: "Trainee vs Webinar Chart"
},
subtitle: {
text: "Test options by dragging the sliders below"
},
yAxis: {
min: 0,
max: 100,
gridLineWidth: 3,
gridLineColor: 'green'
},
xAxis: {
categories:['Trainee','Webinar'],
// min: 0,
// max: 2,
gridLineWidth: 0
},
zAxis: {
min: 0,
max: 3,
categories: ['Trainee','Webinar'],
labels: {
y: 5,
rotation: 18
}
},
plotOptions: {
series: {
groupZPadding: 10,
depth: 60,
groupPadding: 0,
grouping: false,
}
},
series: [
{
// name: "Trainee vs Webinar Data",
data: [
{name:"Trainee",y:80,color:'#4472c5'},
{name:"Webinar",y:60,color:'violet'}
]
}
]
}
I am calling a function in ngoninit.
In that function I am defining this config for chart.
What is my mistake in this?
Thanks in advance
You need to add the highcharts-3d module, in angular:
import * as Highcharts from 'highcharts';
import HC_3d from 'highcharts/highcharts-3d';
HC_3d(Highcharts);
Live demo: http://jsfiddle.net/BlackLabel/0qdkhbt6/
Docs:
https://www.highcharts.com/docs/chart-concepts/3d-charts
https://github.com/highcharts/highcharts-angular#to-load-a-module

Highchart - how to control gap between series

In Highcharts, how do I control the gaps between categories?
I've highlighted the area I am talking about in blue below:
I want to make my highchart chart gaps look like this powerpoint version on the left below. The bars in PowerPoint go all the way to the end of the plot area, but highcharts have this big gap.
https://jsfiddle.net/15u0r64s/
Highcharts.chart('container', {
chart: {
type: 'bar'
},
title: {
text: 'Historic World Population by Region'
},
subtitle: {
text: 'Source: Wikipedia.org'
},
xAxis: {
categories: ['Total', 'Male', 'Female', 'Other'],
title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: 'Population (millions)',
align: 'high'
},
labels: {
overflow: 'justify'
}
},
tooltip: {
valueSuffix: ' millions'
},
plotOptions: {
bar: {
dataLabels: {
enabled: true
}
}
},
legend: {
layout: 'vertical',
align: 'right',
verticalAlign: 'top',
x: -40,
y: 80,
floating: true,
borderWidth: 1,
backgroundColor:
Highcharts.defaultOptions.legend.backgroundColor || '#FFFFFF',
shadow: true
},
credits: {
enabled: false
},
series: [{
name: 'Total',
data: [10, 20, 31, '']
}, {
name: 'Male',
data: [10, 20, 60, 2]
}, {
name: 'Female',
data: [10, 20, 61, '']
}, {
name: 'Other',
data: [10, 20, 65, 4]
}]
});
You need to edit groupPadding and pointPadding properties:
plotOptions: {
bar: {
groupPadding: 0.05,
pointPadding: 0
}
}
Live demo: https://jsfiddle.net/BlackLabel/oqpxmL18/
API Reference:
https://api.highcharts.com/highcharts/series.bar.groupPadding
https://api.highcharts.com/highcharts/series.bar.pointPadding

Pie chart with two circles need to change background color in inner circle

I have two circle pie charts, they're looking good but I need to change the background color of the inner core:
$(document).ready(function () {
var chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
//backgroundColor: 'rgba(255, 255, 255, 0.0)',
//backgroundColor: 'rgba(255, 255, 255, 0.0)',
backgroundColor: '#FCFFC5',
margin: [0, 0, 0, 0],
spacingTop: 23,
spacingBottom: 23,
spacingLeft: 23,
spacingRight: 23,
plotBorderWidth: 1,
//polar: true,
//type: 'inline'
},
exporting: { enabled: false },
credits: {
enabled: false
},
plotOptions: {
size: '100%',
series: {
states: {
hover: {
enabled: false
}
}
},
pie: {
innerSize: 100,
backgroundColor: '#CCC',
depth: 15,
dataLabels: {
connectorWidth: 0
}
}
},
tooltip: {
enabled: false
//pointFormat: '{series.name}: <b>{point.percentage:.1f}%</b>'
},
title: {
text: '<div style="background-color:#2cb5e1;">Today WalkIn<br>67<br>Average wait time<br> 02:00</div>',
align: 'center',
verticalAlign: 'middle',
y: 5,
style: {
color: '#000',
fontWeight: 'bold',
fontSize: '28px',
}
},
legend: {
layout: "vertical",
align: "right",
verticalAlign: "middle",
},
series: { states: { hover: { enabled: false } } },
series: [{
type: 'pie',
dataLabels: false,
shadow: false,
data: [{
name: '',
y: 7,
color: '#fc525a',
}, {
name: '',
y: 5,
color: '#2cb5e1',
}, {
name: '',
y: 18,
color: '#fc8b4d',
}],
innerSize: '65%'
},
{
type: 'pie',
data: [{
name: '',
y: 7,
color: '#fc525a',
}, {
name: '',
y: 5,
color: '#2cb5e1',
}, {
name: '',
y: 18,
color: '#fc8b4d',
}],
innerSize: '80%'
}]
});
});
yellow color background comes out of the two pie chart circles; instead, I wanted to display the color only where text has been placed
Screenshot
You need to draw a custom shape, for example:
chart: {
...,
events: {
load: function() {
var x = this.chartWidth / 2,
y = this.chartHeight / 2,
r = x > y ? y : x;
this.renderer
.circle(x, y, 0.65 * r)
.attr('fill', '#F0F')
.add()
}
}
}
Live demo: http://jsfiddle.net/BlackLabel/apmvgnb4/
API Reference: https://api.highcharts.com/class-reference/Highcharts.SVGRenderer#circle

Move Highcharts Legend Checkbox

I have enabled the checkbox on the Highcharts Legend. I have also disabled the click of the label to toggle that item in the graph. This makes it so the use should use the checkbox only to toggle graph items. The problem now is that the checkbox is always at the end (far right) of the label. Is there a way to make it appear to the left of the label? If not I'd just like to space out the labels so they aren't right next to each other. When I do that the checkbox stays to the very far right side. This makes it look like it is paired with the next item in the legend. If we can make the checkbox stay just to the right of the label that would be okay too. Here is what I have so far:
$(function() {
$('#container').highcharts({
chart: {
renderTo: 'container',
defaultSeriesType: 'column'
},
title: {
text: 'Placed By Advisor'
},
xAxis: {
categories: ['John Jenkins', 'Steve Smith', 'Will Douglas', 'Dustin Johnson', 'Suzy Abbott', 'Wendy Jones'],
min: 0,
max: 4
},
yAxis: {
min: 0
},
legend: {
shadow: true,
itemHoverStyle: {
cursor: "default"
},
itemDistance: 50
//title: {
// text: '<span style="font-size: 10px; color: #666; font-weight: normal">Click to hide</span>',
// style: {
// fontStyle: 'italic'
// }
//},
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0.5
},
series: {
showCheckbox: true,
events: {
checkboxClick: function (event) {
if (event.checked) {
this.show();
this.legendSymbol.show();
} else {
this.hide();
this.legendSymbol.hide();
}
},
legendItemClick: function() {
return false;
}
}
}
},
series: [{
name: 'Unemployed',
color: '#D70014',
selected: true,
data: [100, 100, 120, 55, 35, 189]},
{
name: 'Placed In Related',
color: '#6CBA16',
selected: true,
data: [80, 108, 15, 74, 48, 88]},
{
name: 'Placed In Unrelated',
color: '#FFA501',
selected: true,
data: [17, 22, 187, 70, 75, 35]},
{
name: 'Except',
color: '#2F7DC4',
selected: true,
data: [10, 0, 19, 65, 25, 674]}],
scrollbar: {
enabled:true,
barBackgroundColor: 'lightgray',
//barBorderRadius: 7,
//barBorderWidth: 0,
//buttonBackgroundColor: 'gray',
//buttonBorderWidth: 0,
//buttonArrowColor: 'yellow',
//buttonBorderRadius: 0,
//rifleColor: 'yellow',
//trackBackgroundColor: 'red',
//trackBorderWidth: 1,
//trackBorderColor: 'silver',
//trackBorderRadius: 7
}
});
});
And here is the fiddle.

Dates instead of values on Highchart labels in graph with multiple axis

I've created a line and a bar graph that share the xAxis. But for some reason it chooses to display the value instead of date, even though I am supplying it the standard way.
What am I missing here?
Fiddle: http://jsfiddle.net/ZfP84/
$(function () {
var options = {
chart: {
renderTo: 'container',
},
navigator:{
enabled:true
},
scrollbar: {
enabled:true
},
rangeSelector: {
enabled: true,
//selected: 1
},
xAxis: {
gridLineWidth: 1,
labels: {
rotation: -45,
align: 'right',
style: {
fontSize: '13px',
fontFamily: 'Verdana, sans-serif'
}
}
},
yAxis: [
{
height: 150,
lineWidth: 2,
offset: 0,
title: {
text: 'Price',
}
},
{
top: 225,
//lineWidth: 0,
//min: 0,
//max: 5,
gridLineWidth: 0,
offset: 0,
height: 100,
title: {
text: 'Volume',
}
},
],
series: [
{
yAxis: 0,
name: 'Price by time',
stack: 0,
//data: [1, 12, 32, 43],
data: [[1147651200000,67.79],[1147737600000,64.98],[1147824000000,65.26],[1147910400000,63.18],[1147996800000,64.51],[1148256000000,63.38],[1148342400000,63.15],[1148428800000,63.34],[1148515200000,64.33],[1148601600000,63.55],[1148947200000,61.22],[1149033600000,59.77],[1149120000000,62.17],[1149206400000,61.66],[1149465600000,60.00],[1149552000000,59.72],[1149638400000,58.56],[1149724800000,60.76],[1149811200000,59.24],[1150070400000,57.00],[1150156800000,58.33],[1150243200000,57.61],[1150329600000,59.38],[1150416000000,57.56],[1150675200000,57.20],[1150761600000,57.47],[1150848000000,57.86],[1150934400000,59.58],[1151020800000,58.83],[1151280000000,58.99],[1151366400000,57.43],[1151452800000,56.02],[1151539200000,58.97],[1151625600000,57.27],[1151884800000,57.95],[1152057600000,57.00],[1152144000000,55.77],[1152230400000,55.40],[1152489600000,55.00],[1152576000000,55.65],[1152662400000,52.96],[1152748800000,52.25],[1152835200000,50.67],[1153094400000,52.37],[1153180800000,52.90],[1153267200000,54.10],[1153353600000,60.50],[1153440000000,60.72],[1153699200000,61.42],[1153785600000,61.93],[1153872000000,63.87],[1153958400000,63.40],[1154044800000,65.59],[1154304000000,67.96],[1154390400000,67.18],[1154476800000,68.16],[1154563200000,69.59],[1154649600000,68.30],[1154908800000,67.21],[1154995200000,64.78],[1155081600000,63.59],[1155168000000,64.07],[1155254400000,63.65],[1155513600000,63.94],[1155600000000,66.45],[1155686400000,67.98],[1155772800000,67.59],[1155859200000,67.91],[1156118400000,66.56],[1156204800000,67.62],[1156291200000,67.31],[1156377600000,67.81],[1156464000000,68.75],[1156723200000,66.98],[1156809600000,66.48],[1156896000000,66.96],[1156982400000,67.85],],
tooltip: {
valueDecimals: 2
},
},
{
name: 'Volume by time',
yAxis: 1,
stack: 0,
data: [[1147651200000,67.79],[1147737600000,64.98],[1147824000000,65.26],[1147910400000,63.18],[1147996800000,64.51],[1148256000000,63.38],[1148342400000,63.15],[1148428800000,63.34],[1148515200000,64.33],[1148601600000,63.55],[1148947200000,61.22],[1149033600000,59.77],[1149120000000,62.17],[1149206400000,61.66],[1149465600000,60.00],[1149552000000,59.72],[1149638400000,58.56],[1149724800000,60.76],[1149811200000,59.24],[1150070400000,57.00],[1150156800000,58.33],[1150243200000,57.61],[1150329600000,59.38],[1150416000000,57.56],[1150675200000,57.20],[1150761600000,57.47],[1150848000000,57.86],[1150934400000,59.58],[1151020800000,58.83],[1151280000000,58.99],[1151366400000,57.43],[1151452800000,56.02],[1151539200000,58.97],[1151625600000,57.27],[1151884800000,57.95],[1152057600000,57.00],[1152144000000,55.77],[1152230400000,55.40],[1152489600000,55.00],[1152576000000,55.65],[1152662400000,52.96],[1152748800000,52.25],[1152835200000,50.67],[1153094400000,52.37],[1153180800000,52.90],[1153267200000,54.10],[1153353600000,60.50],[1153440000000,60.72],[1153699200000,61.42],[1153785600000,61.93],[1153872000000,63.87],[1153958400000,63.40],[1154044800000,65.59],[1154304000000,67.96],[1154390400000,67.18],[1154476800000,68.16],[1154563200000,69.59],[1154649600000,68.30],[1154908800000,67.21],[1154995200000,64.78],[1155081600000,63.59],[1155168000000,64.07],[1155254400000,63.65],[1155513600000,63.94],[1155600000000,66.45],[1155686400000,67.98],[1155772800000,67.59],[1155859200000,67.91],[1156118400000,66.56],[1156204800000,67.62],[1156291200000,67.31],[1156377600000,67.81],[1156464000000,68.75],[1156723200000,66.98],[1156809600000,66.48],[1156896000000,66.96],[1156982400000,67.85],],
tooltip: {
valueDecimals: 2
},
lineWidth: 3,
marker: {
enabled: false
},
type: 'column',
},
]
};
var chart = new Highcharts.Chart(options);
});
If you added the the "type" to the xAxis definition then the x values will be interpreted as dates and times rather than decimal values
xAxis: {
type : "datetime", //add this line
gridLineWidth: 1,
labels: {
rotation: -45,
align: 'right',
style: {
fontSize: '13px',
fontFamily: 'Verdana, sans-serif'
}
}
},
you may have to fiddle with the start times and intervals to get HighChart to correctly interpret your x-values.
see this demo on the highchart website as an example. http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/highcharts/demo/line-time-series/
The reason is that you are not actually creating a Stock chart. Your code looks like:
var chart = new Highcharts.Chart(options);
If you want it to be a Stock chart do:
var chart = new Highcharts.StockChart(options);
A Chart by default is a category chart. StockChart is time-based.
You can use dateFormat to replace time in miliseconds with date.
http://jsfiddle.net/3bE4X/
formatter:function(){
return Highcharts.dateFormat('%d / %m / %Y',this.value);
}
http://api.highcharts.com/highcharts#Highcharts.dateFormat()

Resources