0
JSP 프로젝트에 JavaScript 프레임 워크 Chartjs를 포함하고 싶습니다. 나는 단 하나의 날짜 (평균 포인트 수)가있는 매우 단순한 막 대형 차트를 시도했다. 하지만 제대로 작동하지 않는 것 같습니다. http://i43.tinypic.com/15wc6md.pngChartjs는 JSP에서 차트를 제대로 표시하지 않습니다.
내 코드는 다음과 같습니다 :
<canvas id="chartjs"></canvas>
<script>
//Get context with jQuery - using jQuery's .get() method.
var ctx = $("#chartjs").get(0).getContext("2d");
//This will get the first returned node in the jQuery collection.
var myNewChart = new Chart(ctx);
var data = {
labels : ["Durchschnittsgesamtpunktzahl aller Teilnehmer"],
datasets : [
{
fillColor : "rgba(220,220,220,0.5)",
strokeColor : "rgba(220,220,220,1)",
data : [<%=examAveragePoints%>]
}
]
}
var options = {
//Boolean - If we show the scale above the chart data
scaleOverlay : false,
//Boolean - If we want to override with a hard coded scale
scaleOverride : false,
//** Required if scaleOverride is true **
//Number - The number of steps in a hard coded scale
scaleSteps : null,
//Number - The value jump in the hard coded scale
scaleStepWidth : null,
//Number - The scale starting value
scaleStartValue : null,
//String - Colour of the scale line
scaleLineColor : "rgba(0,0,0,.1)",
//Number - Pixel width of the scale line
scaleLineWidth : 1,
//Boolean - Whether to show labels on the scale
scaleShowLabels : true,
//Interpolated JS string - can access value
scaleLabel : true,
//String - Scale label font declaration for the scale label
scaleFontFamily : "'Arial'",
//Number - Scale label font size in pixels
scaleFontSize : 12,
//String - Scale label font weight style
scaleFontStyle : "normal",
//String - Scale label font colour
scaleFontColor : "#666",
///Boolean - Whether grid lines are shown across the chart
scaleShowGridLines : true,
//String - Colour of the grid lines
scaleGridLineColor : "rgba(0,0,0,.05)",
//Number - Width of the grid lines
scaleGridLineWidth : 1,
//Boolean - If there is a stroke on each bar
barShowStroke : true,
//Number - Pixel width of the bar stroke
barStrokeWidth : 2,
//Number - Spacing between each of the X value sets
barValueSpacing : 5,
//Number - Spacing between data sets within X values
barDatasetSpacing : 1,
//Boolean - Whether to animate the chart
animation : true,
//Number - Number of animation steps
animationSteps : 60,
//String - Animation easing effect
animationEasing : "easeOutQuart",
//Function - Fires when the animation is complete
onAnimationComplete : null
}
new Chart(ctx).Bar(data,options);
</script>
문제는 데이터 여야합니다. 설정하는 코드를 게시하거나 브라우저에서 소스를보고 데이터에서 나온 결과를 게시해야합니다. [<% = examAveragePoints %>] – developerwjk
'examAveragePoints'는 61.666668입니다 (반올림 됨) – elementzero23
나는 또한 <% = examAveragePoints %> 대신'61'을 사용하려했으나 아무 것도 변경하지 않았습니다. – elementzero23