this is my polar area chart. - https://ibb.co/H7gJ5DH.
i want to change above polar area chart to look like this - https://ibb.co/ScNwXFB.
jsfiddle - https://jsfiddle.net/isurumahesh/2n3jh8xs/48/
could you please help me to show the legend values inside the polar area chart ?
You can use only one series, disable legend and add another x-axis with the below options:
xAxis: [{
type: 'category',
uniqueNames: false,
gridLineColor: 'black',
gridZIndex: 5,
lineWidth: 3,
labels: {
staggerLines: 2,
allowOverlap: true,
distance: 15,
align: 'center',
style: {
fontSize: '9px',
width: '70px'
}
}
}, {
categories: mainCategories,
min: -0.5,
max: 3.5,
offset: -30,
lineWidth: 0,
gridLineColor: 'black',
gridLineWidth: 3,
gridZIndex: 5,
showLastLabel: true,
labels: {
allowOverlap: true,
align: 'center',
staggerLines: 0,
style: {
fontSize: '14px'
}
}
}],
pane: {
size: '75%'
},
yAxis: {
tickInterval: 1,
gridZIndex: 5,
gridLineWidth: 1,
gridLineColor: 'black',
labels: {
enabled: false
}
},
legend: {
enabled: false
}
Live demo: https://jsfiddle.net/BlackLabel/za1mq3gc/
API Reference: https://api.highcharts.com/highcharts/xAxis
Related
I need customize gauge highchart as
I customized it as jsfiddle code.
var gaugeOptions = {
chart: {
type: 'solidgauge'
},
title: null,
pane: {
center: ['50%', '85%'],
size: '140%',
startAngle: -90,
endAngle: 90,
background: {
backgroundColor:
Highcharts.defaultOptions.legend.backgroundColor || '#EEE',
innerRadius: '60%',
outerRadius: '100%',
shape: 'arc'
}
},
exporting: {
enabled: false
},
tooltip: {
enabled: false
},
// the value axis
yAxis: {
stops: [
[0.1, '#55BF3B'], // green
[0.5, '#DDDF0D'], // yellow
[0.9, '#DF5353'] // red
],
lineWidth: 2,
tickWidth: 10,
tickInterval: 10,
lineColor: '#fff',
minorTickInterval: null,
labels: {
enabled: false
},
minorTickPosition: 'inside',
tickPosition: 'inside',
tickPixelInterval: 10,
tickLength: '50',
tickColor: '#fff',
zIndex: 6,
minorTickWidth: 0,
},
plotOptions: {
solidgauge: {
dataLabels: {
enabled: false
},
rounded: false
},
gauge: {
dial: {
radius: '40',
backgroundColor: '#1d96e0',
baseWidth: 20,
topWidth: 1,
baseLength: '5%', // of radius
rearLength: '0%'
},
pivot: {
radius: '10',
backgroundColor: '#1d96e0'
}
},
series: {
dataLabels: {
enabled: true
}
}
},
};
https://jsfiddle.net/viethien/9L4xcho3/5/
But when I resize gauge chart, it display not good as
I am concern about calculate width of gauge panel to fit style.
Thanks
You can dynamically calculate and set tickLength property for the axis:
var allowChartUpdate = true;
var gaugeOptions = {
chart: {
type: 'solidgauge',
events: {
render: function() {
var tickLength = this.pane[0].group.getBBox().width / 4
if (allowChartUpdate) {
allowChartUpdate = false;
this.yAxis[0].update({
tickLength: tickLength
});
allowChartUpdate = true;
}
}
}
}
}
Live demo: https://jsfiddle.net/BlackLabel/vbctd9ef/
API Reference: https://api.highcharts.com/class-reference/Highcharts.Axis#update
I am very new to Highcharts. I am trying to use the solid gauge. The problem is that the percentage text is not present in the center. Is there anyway to put the percentage in the center of the chart?
Here is the code:
$(function () {
Highcharts.chart('container', {
chart: {
type: 'solidgauge'
},
title: {
text: ''
},
tooltip: {
borderWidth: 0,
backgroundColor: 'none',
shadow: false,
style: {
fontSize: '16px'
},
pointFormat: '{series.name}<br><span style="font-size:2em; color: {point.color}; font-weight: bold">{point.y}%</span>',
positioner: function (labelWidth, labelHeight) {
return {
x: 200 - labelWidth / 2,
y: 180
};
}
},
pane: {
center: ['50%', '27%'],
startAngle: 0,
endAngle: 360,
background: [{ // Track for Stand
outerRadius: '62%',
innerRadius: '38%',
backgroundColor: Highcharts.Color(Highcharts.getOptions().colors[2]).setOpacity(0.3).get(),
borderWidth: 0,
}],
},
yAxis: {
min: 0,
max: 100,
lineWidth: 0,
tickPositions: []
},
plotOptions: {
solidgauge: {
borderWidth: '34px',
dataLabels: {
enabled: false
},
linecap: 'round',
stickyTracking: false
}
},
series: [{
name: 'Stand',
borderColor: Highcharts.getOptions().colors[2],
data: [{
color: Highcharts.getOptions().colors[2],
radius: '50%',
innerRadius: '50%',
y: 50
}]
}]
},
});
The x and y in the label option can set the position but I want it to be dynamic.
Secondly I want it to be always shown. Here is the result of the code above.
I'm trying to make some visualisations using the HighCharts javascript library, mainly I'm hoping to make something very similar to what these guys have on their page:
Research Affiliates - 10Yr Expected Risk & Return
Mainly, I'm trying to work out how they managed to get the 2 solid linear areas on the scatter graph that represent the different Sharpe Ratio levels. Is it just a background image, or have they somehow underlayed an area chart under the scatter chart?
Has anybody got any experience with this, or how to code it?
On the web page you are referring to area type series are used to generate triangular shapes in the background.
Area chart demo: http://www.highcharts.com/demo/area-basic
Area chart API reference: http://api.highcharts.com/highcharts#plotOptions.area
Basically, you can combine any kind of chart type.
See their demo of a scatter plot with a regression line.
As an example of a scatter plot combined with a stacked area chart, see the following code and fiddle:
var Y_MAX = 6;
var X_MAX = 5;
$(function () {
$('#container').highcharts({
title: {
text: 'Scatter plot with stacked area ratio chart'
},
plotOptions: {
area: {
stacking: 'normal'
}
},
xAxis: {
min: 0,
max: X_MAX
},
yAxis: {
min: 0,
max: Y_MAX
},
series: [{
type: 'area',
name: 'Ratio',
data: [{x: 0, y: 0}, {x: X_MAX, y: 0.4*Y_MAX}]
}, {
type: 'area',
name: 'Ratio',
data: [{x: 0, y: 0}, {x: X_MAX, y: 0.6*Y_MAX}]
}, {
type: 'scatter',
name: 'Observations',
data: [1, 0.5, 3.8, 5.5, 3.9, 2.2],
marker: {
radius: 8
}
}]
});
});
Fiddle
Thanks for the heads up on how to combine two charts.
What I actually ended up using was the Polygon Plot type rather than an Area Chart.
I also rendered the labels using Chart.renderer.label.
Still tweaking this, but as a whole reference this is my code (minus data taken out)
$(function () {
$('#scatter-plot').highcharts({
chart: {
type: 'scatter',
zoomType: 'xy'
},
title: {
text: 'Expected Asset Return Against Volatility'
},
legend: {
enabled: false
},
xAxis: {
title: {
text: 'Volatility',
enabled: true,
style: {
fontWeight: 'bold',
fontSize: '18px',
fontFamily: 'PT Sans',
}
},
min: 0,
lineWidth: 0,
lineColor: '#bfbfbf',
gridLineWidth: 0,
tickWidth: 0,
labels: {
format: '{value} %',
style: {
fontSize: '14px',
fontFamily: 'Arial',
}
}
},
yAxis: {
title: {
text: 'Real Expected Returns',
style: {
fontWeight: 'bold',
fontSize: '18px',
fontFamily: 'PT Sans',
},
enabled: true
},
gridLineWidth: 0,
lineWidth: 1,
endOnTick: true,
maxPadding: 0,
startOnTick: true,
minPadding: 0,
lineColor: '#bfbfbf',
minRange: 2,
plotLines: [{
color: '#bfbfbf',
width: 1,
value: 0,
zIndex: 5
}],
labels: {
format: '{value} %',
style: {
fontSize: '14px',
fontFamily: 'Arial',
}
}
},
series: [
{
type: 'polygon',
color: 'rgba(100,100,100, 0.1)',
data: [[0, 0], [20, 10], [20, 0]]
},
{
type: 'polygon',
color: 'rgba(100,100,100, 0.1)',
data: [[0, 0], [20, 20], [20, 0]]
},
{type: 'scatter',
marker: {
radius: 10,
symbol: 'circle',
states: {
hover: {
enabled: true,
lineColor: 'rgb(100,100,100)'
}
}
},
states: {
hover: {
marker: {
enabled: false
}
}
},
dataLabels: {
enabled: true,
x: -8,
y: -8,
fontFamily: 'PT Sans',
color: 'rgba(50, 50, 50, 0.8)',
format: '{series.name}'
},
tooltip: {
headerFormat: '<b>{series.name}</b><br>',
pointFormat: 'Volatility: {point.x}%<br>Exp. Return: {point.y}%'
},name: 'United-States',color: 'rgba(215, 40, 40, 0.6)',data: [[15.8,5.9]]},
//Rest of the data here, repeating in the same format as above^^
},
function (chart) { // on complete
chart.renderer.label('<div style="font-size:18px;">0.1 Sharpe Ratio</div>',
$(chart.container).width() - 200,
$(chart.container).height() - 150,
true)
.css({
color: 'rgba(0,0,0,0.5)'
})
.add();
chart.renderer.label('<div style="font-size:18px;">0.2 Sharpe Ratio</div>',
$(chart.container).width() - 200,
$(chart.container).height() - 250,
true)
.css({
color: 'rgba(0,0,0,0.5)'
})
.add();
});
});
And it produced this result:
Thanks again for the tips!
I am little bit confused with Hightcharts draggable points where the points are getting hidden over the axis in iPad (touch device)
I am using "draggable-points" plugin to drag over with Hightcharts.
If anybody faced this kind of a problem, please answer me.
Thanks in advance.
this.chartBoard = new Highcharts.Chart({
title: {
text: 'Line graph'
},
chart: {
renderTo: graphContainer,
animation: false,
backgroundColor: 'rgba(255, 255, 255, 0.1)',
width : 700,
height : 330
}
xAxis: {
categories: categoriesArray,
lineColor: '#000',
lineWidth: 2,
tickmarkPlacement: 'on',
gridLineWidth: 1,
gridLineColor: '#F2F2F2'
},
yAxis: {
min: minY,
max: maxY,
tickInterval: scaleY,
minorTickLength: 2,
lineColor: '#000',
lineWidth: 2
},
series: [{
id : "series",
data: categoriesValueArray,
draggableY: true,
dragMinY: minY,
dragMaxY: maxY,
type: chartType,
minPointLength: snapsPerLine,
color: "#95B9EC",
marker: {
radius: pointRadius
}
}]
});
I'd like to show data between 0 and 100%. The bar chart have 160px of width and I'd like to see just bar without any titles/legends.
I got the data in range bitween 0 and x (for example from 0 till 700), and max value can be changed.
When max value less then 160 the bar looks correctly. But when max value more than 160 a chars scales current bar value incorectly.
Desirable result
http://jsfiddle.net/dvasuta/H6SJE/2/
What I have now
http://jsfiddle.net/dvasuta/sXAeh/2/
$(function () {
$('#container').highcharts({
credits: {
enabled: false,
},
chart: {
renderTo: 'container',
type: 'bar',
marginBottom: 1,
marginTop: 1,
marginLeft: 1,
marginRight: 1,
borderRadius: 0,
borderWidth: 1,
borderColor: '#c5c6c7',
backgroundColor: 0,
height: 22,
width:160
},
title: {
text: null
},
xAxis: {
tickWidth: 0,
lineWidth: 0,
gridLineWidth: 0,
categories: 0,
labels: {
enabled: false
}
},
yAxis: {
tickWidth: 0,
lineWidth: 0,
gridLineWidth: 0,
min: 0,
max: 2500,
title: {
text: null
},
labels: {
enabled: false
}
},
tooltip: {
enabled: false,
formatter: function () {
return '';
}
},
legend: {
enabled: false
},
plotOptions: {
bar: {
dataLabels: {
enabled: true,
formatter: function () {
return '';
},
y: 0,
x: 0,
color: '#ff0',
style: {
fontSize: '18px',
fontFamily: 'bold Helvetica,Arial,sans-serif'
}
}
},
series: {
allowPointSelect: false,
enableMouseTracking: false,
groupPadding: 0,
pointPadding: 0,
borderWidth: 0,
borderRadius: 0
}
},
series: [{
shadow: true,
data: [2482],
color: {
linearGradient: [20, 20, 0, 20],
stops: [
[0, '#B6D22D'],
[1, '#5C9135']
]
}
}]
});
});
It seems the issue in chart.width parameter. But how can I set a chart width?
I think the parameter you need to try is 'endOnTick' on the y-axis:
endOnTick:false,
http://jsfiddle.net/46nMs/
http://api.highcharts.com/highcharts#yAxis.endOnTick
Also, you may want to turn of exporting (this is just a visual tweak, and doesn't affect the scaling of the bar).
try this LINK ChaRT LINK
1. Disabled exporting
2. borderWidth = 0