score:5
it seems that there is no maxrange
equivalent (feature request, torstein?) so that the axis maximum has to be determined before highcharts is called. building upon sanath's suggestion a solution would be this:
$(function () {
var seta = [29.9, 11.5, 36.4, 19.2, 4.0, 46.0, 48.2, 15.2, 16.4, 4.1, 5.6, 44.4];
var setb = [129.2, 144.0, 176.0, 135.6, 248.5, 316.4, 694.1, 795.6, 954.4, 1029.9, 1171.5, 1506.4];
var data = math.random() < 0.5 ? seta : setb;
var height=math.max.apply(math, data);
if(height > 1000){ height = 1000; }
$('#container').highcharts({
chart: {
marginright: 80 // like left
},
xaxis: {
categories: ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']
},
yaxis: [{
linewidth: 1,
max: height,
min: 0,
title: { text: 'yaxis' }
}],
series: [{
data: data
}]
});
});
as working example: http://jsfiddle.net/panicj/h2pyc/8/
score:1
$(function() {
$('#container').highcharts({
chart: {
marginright: 80 // like left
},
xaxis: {
categories: ['jan', 'feb', 'mar', 'apr', 'may', 'jun', 'jul', 'aug', 'sep', 'oct', 'nov', 'dec']
},
yaxis: [{
linewidth: 1,
max: 1000,
min: 0,
title: {
text: 'primary axis'
}
}, {
linewidth: 1,
opposite: true,
title: {
text: 'secondary axis'
}
}],
series: [{
data: [29.9, 11.5, 36.4, 19.2, 4.0, 46.0, 48.2, 15.2, 16.4, 4.1, 5.6, 44.4]
}]
});
$('#button').click(function() {
var chart = $('#container').highcharts();
if ($(this).hasclass('big')) {
$(this).removeclass('big');
chart.series[0].setdata([29.9, 11.5, 36.4, 19.2, 4.0, 46.0, 48.2, 15.2, 16.4, 4.1, 5.6, 44.4]);
chart.yaxis[0].setextremes(0, 50);
} else {
$(this).addclass('big');
chart.series[0].setdata([129.2, 144.0, 176.0, 135.6, 248.5, 316.4, 694.1, 795.6, 954.4, 1029.9, 1171.5, 1506.4]);
chart.yaxis[0].setextremes(0, 1600);
}
});
});
this solution should work for you, you just need to set yaxis extremes for the chart, if you know the maximum data range for each series it would be easy, otherwise you need to calculate the maximum value for each series.
score:1
since highcharts 4.0 we can use yaxis.ceiling
and yaxis.floor
, demo.
highcharts.chart('container1', {
yaxis: {
floor: 0,
ceiling: 100
},
series: [{
data: [-10, 1, 0, 2, 3, 5, 8, 5, 15, 14, 25, 154]
}]
});
score:4
please use setextremes to define a range. the jsfiddle has been updated.
$('#button').click(function () {
var chart = $('#container').highcharts(
);
if ($(this).hasclass('big')) {
$(this).removeclass('big');
chart.series[0].setdata([29.9, 11.5, 36.4, 19.2, 4.0, 46.0, 48.2, 15.2, 16.4, 4.1, 5.6, 44.4]);
//chart.setsize(null,100,true);
chart.yaxis[0].setextremes(0,50);
} else {
$(this).addclass('big');
chart.series[0].setdata([129.2, 144.0, 176.0, 135.6, 248.5, 316.4, 694.1, 795.6, 954.4, 1029.9, 1171.5, 1506.4]);
//chart.setsize(null,1600,true);
chart.yaxis[0].setextremes(0,1600);
}
});
});
Source: stackoverflow.com
Related Query
- Highcharts - set maximum range for yAxis but keep axis dynamic within that range
- How to set a Maximum yAxis range for HighChart graph?
- My Highcharts graph with multiple axis ignores the max value I set for the first yaxis
- How to set Highcharts chart maximum yAxis value
- Highcharts Line - When Y axis min is set to 0, connecting line isn't shown for consecutive 0 values
- Set Dynamic x-axis range in Highcharts
- How do I put Icons in the y Axis for a Dynamic Highcharts chart?
- highcharts reversed yAxis but keep fill area below spline?
- Highcharts dynamic set category update the chart but shows only points but not lines
- Highcharts - Toggling the lines that run parallel to X axis for each value on Y axis?
- Dynamic Labels for X axis in HighCharts
- Highcharts - Automatic min/max range is not set correctly for 'area' and 'column' fill types
- Decimals on yAxis are not being displayed, even if that same code works on highcharts jsfiddle
- Set a minimal default range for a column chart in Highcharts
- How to keep highcharts speedometer within range
- HighCharts - Set default Axis options for my extension
- Showing all values on one point on x axis and changing range for rCharts highcharts
- How to set the width within axis label in highcharts
- Highcharts code with same set of code/data works in PHP but does not work in JSfiddle
- set different colors for each column in highcharts
- how to set the interval of points on Y - Axis highcharts
- HighCharts - How to create dynamic chart that exports EVERYTHING
- Highcharts - How to set custom colors for the series
- How do I set a minimum upper bound for an axis in Highcharts?
- how to set dynamic data in highcharts
- How to set a static minimum value for axes in Highcharts
- Highcharts - yAxis logarithmic scale and allowDecimals set to false not seeming to have any effect
- Highcharts column range change color for negative numbers
- Set x-axis range in highcharts
- Decimal values for yAxis categories in Highcharts
More Query from same tag
- No animation when using addPoint()
- How to fetch json array data into highcharts in angularjs
- Highcharts - how to add additional information to chart
- HTML5 charts-Customizing tooltip formatting in Jasper Studio
- Showing HighCharts series name on x-axis and in legend
- HIghCharts dual axes combo
- Can not get highchart to display on page - only example will display
- Variable tick length in highcharts
- Remove the line and tickers on the X axis
- Content must fill available space down to footer and highchart must be reponsive (no scrolling allowed)
- Padding between column and y axis line - is this possible?
- Graphs backround on Iexplorer after Deploying it on the server
- Using datetime axes, but with changing scales
- Highcharts: save chart parameters when user changes them
- How replicate the value of Y Axis on both sides of the axis in Highcharts
- Real time chart on R - Shiny
- Basic highcharts plugin, need to remove line between point
- How to generate dynamic series data for highcharts?
- Highmaps : Custom data label on world map
- Specify X-Axis Category in Series Data in Highcharts
- Download pdf from High Charts
- How to fix "Property 'type' is missing in type but required in type 'SeriesXrangeOptions'" in angular highcharts module
- How to get Yaxis values from highchart
- having sorted multi column chart with unsorted series in highchart-ng module
- HighCharts column unknown number of series
- Resolve Conflict When Using Highchart and Highmap together (TypeError: ma is not a function)
- How to align the labels of sankey diagram?
- Irregular time data in highcharts
- Highcharts tooltip is hidden behind other charts
- Irregular Display of Chart In Highstocks