HightStock加标签

1. 使用加flag

$(function() {
	$.getJSON('http://www.highcharts.com/samples/data/jsonp.php?filename=aapl-ohlcv.json&callback=?', function(data) {

		// split the data set into ohlc and volume
		var ohlc = [],
			volume = [],
            flagData = [],
			dataLength = data.length;
			 console.log(data);
		for (i = 0; i < dataLength; i++) {
			ohlc.push([
				data[i][0], // the date
				data[i][1], // open
				data[i][2], // high
				data[i][3], // low
				data[i][4] // close
			]);
			
			volume.push([
				data[i][0], // the date
				data[i][5] // the volume
			])
            
            if(i % 20 == 0) {
               
                flagData.push({
                    x : data[i][0],
                    y : data[i][2],
					title : 'A',
					text : 'Shape: "squarepin"'
                });
            }
            if(i % 27 == 0) {
               
                flagData.push({
                    x : data[i][0],
                    y : data[i][2],
					title : 'B',
					text : 'Shape: "squarepin"'
                });
            }
            
           
		}

		// set the allowed units for data grouping
		var groupingUnits = [[
			'week',                         // unit name
			[1]                             // allowed multiples
		], [
			'month',
			[1, 2, 3, 4, 6]
		]];

		// create the chart
		$('#container').highcharts('StockChart', {
		    
		    rangeSelector: {
				inputEnabled: $('#container').width() > 480,
		        selected: 1
		    },

		    title: {
		        text: 'AAPL Historical'
		    },

		    yAxis: [{
		        title: {
		            text: 'OHLC'
		        },
		        height: '60%',
		        lineWidth: 2
		    }, {
		        title: {
		            text: 'Volume'
		        },
		        top: '65%',
		        height: '35%',
		        offset: 0,
		        lineWidth: 2
		    }],
		    
		    series: [{
		        type: 'candlestick',
		        name: 'AAPL',
		        data: ohlc,
		        dataGrouping: {
					units: groupingUnits
		        }
		    }, {
		        type: 'column',
		        name: 'Volume',
		        data: volume,
		        yAxis: 1,
		        dataGrouping: {
					units: groupingUnits
		        }
		    },{
				type : 'flags',
				data : flagData,
				onSeries : 'dataseries',
				shape : 'squarepin',
				width : 16
			}]
		});
	});
});

http://api.highcharts.com/highstock#series.data.marker

http://jsfiddle.net/gh/get/jquery/1.9.1/highslide-software/highcharts.com/tree/master/samples/stock/demo/flags-shapes/



  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值