Highcharts column chart - transform columns manually after render - javascript

I have a basic column chart done in Highcharts.
I would like to 'move' (= use CSS transform: translate()) each column in the chart.
I tried to use CSS styles to achieve this, but it obviously broke the positioning rendered by Highcharts.
Is there any way how to change the existing elements in the callback function?
Thank you
Code:
http://jsfiddle.net/tomexx/vrh5kzzz/10/
$(function () {
var config = {
chart: {
type: 'column',
backgroundColor: 'rgba(40,40,40,1)'
},
title: {
text: ''
},
subtitle: {
text: ''
},
legend: {
enabled: false
},
credits: {
enabled: false
},
tooltip: {
enabled: false
},
xAxis: {
categories: [
'Likes',
'Comments',
'Shares'
],
tickColor: 'rgba(83,83,83,1)',
gridLineColor: 'rgba(83,83,83,1)',
gridLineWidth: 1,
minorGridLineColor: 'rgba(83,83,83,1)',
lineColor: 'rgba(83,83,83,1)'
},
yAxis: {
min: 0,
title: {
text: ''
},
gridLineColor: 'rgba(83,83,83,1)',
minorGridLineColor: 'rgba(83,83,83,1)',
lineColor: 'rgba(83,83,83,1)'
},
plotOptions: {
column: {
grouping: false,
shadow: false,
borderWidth: 0,
animation: false,
enableMouseTracking: false,
}
},
series: [{
color: 'rgba(126,200,54,1)',
data: [44, 73, 20],
pointPadding: 0.3,
pointPlacement: 0.16
}, {
color: 'rgba(43,205,203,1)',
data: [150, 88, 20],
pointPadding: 0.3,
pointPlacement: 0.04
}, {
color: 'rgba(168,68,214,1)',
data: [63, 33, 10],
pointPadding: 0.3,
pointPlacement: -0.04
}, {
color: 'rgba(255,191,0,1)',
data: [86, 245, 222],
pointPadding: 0.3,
pointPlacement: -0.12
}]
};
$('#container').highcharts(config);
});

Instaed of CSS styles, you can use pointPlacement value with number.
Since Highcharts 3.0.2, the point placement can also be numeric, where
0 is on the axis value, -0.5 is between this value and the previous,
and 0.5 is between this value and the next. Unlike the textual
options, numeric point placement options won't affect axis padding.

Related

Highcharts: How to make line touch left + right sides

I would like to make this line touch the left + right edges, instead of the padding/margin highlighted in red here:
I have tried everything from minPadding, maxPadding, margin, spacing, groupPadding to pointPadding...
Here are my chart options:
{
chart: {
margin: 0,
spacing: [0,0,0,0]
},
title: { text: '' },
xAxis: {
labels: { enabled: false },
minPadding: 0,
maxPadding: 0
},
yAxis: {
title: { text: '' },
minPadding: 0,
maxPadding: 0,
labels: { enabled: false },
offset: 0
},
plotOptions: {
column: {
groupPadding: 0,
pointPadding: 0
},
},
series: [{
data: [12, 8, 43, 35, 20, 90, 100, 110],
type: 'line',
showInLegend: false,
marker: { enabled: false }
}],
tooltip: { enabled: false },
credits: { enabled: false }
}
Any help is greatly appreciated - Thx!
My solutions work with this. Did you try it?
{
chart: {
"marginLeft": 0,
"marginRight": 0,
"spacing": [0,0,0,0]
},
//....other configs
}
if not check following link solves you problem
https://www.highcharts.com/forum/viewtopic.php?t=40852

High charts gauge-solid and different data sets

I'm using High charts gauge-solid. So I need to create below like chart.
Can you tell me how to give different data sets for this chart (each and every color has its own data)?
What I need is this:
This is what I have tried: jsfiddle
$(function () {
$('#gauge').highcharts({
chart: {
type: 'solidgauge',
backgroundColor: 'transparent'
},
title: null,
pane: {
center: ['50%', '70%'],
size: '130%',
startAngle: -120,
endAngle: 120,
background: {
backgroundColor: '#fff',
innerRadius: '75%',
outerRadius: '100%',
shape: 'arc',
borderColor: 'transparent'
}
},
tooltip: {
enabled: false
},
// the value axis
yAxis: {
min: 0,
max: 100,
stops: [
[0.1, '#e74c3c'], // red
[0.5, '#f1c40f'], // yellow
[0.9, '#2ecc71'] // green
],
minorTickInterval: null,
tickPixelInterval: 400,
tickWidth: 0,
gridLineWidth: 0,
gridLineColor: 'transparent',
labels: {
enabled: false
},
title: {
enabled: false
}
},
credits: {
enabled: false
},
plotOptions: {
solidgauge: {
innerRadius: '75%',
dataLabels: {
y: -45,
borderWidth: 0,
useHTML: true
}
}
},
series: [{
data: [83],
dataLabels: {
format: '<p style="text-align:center;">{y}%</p>'
}
}]
});
});
data array can contain more than one value for a series:
series: [{
data: [80, 150, 200]
}]
Live demo: http://jsfiddle.net/kkulig/tou6wwxj/
If you want every dial to move only within its own range then you can simply make sure that a proper value is assigned to a point while initializing or updating it.

Highcharts: Heatmap using CSV

I am trying to load data via CSV file. Now if I have it already on the page as a hidden div, it works great. But trying to load it from a CSV file via Jquery $.get is not working. The x and y axis shows, but the heatmap itself does not.
The javascript looks like this (without the actual file offhand):
$.get('http://www.urltofile.com/cell001.csv', function(csv) {
generateHeatMap($('#heatmapBody'),csv);
});
function generateHeatMap(target,data) {
target.highcharts({
chart: {
type: 'heatmap',
//height: highChartsArguments.chartHeight
margin: [60, 10, 80, 50]
},
boost: {
useGPUTranslations: true
},
title: {
text: 'Highcharts extended heat map',
style: {
color: 'black',
fontSize: '12px',
fontFamily: 'Verdana'
}
},
xAxis: {
type: 'text',
min: 0,
max: 427,
labels: {
align: 'left',
x: 5,
y: 14,
format: '{value}' // long month
},
showLastLabel: false,
tickLength: 16
},
yAxis: {
title: {
text: null
},
labels: {
format: '{value}'
},
minPadding: 0,
maxPadding: 0,
startOnTick: false,
endOnTick: false,
tickPositions: [0, 16, 32, 48, 64, 80, 96, 112, 133],
tickWidth: 1,
min: 0,
max: 133,
reversed: true
},
colorAxis: {
max: 1.5,
min: -1.5,
minColor: '#00FF00',
maxColor: '#FF0000',
stops: [
[0.0, '#00FF00'],
[0.5, '#003319'],
[0.9, '#FF0000'],
[1, '#FF0000']
]
},
credits: {
enabled: false
},
legend: {
enabled: true,
align: 'right',
layout: 'vertical',
margin: 0,
verticalAlign: 'top',
symbolHeight: 60
},
series: [{
name: 'heatmap',
data: {
csv: data
},
boostThreshold: 100,
borderWidth: 0,
nullColor: '#EFEFEF',
tooltip: {
headerFormat: 'Test<br/>',
pointFormat: '{point.x} {point.y}: <b>{point.value}</b>'
},
turboThreshold: Number.MAX_VALUE // #3404, remove after 4.0.5 release
}],
exporting: {
enabled: false
}
});
}
The CSV is over 100K rows. Is that causing a problem perhaps? As a sample, it looks like
Gene,Label,zScore
0,0,3.630958
0,1,1.547901
0,2,-0.604027
0,3,0.486755
0,4,-0.359456
0,5,0.228968
0,6,3.197601
0,7,1.554732
0,8,0.374111
Any help would be appreciated.
You load the data incorrectly. Series object is not responsible for handling csv data. If you use data module, you should move the data from series options to top level options, like this:
data: { // this is how you load the with data module
csv: data
},
series: [{
... // here, options for series goes but not data
}]
Compare your code with the official example: http://jsfiddle.net/gh/get/library/pure/highcharts/highcharts/tree/master/samples/maps/demo/heatmap/

How can I remove the extra space around my Highcharts scatter plot?

I'm trying to build an NBA shot chart generator using Highcharts. So far I've managed to gather the data and plot it, but I'm unable to overlay a court diagram over the chart to finish the job because of the extra space at the right and bottom of the chart.
Here's an Imgur gallery demonstrating what I have now and what I'm trying to achieve.
This is the code I'm using to generate the charts:
var drawChart = function(made, missed) {
$(function () {
$('#container').highcharts({
chart: {
type: 'scatter',
width: 500,
height: 470
},
title: {
text: ""
},
xAxis: {
title: {
enabled: false
},
lineWidth: 0,
gridLineWidth: 0,
minorGridLineWidth: 0,
lineColor: 'transparent',
labels: {
enabled: false
},
minorTickLength: 0,
tickLength: 0
},
yAxis: {
title: {
enabled: false
},
lineWidth: 0,
gridLineWidth: 0,
minorGridLineWidth: 0,
lineColor: 'transparent',
labels: {
enabled: false
},
minorTickLength: 0,
tickLength: 0
},
legend: {
layout: 'vertical',
align: 'left',
verticalAlign: 'top',
x: 250,
y: 400,
floating: true,
backgroundColor: (Highcharts.theme && Highcharts.theme.legendBackgroundColor) || '#FFFFFF',
borderWidth: 1
},
credits: {
enabled: false
},
plotOptions: {
scatter: {
marker: {
radius: 5,
states: {
hover: {
enabled: true,
lineColor: 'rgb(100,100,100)'
}
}
},
states: {
hover: {
marker: {
enabled: false
}
}
},
tooltip: {
headerFormat: '<b>{series.name}</b><br>',
pointFormat: '{point.x} ft, {point.y} ft'
}
}
},
series: [{
name: "Made",
color: 'rgba(223, 83, 83, .5)',
data: made
}, {
name: "Missed",
color: 'rgba(119, 152, 191, .5)',
data: missed
}
]
});
});
}
I've tried fiddling with various spacing and margin options but haven't had any luck.
Thanks.

HighCharts not plotting decimal values in x-axis

I'm trying to plot decimal values on my x-axis, but each of my data points gets placed only on my major tick marks (at whole numbers). I'm using an array of [x,y] paired data, e.g. [[35,1500], [35.21,2000], [35.72,3500], [36.32,4000]]
What is happening, is the first item get's placed over the starting value (35), the second value (x 35.21) is being placed directly over 36, the next value (x 35.72) gets placed over 37, etc. It's as if the x-value in my data is being ignored.
Here is the chart's setup attributes:
chart: {
zoomType: 'x',
spacingRight: 10,
type: 'area'
},
title: {
text: null
},
xAxis: {
allowDecimals: true,
tickInterval: 1,
minorTickInterval: 10,
labels: {
step: 1
},
title: {
text: null
}
},
yAxis: {
min: 0,
title: {
text: 'total$'
}
},
tooltip: {
shared: true
},
legend: {
enabled: false
},
plotOptions: {
area: {
pointStart: 35,
lineWidth: 1,
marker: {
enabled: false
},
shadow: false,
states: {
hover: {
lineWidth: 1
}
},
threshold: null
}
},
series: [
{
//index: 1,
name: 'trajectory$',
data: progressUpdateData,
}
]
How do I get the x-values plotted properly?
Thanks
Here's a fiddle showing your points in-between whole numbers
http://jsfiddle.net/LLExL/2462/
plotOptions: {
area: {
pointStart: 35,
pointPlacement: 'between',
lineWidth: 1,
marker: {
enabled: false
},
shadow: false,
states: {
hover: {
lineWidth: 1
}
},
threshold: null
}
}
You might want to look at http://api.highcharts.com/highcharts#plotOptions.area.pointPlacement as maybe you have this set to "on" instead of "between" somewhere?
Will's answer didn't work for me. However, setting a min and a max to yAxis did. If you have these values [[35,1500], [35.21,2000], [35.72,3500], [36.32,4000]], you simply set a minimum of 35 and a maximum of 37.
This
yAxis: {
min: 0,
title: {
text: 'total$'
}
},
became this
yAxis: {
min: 35,
max: 37,
title: {
text: 'total$'
}
},

Categories

Resources