http://www.chartjs.org/의 꺽은선형 차트를 사용하고 있습니다.
Y축에 대한 max value(130)와 min value(60)가 자동으로 선택되는 것을 볼 수 있듯이 max value = 500, min value = 0을 원합니다. 이게 가능할까요?
처t.j스 V2 (베타) 를 사용합니다.
var options = {
scales: {
yAxes: [{
display: true,
ticks: {
suggestedMin: 0, // minimum will be 0, unless there is a lower value.
// OR //
beginAtZero: true // minimum value will be 0.
}
}]
}
};
처t.j스 관한 문서가 일괄이라는 axes 구성 에서 자세한 내용을 참조.
저울을 재정의해야 합니다. 다음을 시도해 보십시오.
window.onload = function(){
var ctx = document.getElementById("canvas").getContext("2d");
window.myLine = new Chart(ctx).Line(lineChartData, {
scaleOverride : true,
scaleSteps : 10,
scaleStepWidth : 50,
scaleStartValue : 0
});
}
<! - begin 스니핏: js 숨기십시오: 거짓값 콘솔: 거짓값 바벨. > 거짓값 -;
var config = {
type: 'line',
data: {
labels: ["January", "February", "March", "April", "May", "June", "July"],
datasets: [{
label: "My First dataset",
data: [10, 80, 56, 60, 6, 45, 15],
fill: false,
backgroundColor: "#eebcde ",
borderColor: "#eebcde",
borderCapStyle: 'butt',
borderDash: [5, 5],
}]
},
options: {
responsive: true,
legend: {
position: 'bottom',
},
hover: {
mode: 'label'
},
scales: {
xAxes: [{
display: true,
scaleLabel: {
display: true,
labelString: 'Month'
}
}],
yAxes: [{
display: true,
ticks: {
beginAtZero: true,
steps: 10,
stepValue: 5,
max: 100
}
}]
},
title: {
display: true,
text: 'Chart.js Line Chart - Legend'
}
}
};
var ctx = document.getElementById("canvas").getContext("2d");
new Chart(ctx, config);
<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/2.2.1/Chart.bundle.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<body>
<canvas id="canvas"></canvas>
</body>
끝 - < 스니핏 >;!
처티스 v2.4.0
7 일 http://support. (https://github.com/jtblin/angular-chart.js) 의 예에서 볼 수 있듯이 2017년 월에는 (이후 것 같다고 자주 받아야 변경률):
var options = {
yAxes: [{
ticks: {
min: 0,
max: 100,
stepSize: 20
}
}]
}
이로 인해 5 y-축 다음과 같은 값을
100
80
60
40
20
0
이 글을 쓰는 동안 2016년 차트입니다 2.3.0 js 는 최신 버전을. 다음은 한 어떻게 바꿀 수
var options = {
scales: {
yAxes: [{
display: true,
stacked: true,
ticks: {
min: 0, // minimum value
max: 10 // maximum value
}
}]
}
};
window.onload = function(){
var ctx = document.getElementById("canvas").getContext("2d");
window.myLine = new Chart(ctx ,{
type: 'line',
data: yourData,
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero:true,
min: 0,
max: 500
}
}]
}
}
});
난 # 39, & # 39 로 구성할 options&. v2 의.
붽뎄 읽어야 합니다. http://www.chartjs.org/docs/ # 는 선형 증가
이 캐비닛용입니다 카르츠실제스 2.0.
그 이유는 일부 그것은꿈의 작동안함 만들 때 같은 차트입니다 옵션 때문에 선언해야 합니다 있습니다.
$(function () {
var ctxLine = document.getElementById("myLineChart");
var myLineChart = new Chart(ctxLine, {
type: 'line',
data: dataLine,
options: {
scales: {
yAxes: [{
ticks: {
min: 0,
beginAtZero: true
}
}]
}
}
});
})
이것은 붽뎄 있습니다. http://www.chartjs.org/docs/ # 확장할 수 있습니다.
내가 쓴 《 0 부터 100 에서 무려 20 y-축 수신기마다 js 값을 표시할 수 있습니다.
이건 내 스크리프t.j스
<! - begin 스니핏: js 숨기십시오: 거짓값 콘솔: 진정한 바벨. > 거짓값 -;
//x-axis
var vehicles = ["Trucks", "Cars", "Bikes", "Jeeps"];
//The percentage of vehicles of each type
var percentage = [41, 76, 29, 50];
var ctx = document.getElementById("barChart");
var lineChart = new Chart(ctx, {
type: 'bar',
data: {
labels: vehicles,
datasets: [{
data: percentage,
label: "Percentage of vehicles",
backgroundColor: "#3e95cd",
fill: false
}]
},
options: {
scales: {
yAxes: [{
ticks: {
beginAtZero: true,
min: 0,
max: 100,
stepSize: 20,
}
}]
}
}
});
끝 - < 스니핏 >;!
이것은 웹에서 시됩니다 그래프화합니다.
1.1.1 로, 난 다음 해결하기 위해 사용되는 배율입니다 0.0 과 1.0 사이의:
var options = {
scaleOverride: true,
scaleStartValue: 0,
scaleSteps: 10,
scaleStepWidth: 0.1
}
제 경우에는 제가 사용하고 있는 진드기, 야시스 콜백하는 내 에 도달했을 때, 이 값은 100% % 와 이를 활용한 doesn& # 39 점, 내가 볼 수 없다.
yAxes: [{
ticks: {
beginAtZero: true,
steps: 10,
stepValue: 5,
max: 100.1,
callback: function(value, index, values) {
if (value !== 100.1) {
return values[index]
}
}
}
}],
또한 주효했다.
차트입니다 min" 투명지에 "; 및 " max"; 값. 이 링크를 붽뎄
https://www.chartjs.org/docs/latest/axes/cartesian/linear.html
제가 사용하고 있는 여러 프로젝트) 의 이전 버전의 균등형 실습에서는 템플리트를 v1.x 사용한 # 39 m, 어떤 i& 내거냐 처t.j스 확실하지 않습니다. As I v2.x 업데이트하십시오 이미 여러 프로젝트를 쉽게 작업할 수 없음. 위에 언급된 ' (바르타, 옵션뿐)' 는 작동안함 for me.
여기서는 버전 1.x 대한 해킹 사건
calculatedScale = calculateScale(scaleHeight,valueBounds.maxSteps,valueBounds.minSteps,valueBounds.maxValue,valueBounds.minValue,labelTemplateString);
바꿀 수 있습니다.
calculatedScale = calculateScale(scaleHeight,valueBounds.maxSteps,1,valueBounds.maxValue,0,labelTemplateString);