Highcharts set the min height for (column-stacked-and-grouped) chart.

The mian way.

1.use axis.translate function to convert value to pixel and backward

point to pixel:

plot_y = chart.yAxis[0].translate(point_y)

pixel to point, simply add "true" as second parameter:

point_y = chart.yAxis[0].translate(plot_y, true)


2.update([Mixed options], [Boolean redraw], [Mixed animation])


Update the point with new values.

Parameters

  • options: Number|Array|Object
    The point options. If options is a single number, the point will be given that number as the y value.If it is an array, it will be interpreted as x and y values respectively. If it is an object, advanced options as outlined underseries.data are applied.
  • redraw: Boolean
    Defaults to true. Whether to redraw the chart after the point is updated.If doing more operations on the chart, it is a good idea to set redraw to false and callchart.redraw() after.
  • animation: Mixed
    Defaults to true. When true, the update will be animated with default animationoptions. The animation can also be a configuration object with propertiesdurationand easing.

<!DOCTYPE HTML>
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<title>Highcharts Example</title>

		<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
		<script type="text/javascript">
		$(function () {
		    var chart;
		    //set minHeight.
		    var minHeight = 10;
		    $(document).ready(function() {
		        chart = new Highcharts.Chart({
		            chart: {
		                renderTo: 'container',
		                type: 'column',
				        events: {
			                load: function(event) {
			                    var chart = this.series[0].chart;
			    	            var series = chart.series;
			    	            
			    	            for(var i = 0; i < series.length; i++){
			    	            	var serieData = series[i].data;
			    	            	console.log('series----------------------------------'+i+'-------------------------------------->'+series[i].name);
			    	            	for(var j = 0; j < serieData.length; j++){
			    	            		var dragPoint = serieData[j];
			    	            		console.log('series******'+ i +'serieData****************************************' + j);
			    	            		if(dragPoint){
			    							console.log('dragPoint.x----'+dragPoint.x);
			    							console.log('dragPoint.y----'+dragPoint.y);
			    							console.log('barX----'+dragPoint.barX);
			    							console.log('plotY-----'+dragPoint.plotY);
			    							console.log('yBottom-----'+dragPoint.yBottom);
			    							console.log('chart.plotHeight----'+chart.plotHeight);
			    							console.log('shapeArgs.height---'+dragPoint.shapeArgs.height);
			    							console.log('shapeArgs.width---'+dragPoint.shapeArgs.width);
			    							console.log('shapeArgs.x---'+dragPoint.shapeArgs.x);
			    							console.log('shapeArgs.y---'+dragPoint.shapeArgs.y);
				    		                //var series = dragPoint.series;
				    						var	newX = dragPoint.x;
				    						var newY;
			    							if(dragPoint.y != 0 && dragPoint.shapeArgs.height < minHeight){
					    		                newY = dragPoint.series.yAxis.translate(minHeight, true);
					    		                dragPoint.update([newX, newY], false);
			    							}
			    	            		}
			    	            	}
			    	            }
			    	            
			    	            chart.redraw();
			                }
			            }
		            },
		    
		            title: {
		                text: 'Total fruit consumtion, grouped by gender'
		            },
		    
		            xAxis: {
		                categories: ['Apples', 'Oranges', 'Pears', 'Grapes', 'Bananas']
		            },
		    
		            yAxis: {
		                allowDecimals: false,
		                min: 0,
		                title: {
		                    text: 'Number of fruits'
		                }
		            },
		    
		            tooltip: {
		                formatter: function() {
		                    return '<b>'+ this.x +'</b><br/>'+
		                        this.series.name +': '+ this.y +'<br/>'+
		                        'Total: '+ this.point.stackTotal;
		                }
		            },
		    
		            plotOptions: {
		                column: {
		                    stacking: 'normal'
		                }
		            },
		    
		            series: [{
		                name: 'John',
		                data: [5, 300, 400, 700, 20],
		                stack: 'male'
		            }, {
		                name: 'Joe',
		                data: [30, 40, 400, 200, 50],
		                stack: 'male'
		            }, {
		                name: 'Jane',
		                data: [20, 500, 60, 200, 100],
		                stack: 'female'
		            }, {
		                name: 'Janet',
		                data: [3, 0, 400, 400, 3],
		                stack: 'female'
		            }]
		        });
		    });
		    
		});
		</script>
	</head>
	<body>
		<script src="../../js/highcharts.js"></script>
		<script src="../../js/modules/exporting.js"></script>
		<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
	</body>
</html>


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值