Highcharts가 예쁜 그래프를 만들었어요.

2397 단어 Highcharts
var stockchart;
var curreychart;
$(document).ready(
		function() {
			$.getJSON("gotDailyReportStockView.statFund", function(data) {
				var stockoptions=createSeries(' ',' (%)',' ','stockcontainer',data.stock);
				var curreyoptions=createSeries(' ',' (%)',' ','currencycontainer',data.currency);
				stockchart = new Highcharts.Chart(stockoptions);
				curreychart=new Highcharts.Chart(curreyoptions);
			});
		});


function createSeries(title,text,toolTitle,rendercontainer,data){
	var options = {
			chart : {
				renderTo : rendercontainer,
				defaultSeriesType : 'spline'
			},
			title : {
				text : title,
				x : -20
			// center
			},
			xAxis : {
				type : 'datetime',
				tickInterval : 7 * 24 * 3600 * 1000, // one week
				categories : [],
				gridLineWidth : 1
			},
			yAxis : {
				title : {
					text : text
				}
			},
			legend : {
				enabled : true
			},
			exporting : {
				enabled : false
			},
			tooltip : {
				formatter : function() {
					return '<b>' + this.series.name + '</b><br/>'
							+ data["label"][this.x] + '  '+toolTitle+':' + this.y;
				}
			},
			plotOptions : {
				spline : {
					cursor : 'pointer',
					point : {
						events : {
							click : function() {
								hs.htmlExpand(null, {
									pageOrigin : {
										x : this.pageX,
										y : this.pageY
									},
									headingText : this.series.name,
									maincontentText : 'this.category: '
											+ this.category
											+ '<br/>this.y: ' + this.y,
									width : 200
								});
							}
						}
					}
				}
			},
			series : []
		}
	$.each(data, function(key, val) {
		if (key != 'label') {
			options.series.push( {
				name : key,
				data : val
			});
		}
	});
	return options
}

categories: X 좌표 설정
series: Y 좌표 설정.
첨부는 API

좋은 웹페이지 즐겨찾기