highcharts : issue in plotting 2 graphs in 1 chart - highcharts

I have 2 graphs in 1 chart. The range of x-axis values for 1st graph is from 1 to 100. The range of x-axis values for 2nd graph is from 1 to 30. So, when the graphs are plotted in the chart, the 2nd graph gets plotted in very small area. So, it becomes difficult to read 2nd graph. My requirement - both the charts to be readable. Can anyone help me in doing this? Thanks in advance.

You could set up two axes - one for each series.
Example: http://jsfiddle.net/4v0a07op/
$(function () {
$('#container').highcharts({
title: {
text: 'Monthly Average Temperature',
x: -20 //center
},
subtitle: {
text: 'Source: WorldClimate.com',
x: -20
},
xAxis: [{
},{
opposite: true
}],
yAxis: {
title: {
text: 'Temperature (°C)'
},
plotLines: [{
value: 0,
width: 1,
color: '#808080'
}]
},
series: [{
name: '1 to 30',
xAxis: 1,
data: [11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17,18,19,10,11,12,13,14,15,16,17,18,19,10]
}, {
name: '1 to 100',
xAxis: 0,
data: [1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9,0]
}]
});
});

Related

Highstock xAxis gridlines should show only on first series

I have two series, to display both I created two xAxis and two yAxis. I need to show gridlines for both x and yaxis gridlines. But I found that xAxis grid lines are extended to second axis. Here is my code:
Highcharts.stockChart('container', {
rangeSelector: {
selected: 1
},
yAxis: [{
gridLineWidth: 2,
height: '90%'
}, {
top: '100%',
height: 45,
gridLineWidth: 2
}],
xAxis: [{
gridLineWidth: 2
},{
top: '100%',
height: 45,
gridLineWidth: 2
}],
series: [{
name: 'USD to EUR',
data: usdeur
},
{
name: 'USD to EUR',
data: usdeur,
xAxis: 1,
yAxis : 1,
}]
});
Here is a jsFiddle:
https://jsfiddle.net/Subhabrata/85sztqw6/6/
Here is my intention:

Highcharts stacked column is cut off

The first stack of my column chart is not fully visible.
The only solution I found was to add a max value on the y-axis.
Bu that is not an ideal solution because the max remains even when I disable a series by clicking on it in the legend.
Here is an JSFiddle example.
{
chart:{
type: 'column'
},
plotOptions: {
column: {
stacking:"normal",
grouping: false
}
},
yAxis: {
title: {
text: ""
},
labels: {
},
allowDecimals:true,
gridLineColor:"#DDDDDD",
endOnTick:false,
max:null
},
xAxis:{
type: "datetime",
min:1609459200000,
softMax:1638316800000,
dateTimeLabelFormats: {month:"%b",year:"%Y"},
labels: {y:20},
title:{text:null},
gridLineColor:"#DDDDDD"
},
series:[{
name:"Solar power",
data:[{
x:1609455600000,y:40.328},{x:1612134000000,y:108.824},{x:1614553200000,y:58.224}],
color: "rgba(255, 174, 1, 1)",
id:"del-solarPhotovoltaic"
},
{
name:"Delivered Electricity",
data:[{x:1609455600000,y:327.583405},{x:1612134000000,y:238.927913},{x:1614553200000,y:54.12531}],
color:"rgba(96, 189, 104, 1)",
id:"del-electricity"
},
{
name:"Natural gas",
data:[{x:1609455600000,y:4073.892843},{x:1612134000000,y:2768.81114}],
color:"rgba(93, 165, 218, 1)",
id:"del-naturalGas"
},
{
name:"Exported Electricity",
data:[{x:1609455600000,y:-19.093318},{x:1612134000000,y:-68.414876},{x:1614553200000,y:-37.718392,}],
color:"rgba(96, 189, 104, 1)",
id:"exp-electricity"
}]
}
This happens because your x-axis min value: 1609459200000 is greater than the first data point x value: 1609455600000 and Highcharts doesn't take into account the first column when calculating y-axis extremes (treated as if it were outside the chart).
Similar situation presented here: http://jsfiddle.net/BlackLabel/b1oucLne/
xAxis: {
min: 4,
max: 40
},
series: [{
type: 'column',
data: [{
x: 2,
y: 4073.892843
}, {
x: 6,
y: 2768.81114
}]
}]
As a solution reduce or remove xAxis.min property.

Horizontal crosshairs for multiple series

It seems like when I enable crosshair for the yAxis, only the last series defined get a crosshair. I would like all of them to be crosshaired.
(.. and I would love if they also had the color (or preferably a darker variant) as the series.)
You can create an y axis per series, link those additional axes to the first one and define a specific crosshair in each axis - then link series with a specific axis and you will get an seperate customizable crosshair per series.
Highcharts.chart('container', {
yAxis: [{
gridLineWidth: 0,
crosshair: {
width: 2,
color: Highcharts.getOptions().colors[0]
}
}, {
linkedTo: 0,
crosshair: {
width: 2,
color: Highcharts.getOptions().colors[1]
},
visible: false
}],
tooltip: {
shared: true
},
series: [{
data: data.slice()
}, {
yAxis: 1,
data: data.reverse()
}]
});
example: http://jsfiddle.net/absuLu6h/

Cannot plot scatter and columnrange graph with multiple y-axis

I am trying to plot a 'scatter' graph and 'columnrange' graph with multiple y-axis (ie two graphs stacked on top of each other with common x-axis). The scatter plot represents an event that occured in particular month and columnrange plot represents the time duration of an event. Both the graphs represent one and only one event type. I tried many things but was not able to produce a graph with my requirements.
$(function() {
$('#container').highcharts({
title: { text: null },
subtitle: { text: null },
legend: { enabled: false },
xAxis: {
type: 'datetime',
title: { text: null }
},
yAxis: [{
top: 10,
height: 60,
offset: 0,
title: { text: 'Plot 1'}
},{
top: 80,
height: 60,
offset: 0,
title: { text: 'Plot 2'}
}]
});
chart = $('#container').highcharts();
chart.addSeries({
yAxis: 0,
type: 'scatter',
marker: {
enabled: true,
symbol: 'triangle'
},
data: [[1356977700000,1], [1359656100000,1], [1364753700000,1]]
});
chart.addSeries({
yAxis: 1,
type: 'columnrange',
data: [[1356977700000, 1359656100000], [1362075300000, 1364753700000]]
});
});
This is how I want to represent columnrange graph
This is how my current plot looks like (second graph is behaving as 'column' graph instead of 'columnrange')
Also I would like to locate the scatter plot points in the middle of the area assigned for scatter plot. How can I achieve that. (currently I have set y=1 for scatter graph.)
To have columnrange series inverted a chart needs to be inverted.
If you want for columntange points to share same horizontal line, then set same x value for points.
Example: http://jsfiddle.net/ubdxdqnh/

trouble with categories on highcharts column chart

I am having some difficulty getting my x-axis labels correct. i am using highcharts to draw a column chart, but instead of useing my catagories as labels, it uses numbers from 1 - however many plots points there are.
here is the code:
$('#bar').highcharts({
chart: {
borderColor: "#FFFFFF",
borderRadius: 2,
backgroundColor: "#D8D8D8",
renderTo: 'chartdiv3',
type: 'column'
},
title: { text: 'one year rain' },
xAxis: [{
type: "catagory",
catagories: [
'09/19',
'09/12',
'09/05',
'08/29',
'08/22',
'08/15',
'08/08',
'08/01',
'07/25',
'07/18',
'07/11',
'07/04',
'10/12'
],
labels: {
rotation: -45,
style: {
fontSize: '13px',
fontFamily: 'Verdana, sans-serif'
}
},
title: {
text: 'week ending'
}
}],
yAxis: {
title: { text: 'inches'}
},
plotOptions: {
column: {
pointPadding: 0.2,
borderWidth: 0
}
},
// must move the month ahead because javascript indexes a month as a number between 0 and 11
series: [{
name: 'rain',
color: "#2E64FE",
type: "column",
data: [
0.0,
0.05,
0.2,
0.02,
1.48,
0.38,
1.75,
2.74,
1.07,
0.36,
2.72,
0.1,
0.0
]
}]
});
the plots look fine, but the labels both in the tooltip and at the bottom for the x-axis just show numbers 1-12.
i appreciate any tips here. I have searched everywhere.
You spelled "categories" incorrectly.
Something like this should work:
categories: ['Apples', 'Bananas', 'Oranges']

Resources