0
내 높은 차트 기능 안에 메서드를 추가했지만이를 호출하는 데 문제가 있습니다.자바 스크립트 사용자 정의 높은 차트 방법
내가 잘못된 구문을 가지고 있거나 (JS에 상대적으로 새로운) 잘못된 지점에이 메서드를 배치했을 수 있다고 생각합니다. 이 메소드는 내 코드의 맨 아래에 있으며, 주석을 달고 단순히 그래프에 새 포인트를 추가해야하는 addPoint.its라고합니다.
나는 방법으로 경고를하면서 문제 해결을 시도했지만 아직 효과가 없습니다.
을 heres jfiddle : 사전에 어떤 도움
NewHighCharts = function()
{
chart = new Highcharts.Chart(
{
chart :
{
renderTo : 'container',
type : 'line',
marginRight : 130,
marginBottom : 25,
events:
{
click: function(e)
{
// find the clicked values and the series
var x = e.xAxis[0].value,
y = e.yAxis[0].value,
series = this.series[0];
// Add it
series.addPoint([x, y]);
}
}
},
title :
{
text : 'Body Weight',
x : -20 //center
},
xAxis :
{
categories : ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
yAxis :
{
title :
{
text : 'Weight (lbs)'
},
plotLines : [{
value : 0,
width : 1,
color : '#808080'
}]
},
tooltip :
{
formatter : function()
{
return '<b>' + this.series.name + '</b><br/>' + this.x + ': ' + this.y + 'lbs';
}
},
legend :
{
layout : 'vertical',
align : 'right',
verticalAlign : 'top',
x : -10,
y : 100,
borderWidth : 0
},
series : [{
name : 'George',
data : [185,190,185,180]
}, {
name : 'Bindu',
data : [115,110,112,115]
}]
});//end of chart
//this is the method i added
addPoint = function()
{
alert("You Added a point!")
series = this.series[0];
series.addPoint([4, 190]);
};
};//end of newHighCharts
newChart = new NewHighCharts();
newChart.addPoint();
감사 : 여기 http://jsfiddle.net/fourgates/WdMrm/
내 코드입니다!
프로젝트에 코드를 복사 할 때 어떤 이유로 작동하지 않습니다. 모든 것은 마지막 줄에서 끊어집니다 : newChart.addPoint(); 차트가 돌아 오면. 어떤 아이디어? 감사합니다 –
나는 JS를 $ (function() {copied code}) 안에 복사했습니다. –
크롬으로 디버깅 할 수 있습니까? jQuery가 포함되어 있습니까? – marspzb