I'm having problems in the integration of Solid Gauge in Highcharts with Google Sheets. I manage lines, bars and others, but this could not pull data.
Has anyone done something like that in Highcharts?
..............................................................................................................................................................
$(function () {
var gaugeOptions = {
chart: {
type: 'solidgauge'
},
title: null,
pane: {
center: ['50%', '85%'],
size: '140%',
startAngle: -90,
endAngle: 90,
background: {
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE',
innerRadius: '60%',
outerRadius: '100%',
shape: 'arc'
}
},
tooltip: {
enabled: false
},
// the value axis
yAxis: {
stops: [
[0.1, '#55BF3B'], // green
[0.5, '#DDDF0D'], // yellow
[0.9, '#DF5353'] // red
],
lineWidth: 0,
minorTickInterval: null,
tickPixelInterval: 400,
tickWidth: 0,
title: {
y: -70
},
labels: {
y: 16
}
},
plotOptions: {
solidgauge: {
dataLabels: {
y: 5,
borderWidth: 0,
useHTML: true
}
}
}
};
// The speed gauge
$('#container-speed').highcharts(Highcharts.merge(gaugeOptions, {
yAxis: {
min: 0,
max: 200,
title: {
text: 'Speed'
}
},
credits: {
enabled: false
},
series: [{
name: 'Speed',
data: [80],
dataLabels: {
format: '<div style="text-align:center"><span style="font-size:25px;color:' +
((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y}</span><br/>' +
'<span style="font-size:12px;color:silver">km/h</span></div>'
},
tooltip: {
valueSuffix: ' km/h'
}
}]
}));
// The RPM gauge
$('#container-rpm').highcharts(Highcharts.merge(gaugeOptions, {
yAxis: {
min: 0,
max: 5,
title: {
text: 'RPM'
}
},
series: [{
name: 'RPM',
data: [1],
dataLabels: {
format: '<div style="text-align:center"><span style="font-size:25px;color:' +
((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y:.1f}</span><br/>' +
'<span style="font-size:12px;color:silver">* 1000 / min</span></div>'
},
tooltip: {
valueSuffix: ' revolutions/min'
}
}]
}));
// Bring life to the dials
setInterval(function () {
// Speed
var chart = $('#container-speed').highcharts(),
point,
newVal,
inc;
if (chart) {
point = chart.series[0].points[0];
inc = Math.round((Math.random() - 0.5) * 100);
newVal = point.y + inc;
if (newVal < 0 || newVal > 200) {
newVal = point.y - inc;
}
point.update(newVal);
}
// RPM
chart = $('#container-rpm').highcharts();
if (chart) {
point = chart.series[0].points[0];
inc = Math.random() - 0.5;
newVal = point.y + inc;
if (newVal < 0 || newVal > 5) {
newVal = point.y - inc;
}
point.update(newVal);
}
}, 2000);
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script src="http://code.highcharts.com/highcharts.js"></script>
<script src="http://code.highcharts.com/highcharts-more.js"></script>
<script src="http://code.highcharts.com/modules/solid-gauge.js"></script>
<div style="width: 600px; height: 400px; margin: 0 auto">
<div id="container-speed" style="width: 300px; height: 200px; float: left"></div>
<div id="container-rpm" style="width: 300px; height: 200px; float: left"></div>
</div>
Looks like possibly bug, reported here: https://github.com/highslide-software/highcharts.com/issues/4427
Work, but, i use JS from Highchart cloud.
function parseData(completeHandler, chartOptions) {
try {
var dataOptions = {
"googleSpreadsheetWorksheet": "3",
"endColumn": null,
"seriesMapping": [
{
"x": 0
}
],
"googleSpreadsheetKey": "1u0vGMYJM-iAP04NMARJuB875Y3xOj8gDGPbfzEf1FL8",
"startRow": null,
"startColumn": null,
"endRow": null
};
dataOptions.sort = true
dataOptions.complete = completeHandler;
Highcharts.data(dataOptions, chartOptions);
} catch (error) {
console.log(error);
completeHandler(undefined);
}
}
var template = {
chart: {
renderTo: 'container'
},
navigation: {
menuItemStyle: {
fontFamily: Highcharts.SVGRenderer.prototype.getStyle().fontFamily,
padding: '2px 10px'
}
},
};
var chartOptions = {
"plotOptions": {
"solidgauge": {
"dataLabels": {
"useHTML": true,
"borderWidth": 0,
"y": 10
}
}
},
"yAxis": {
"tickPixelInterval": 50,
"tickWidth": 0,
"minorTickInterval": null,
"min": 0,
"max": 16,
"stops": [
[
0.1,
"#55BF3B"
],
[
0.5,
"#DDDF0D"
],
[
0.9,
"#DF5353"
]
],
"title": {
"y": -70,
"style": {
"fontSize": 20
},
"text": null
},
"lineWidth": 0,
"labels": {
"y": 16
}
},
"xAxis": {
"labels": {
"format": null
}
},
"credits": {
"enabled": false
},
"series": [
{
"dataLabels": {
"format": "\u003cdiv style\u003d\"text-align:center\"\u003e\u003cspan style\u003d\"font-size:25px;color:#000000\"\u003e{y}\u003c/span\u003e\u003c/div\u003e"
},
"index": 0
}
],
"subtitle": {
"text": null
},
"tooltip": {
"enabled": false
},
"title": {
"text": "METAS MÊS"
},
"pane": {
"startAngle": "-90",
"size": "140%",
"background": {
"backgroundColor": "#EEE",
"innerRadius": "60%",
"outerRadius": "100%",
"shape": "arc"
},
"center": [
"50%",
"85%"
],
"endAngle": "90"
},
"chart": {
"type": "solidgauge"
}
};
parseData(function (dataOptions) {
// Merge series configs
if (chartOptions.series && dataOptions) {
Highcharts.each(chartOptions.series, function (series, i) {
chartOptions.series[i] = Highcharts.merge(series, dataOptions.series[i]);
});
}
var options = Highcharts.merge(dataOptions, chartOptions, template);
var chart = new Highcharts['Chart'](options);
}, chartOptions);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="http://akasicuro.com/plataforma/highstock-cloud.js"></script>
<div id="container" style="width:100%; height:100%;max-width:1000px;margin: 0 auto"></div>
Related
I am using Highcharts for column
On hover of a bar, wanted to get box-shadow for currently hovered bar only. Can someone help me doing this?
I need to put specific box-shadow value for the point
currently, it looks like this
here is my code
// column chart
Highcharts.chart('column-highchart', {
chart: {
type: 'column',
height: 270
},
title: {
text: ''
},
subtitle: {
text: ''
},
xAxis: {
type: 'category',
labels:{
style: {
color: 'rgba(43, 48, 52, 0.4)',
fontWeight:'bold',
fontFamily:'Inter UI'
}
}
},
yAxis: {
gridLineWidth: 0,
min: 20,
max: 100,
distance:20,
tickInterval: 20,
labels:{
style: {
color: 'rgba(43, 48, 52, 0.4)',
fontWeight:'bold',
fontFamily:'Inter UI'
}
},
title: {
text: ''
}
},
legend: {
enabled: false,
},
plotOptions: {
// column: {
// states: {
// hover: {
// shadow: {
// color: 'rgba(0, 0, 0, 0.2)',
// offsetX: 1,
// offsetY: 10,
// opacity: '0.2',
// width: 10
// },
// }
// }
// },
series: {
borderWidth: 0,
// pointWidth:120,
groupPadding: 0,
pointPadding:0.08,
dataLabels: {
enabled: false,
format: '{point.y:.1f}%'
},
point: {
events: {
mouseOver: function() {$(this.series.chart.xAxis[0].labelGroup.element.childNodes[this.x]).css('fill', '#00b5fa');
},
mouseOut: function() {
$(this.series.chart.xAxis[0].labelGroup.element.childNodes[this.x]).css('fill', 'rgba(43, 48, 52, 0.4)');
}
}
},
color: {
linearGradient: {
x1: 0,
x2: 0,
y1: 0,
y2: 1
},
stops: [
[0, '#05e06f'],
[1, '#00b1f5']
]
}
}
},
tooltip: {
headerFormat: '<span style="font-family:Inter UI;font-size:11px; color:#fff;">{point.y} {series.name}</span><br>',
pointFormat: '',
backgroundColor: '#282e35',
borderColor: '#282e35'
},
"series": [
{
"name": "Hours",
"colorByPoint": false,
"data": [
{
"name": "Week 1",
"y": 62,
// "drilldown": "week1"
},
{
"name": "Week 2",
"y": 40,
// "drilldown": "week2"
},
{
"name": "Week 3",
"y": 35,
// "drilldown": "week3"
},
{
"name": "Week 4",
"y": 84,
// "drilldown": "week4"
},
{
"name": "Week 5",
"y": 68,
// "drilldown": "week5"
}
]
}
]
});});
If some kind soul can help me with it, I would really appreciate that.
You can catch mouseOver and mouseOut events and use Highcharts SVG Renderer to render anything you want, for example the shadow.
point: {
events: {
mouseOver: function() {
var chart = this.series.chart,
r = chart.renderer,
borderWidth = 2,
x, y;
x = this.plotX + chart.plotLeft + (this.pointWidth / 2);
y = this.plotY + chart.plotTop + borderWidth;
chart.pointShadow = r.path([
'M', x, y,
'L', x, y + this.shapeArgs.height - borderWidth
])
.attr({
zIndex: 3,
'stroke-width': borderWidth,
'stroke': 'gray'
})
.add()
},
mouseOut: function() {
this.series.chart.pointShadow.destroy()
}
}
},
jsFiddle
I was developing a vue app using vue advanced webpack template and I didn't took much attention to IE browser but today I tried and I'm getting very odd errors.
I have a several sparkline charts rendered with Highcharts in the mount function of a component and I think the point where I have this error is here:
options = Highcharts.merge(defaultOptions, options);
I use babel-polyfill and my .babelrc configuration is this one:
{
"presets": [
["env", {
"modules": false,
"targets": {
"browsers": [
"Chrome >= 52",
"FireFox >= 44",
"Safari >= 7",
"Explorer 11",
"last 4 Edge versions"
]
},
"useBuiltIns": true,
"debug": true
}],
"stage-2"
],
"plugins": ["transform-vue-jsx", "transform-runtime"],
"env": {
"test": {
"presets": ["env", "stage-2"],
"plugins": ["transform-vue-jsx", "transform-es2015-modules-commonjs",
"dynamic-import-node"]
}
}
}
In webpack.base.config.js I have this loader configured:
{
test: /\.js$/,
loader: 'babel-loader',
include: [resolve('src'), resolve('i18n'), resolve('test'),
resolve('node_modules/webpack-dev-server/client')]
},
Any help will be appreciated, thanks!
Relevant Source of List.vue:
import createSmallCharts from './smallChart';
function refreshCharts(elements) {
createSmallCharts(elements);
}
...
mounted() {
const elements = this.$refs['currency-table-
body'].querySelectorAll('.table__price-graph');
refreshCharts(elements);
},
And the source for createSmallCharts
import * as Highcharts from 'highcharts/highcharts';
// Creating 153 sparkline charts is quite fast in modern browsers, but IE8 and mobile
// can take some seconds, so we split the input into chunks and apply them in timeouts
// in order avoid locking up the browser process and allow interaction.
function createSmallCharts(elements) {
const time = +new Date();
let stringdata;
let data;
let n = 0;
for (let i = 0; i < elements.length; i += 1) {
const element = elements[i];
stringdata = element.getAttribute('data-sparkline');
data = stringdata.split(', ').map(dataEl => parseFloat(dataEl));
Highcharts.SparkLine(element, {
series: [{
data,
pointStart: 1,
pointInterval: 24 * 3600 * 1000,
fillColor: {
linearGradient: {
x1: 0,
y1: 0,
x2: 0,
y2: 1,
},
},
}],
plotOptions: {
series: {
marker: {
enabled: false,
states: {
hover: {
enabled: true,
radius: 3,
},
},
},
},
},
tooltip: {
formatter: () => false,
},
});
// If the process takes too much time, run a timeout to allow interaction with the browser
if (new Date() - time > 500) {
elements.splice(0, i + 1);
setTimeout(createSmallCharts, 0);
break;
}
}
}
export { createSmallCharts as default };
Finnaly the definition of SparkLine:
import Highcharts from 'highcharts/highcharts';
Highcharts.SparkLine = function SparkLine(...params) {
const hasRenderToArg = typeof a === 'string' || params[0].nodeName;
let options = params[hasRenderToArg ? 1 : 0];
const defaultOptions = {
chart: {
renderTo: (options.chart && options.chart.renderTo) || this,
backgroundColor: null,
borderWidth: 0,
type: 'area',
margin: [2, 0, 2, 0],
width: 120,
height: 20,
style: {
overflow: 'visible',
},
// small optimalization, saves 1-2 ms each sparkline
skipClone: true,
},
title: {
text: '',
},
credits: {
enabled: false,
},
xAxis: {
labels: {
enabled: false,
},
title: {
text: null,
},
startOnTick: false,
endOnTick: false,
tickPositions: [],
},
yAxis: {
endOnTick: false,
startOnTick: false,
labels: {
enabled: false,
},
title: {
text: null,
},
tickPositions: [0],
},
legend: {
enabled: false,
},
tooltip: {
backgroundColor: null,
borderWidth: 0,
shadow: false,
useHTML: true,
hideDelay: 0,
shared: true,
padding: 0,
positioner(w, h, point) {
return {
x: point.plotX - (w / 2),
y: point.plotY - h,
};
},
},
plotOptions: {
series: {
animation: false,
lineWidth: 1,
shadow: false,
states: {
hover: {
lineWidth: 1,
},
},
marker: {
radius: 1,
states: {
hover: {
radius: 2,
},
},
},
fillOpacity: 0.25,
},
column: {
negativeColor: '#910000',
borderColor: 'silver',
},
},
};
options = Highcharts.merge(defaultOptions, options); // I think ERROR is here
return hasRenderToArg ?
new Highcharts.Chart(params[0], options, params[2]) :
new Highcharts.Chart(options, params[1]);
};
Try to import it at the top of your main.js file like this:
import 'babel-polyfill'
At least this fixed this issue for me.
I'm trying to recreate a linear gauge chart of fusionchart in highcharts. This is the example that I am trying to recreate.
Head:
<script type="text/javascript" src="https://static.fusioncharts.com/code/latest/fusioncharts.js"></script>
<script type="text/javascript" src="https://static.fusioncharts.com/code/latest/fusioncharts.charts.js"></script>
<script type="text/javascript" src="https://static.fusioncharts.com/code/latest/fusioncharts.widgets.js"></script>
<script type="text/javascript" src="https://static.fusioncharts.com/code/latest/themes/fusioncharts.theme.fint.js"></script>
<div id="chart-container">FusionCharts will render here</div>
Body:
FusionCharts.ready(function () {
var cpuGauge = new FusionCharts({
type: 'hlineargauge',
renderAt: 'chart-container',
id: 'cpu-linear-gauge',
width: '400',
height: '190',
dataFormat: 'json',
dataSource: {
"chart": {
"theme": "fint",
"lowerLimit": "-1.9",
"upperLimit": "4.4",
"numberSuffix": "%",
"chartBottomMargin": "40",
"valueFontSize": "11",
"pointerBgColor": "#000000",
"baseFontColor": "#000000",
"decimalSeparator": ",",
"forceDecimals": "1",
"decimals": "1",
"valueFontBold": "0"
},
"colorRange": {
"color": [
{
"minValue": "-1.9",
"maxValue": "-0.1",
"label": "",
"code": "#e51b1b",
},
{
"minValue": "-0.1",
"maxValue": "1.0",
"label": "",
"code": "#fa7921",
},
{
"minValue": "1.0",
"maxValue": "1.5",
"label": "",
"code": "#fde74c",
},
{
"minValue": "1.5",
"maxValue": "4.4",
"label": "",
"code": "#9bc53d",
}
]
},
"pointers": {
"pointer": [
{
"value": "2"
}
]
},
}
})
.render();
});
The highcharts chart must take over the following properties:
Negative values
At least 4 groups (colors)
Pointer (indication marker) with number at top
In addition, I would really appreciate if there is an animation where you can see the pointer moving.
The bullet graph from highcharts comes closest to the fusionchart. I have made a first step (example) with this graph
Head:
<script src="https://code.highcharts.com/highcharts.js"></script>
<script src="https://code.highcharts.com/modules/bullet.js"></script>
<div id="container1"></div>
Body:
Highcharts.setOptions({
chart: {
inverted: true,
marginLeft: 135,
type: 'bullet'
},
title: {
text: null
},
legend: {
enabled: false
},
yAxis: {
gridLineWidth: 0
},
plotOptions: {
series: {
pointPadding: 0.25,
borderWidth: 0,
color: '#000',
targetOptions: {
width: '200%'
}
}
},
credits: {
enabled: false
},
exporting: {
enabled: false
}
});
Highcharts.chart('container1', {
chart: {
marginTop: 40
},
title: {
text: ''
},
xAxis: {
categories: "P"
},
yAxis: {
plotBands: [{
from: -1.9,
to: -0.1,
color: '#e51b1b'
}, {
from: -0.1,
to: 1,
color: '#fa7921'
}, {
from: 1,
to: 1.5,
color: '#fde74c'
}, {
from: 1.5,
to: 4.4,
color: '#9bc53d'
}],
labels: {
format: '{value}%'
},
title: null
},
series: [{
data: [{
y: 0,
target: 2
}]
}],
tooltip: {
pointFormat: '<b>{point.y}</b> (with target at {point.target})'
}
});
CSS:
#container1 {
max-width: 800px;
height: 115px;
margin: 1em auto;
}
But encounter a number of problems:
Negative numbers are not working
Pointer
Maximum is not shown (stops before 4.4)
With reference to this post. I have modified this chart with yAxis.tickPositioner and min, max property of yAxis
$(function () {
/**
* Highcharts Linear-Gauge series plugin
*/
(function (H) {
var defaultPlotOptions = H.getOptions().plotOptions,
columnType = H.seriesTypes.column,
wrap = H.wrap,
each = H.each;
defaultPlotOptions.lineargauge = H.merge(defaultPlotOptions.column, {});
H.seriesTypes.lineargauge = H.extendClass(columnType, {
type: 'lineargauge',
//inverted: true,
setVisible: function () {
columnType.prototype.setVisible.apply(this, arguments);
if (this.markLine) {
this.markLine[this.visible ? 'show' : 'hide']();
}
},
drawPoints: function () {
// Draw the Column like always
columnType.prototype.drawPoints.apply(this, arguments);
// Add a Marker
var series = this,
chart = this.chart,
inverted = chart.inverted,
xAxis = this.xAxis,
yAxis = this.yAxis,
point = this.points[0], // we know there is only 1 point
markLine = this.markLine,
ani = markLine ? 'animate' : 'attr';
// Hide column
point.graphic.hide();
if (!markLine) {
var path = inverted ? ['M', 0, 0, 'L', -5, -5, 'L', 5, -5, 'L', 0, 0, 'L', 0, 0 + xAxis.len] : ['M', 0, 0, 'L', -5, -5, 'L', -5, 5,'L', 0, 0, 'L', xAxis.len, 0];
markLine = this.markLine = chart.renderer.path(path)
.attr({
fill: series.color,
stroke: series.color,
'stroke-width': 1
}).add();
}
markLine[ani]({
translateX: inverted ? xAxis.left + yAxis.translate(point.y) : xAxis.left,
translateY: inverted ? xAxis.top : yAxis.top + yAxis.len - yAxis.translate(point.y)
});
}
});
})(Highcharts);
$('#container').highcharts({
chart: {
type: 'lineargauge',
inverted: true
},
title: {
text: 'A Horizontal Linear Gauge'
},
xAxis: {
lineColor: '#C0C0C0',
labels: {
enabled: false
},
tickLength: 0,
},
yAxis: {
min: -1.9,
max: 4.4,
tickPositions: [-1.9, -0.1,1,1.5 ,4.4],
tickLength: 1,
tickWidth: 1,
tickColor: '#C0C0C0',
gridLineColor: '#C0C0C0',
gridLineWidth: 1,
minorTickInterval: 5,
minorTickWidth: 1,
minorTickLength: 5,
minorGridLineWidth: 0,
startOnTick: true,
endOnTick: true,
title: null,
labels: {
format: '{value}%'
},
plotBands: [{
from:-1.9,
to: -0.1,
color: 'rgba(229, 27, 27, 1)'
}, {
from: -0.1,
to: 1.0,
color: 'rgba(250, 121, 33, 1)'
}, {
from: 1.0,
to: 1.5,
color: 'rgba(253, 231, 76, 1)'
},
{
from: 1.5,
to: 4.4,
color: 'rgba(155, 197, 61, 1)'
}]
},
legend: {
enabled: false
},
series: [{
data: [1.1],
color: '#000000',
dataLabels: {
enabled: true,
align: 'center',
format: '{point.y}%',
y: 10,
}
}]
}, // Add some life
function (chart) {
setInterval(function () {
Highcharts.each(chart.series, function (serie) {
var point = serie.points[0],
newVal,
inc = (Math.random() - 0.5) *10;
newVal = point.y + inc;
if (newVal < -1.9 || newVal > 4.4) {
newVal = point.y - inc;
}
point.update(Math.floor(newVal));
});
}, 2000);
});
});
Fiddle demo
I had an requirement with gauge Chart -
$(function () {
var gaugeOptions = {
chart: {
type: 'solidgauge'
},
title: {
text: 'Sample Title'
},
pane: {
center: ['50%', '85%'],
size: '140%',
startAngle: -90,
endAngle: 90,
background: {
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE',
innerRadius: '60%',
outerRadius: '100%',
shape: 'arc'
}
},
tooltip: {
enabled: false
},
// the value axis
yAxis: {
stops: [
[0.1, '#55BF3B'], // green
[0.5, '#DDDF0D'], // yellow
[0.9, '#DF5353'] // red
],
lineWidth: 0,
minorTickInterval: null,
tickAmount: 2,
title: {
y: -70,
},
labels: {
y: 16
}
},
plotOptions: {
solidgauge: {
dataLabels: {
y: 5,
borderWidth: 0,
useHTML: true
}
}
}
};
// The speed gauge
$('#container-speed').highcharts(Highcharts.merge(gaugeOptions, {
yAxis: {
min: 0,
max: 200,
title: {
text: 'Speed'
}
},
credits: {
enabled: false
},
series: [{
name: 'Speed',
data: [80],
dataLabels: {
format: '<div style="text-align:center"><span style="font-size:25px;color:' +
((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y}</span><br/>' +
'<span style="font-size:12px;color:silver">km/h</span></div>'
},
tooltip: {
valueSuffix: ' km/h'
}
}]
}));
// The RPM gauge
$('#container-rpm').highcharts(Highcharts.merge(gaugeOptions, {
yAxis: {
min: 0,
max: 5,
title: {
text: 'RPM'
}
},
series: [{
name: 'RPM',
data: [1],
dataLabels: {
format: '<div style="text-align:center"><span style="font-size:25px;color:' +
((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y:.1f}</span><br/>' +
'<span style="font-size:12px;color:silver">* 1000 / min</span></div>'
},
tooltip: {
valueSuffix: ' revolutions/min'
}
}]
}));
// Bring life to the dials
setTimeout(function () {
// Speed
var chart = $('#container-speed').highcharts(),
point,
newVal,
inc;
if (chart) {
point = chart.series[0].points[0];
inc = Math.round((Math.random() - 0.5) * 100);
newVal = point.y + inc;
if (newVal < 0 || newVal > 200) {
newVal = point.y - inc;
}
point.update(newVal);
}
// RPM
chart = $('#container-rpm').highcharts();
if (chart) {
point = chart.series[0].points[0];
inc = Math.random() - 0.5;
newVal = point.y + inc;
if (newVal < 0 || newVal > 5) {
newVal = point.y - inc;
}
point.update(newVal);
}
}, 2000);});
In the above example you can see that title is printing two times, But I need single title to be displayed at the center.
So I got solution that instead of creating multiple charts create single chart with multiple panes and series objects as shown in below link.
$(function () {
$('#container').highcharts({
chart: {
type: 'solidgauge',
height: 200
},
title: {
text: 'Sample Title1'
},
pane: [{
startAngle: -90,
endAngle: 90,
background: null,
center: ['25%', '85%'],
size: '140%',
background: {
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE',
innerRadius: '60%',
outerRadius: '100%',
shape: 'arc'
}
}, {
startAngle: -90,
endAngle: 90,
background: null,
center: ['70%', '85%'],
size: '140%',
background: {
backgroundColor: (Highcharts.theme && Highcharts.theme.background2) || '#EEE',
innerRadius: '60%',
outerRadius: '100%',
shape: 'arc'
}
}],
tooltip: {
enabled: false
},
yAxis: [{
stops: [
[0.1, '#55BF3B'], // green
[0.5, '#DDDF0D'], // yellow
[0.9, '#DF5353'] // red
],
lineWidth: 0,
min: 0,
max: 200,
minorTickInterval: null,
tickAmount: 2,
title: {
y: -70,
text: 'Speed'
},
pane:0,
labels: {
y: 16
}
}, {
stops: [
[0.1, '#55BF3B'], // green
[0.5, '#DDDF0D'], // yellow
[0.9, '#DF5353'] // red
],
lineWidth: 0,
min: 0,
max: 5,
minorTickInterval: null,
tickAmount: 2,
pane:1,
title: {
y: 70,
text: 'RPM'
},
labels: {
y: 16
}
}],
plotOptions: {
solidgauge: {
dataLabels: {
y: 5,
borderWidth: 0,
useHTML: true
}
}
},
series: [{
name: 'Speed',
data: [80],
yAxis: 0,
dataLabels: {
format: '<div style="text-align:center"><span style="font-size:25px;color:' +
((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y}</span><br/>' +
'<span style="font-size:12px;color:silver">km/h</span></div>'
},
tooltip: {
valueSuffix: ' km/h'
}
}, {
name: 'RPM',
data: [1],
yAxis: 1,
dataLabels: {
format: '<div style="text-align:center"><span style="font-size:25px;color:' +
((Highcharts.theme && Highcharts.theme.contrastTextColor) || 'black') + '">{y:.1f}</span><br/>' +
'<span style="font-size:12px;color:silver">* 1000 / min</span></div>'
},
tooltip: {
valueSuffix: ' revolutions/min'
}
}]
});
// Bring life to the dials
setInterval(function () {
var chart = $('#container').highcharts();
if (chart.series) { // the chart may be destroyed
var left = chart.series[0].points[0],
right = chart.series[1].points[0],
leftVal,
rightVal,
inc1 = Math.round((Math.random() - 0.5) * 100),
inc2 = (Math.random() - 0.5) * 3;
leftVal = left.y + inc1;
if (leftVal < 0 || leftVal > 200) {
leftVal = left.y - inc1;
}
rightVal = right.y+inc2;
if (rightVal < 0 || rightVal > 5) {
rightVal = right.y - inc2;;
}
left.update(leftVal);
right.update(rightVal);
chart.redraw();
}
}, 2000);});
Now the Proiblem is
In My charts i can have gauge or solid gauge or both.
I want to actually add the panes and series objects dynamically . How can I add that for series I have chart.addSeries() how about pane.
Also in my charts we have enabled a toolbar where we have some form where the users can filter the options like
show or hide title
change tickamount
change mintickinterval etc
how can i update these options to a particular pane or series when I am using multiple panes and multiple series
Please help me.
The same code generates both the images. In the first image the div (the blue border) is filled nicely. In the second image there is plenty of space on the top left over. I would like it to always fill the div the way it does in the first image. spacingTop: 0 seems to have no effect. Is there some other setting I should be using instead?
Here is the code:
new Highcharts.Chart({
chart: {
animation: false,
renderTo: data.id,
type: 'column',
height: data.height,
backgroundColor: 'transparent',
spacingTop: 0
},
title: {
text: ''
},
plotOptions: {
column: {
dataLabels: {
enabled: true,
formatter: function() {
var point = this.point;
setTimeout(function() {
point.dataLabel.attr({
y: point.name/1 > 0 ? point.plotY - 20 : point.yBottom - 20
});
});
return point.name;
}
},
pointWidth: 40,
borderWidth: 0
},
series: {
animation: false
}
},
xAxis: {
categories: [ data.labelActual, data.labelDelta, data.labelPlan ],
lineColor: '#CCCCCC',
labels: {
style: {
whiteSpace: 'nowrap', // This is not working
width: '200px' // This is the workaround
}
}
},
yAxis: {
title: {
text: ''
},
gridLineWidth: 0,
labels: {
formatter: function() {
if ((valuePlan < 0 || valueActual < 0) && this.value === 0) {
return '0';
}
return '';
}
},
plotLines: [ {
value: 0,
color: '#CCCCCC',
width: 1
} ],
opposite: true
},
credits: {
enabled: false
},
legend: {
enabled: false
},
series: [ {
data: [
{
y: valueActual,
low: 0,
name: valueActual,
color: {
linearGradient: [ 0, 0, 0, 100 ],
stops: [ [ 0, '#7F7F7F' ], [ 1, '#DDDDDD' ] ]
},
dataLabels: {
enabled: true,
y: valueActual < 0 ? 13 : -5,
style: {
color: '#7F7F7F'
}
}
},
{
y: valueActual,
low: Math.abs(valueDelta) < 1 ? valueActual - 1 : valueActual - valueDelta,
name: valueDelta > 0 ? '+' + valueDelta : valueDelta,
color: valueDelta === 0 ? '#7F7F7F' : {
linearGradient: [ 0, 0, 0, 100 ],
stops: [ [ 0, data.color === 'g' ? '#005712' : data.color === 'r' ? '#CC0000' : '#7F7F7F' ],
[ 1, data.color === 'g' ? '#A2C0A8' : data.color === 'r' ? '#E29A9A' : '#DDDDDD' ] ]
},
dataLabels: {
enabled: true,
y: valueDelta < 0 ? 13 : -5,
style: {
color: valueDelta === 0 ? '#7F7F7F' : data.color === 'g' ? '#005712' : data.color === 'r' ? '#CC0000' : '#7F7F7F'
}
}
}, {
y: valuePlan,
low: 0,
name: valuePlan,
color: {
linearGradient: [ 0, 0, 0, 100 ],
stops: [ [ 0, '#7F7F7F' ], [ 1, '#DDDDDD' ] ]
},
dataLabels: {
enabled: true,
y: valuePlan < 0 ? 13 : -5,
style: {
color: '#7F7F7F'
}
}
} ]
} ],
tooltip: {
enabled: false
},
exporting: {
enabled: false
}
});
Try maxPadding in yAxis - http://jsfiddle.net/zKHAw/
yAxis: {
endOnTick: false,
maxPadding: 0.1
},
spacingTop is for space above your chart, not the space between your graph and graph edge.