Fix: show minus record for start
This commit is contained in:
+32
-8
@@ -21,20 +21,44 @@ Chart.prototype.drawRecordGraph = function(index, date, bestRecord, min, max) {
|
|||||||
if(bestRecord === "")
|
if(bestRecord === "")
|
||||||
return;
|
return;
|
||||||
|
|
||||||
this.drawText(
|
var recordTextPosY = posY - Chart.CHART_HEIGHT - Chart.CHART_RECORD_OFFSET_Y;
|
||||||
posX, posY - Chart.CHART_HEIGHT - Chart.CHART_RECORD_OFFSET_Y,
|
var absRecordValue = Math.abs(bestRecord);
|
||||||
// StringUtil.getRecordTextWithoutUnit(bestRecord) + StringUtil.getScoreUnit(sessionStorageManager.playingAppID)
|
var recordWithUnit = RecordUtil.getRecordValueWithUnit(absRecordValue, sessionStorageManager.getPlayingAppID());
|
||||||
RecordUtil.getRecordValueWithUnit(bestRecord, sessionStorageManager.getPlayingAppID())
|
if(bestRecord >= 0) {
|
||||||
);
|
this.drawText(posX, recordTextPosY, recordWithUnit);
|
||||||
|
} else {
|
||||||
|
// recordWithUnit = recordWithUnit + "/실격";
|
||||||
|
recordWithUnit = "실격/" + recordWithUnit;
|
||||||
|
this.drawDisqualificationText(posX, recordTextPosY, recordWithUnit);
|
||||||
|
}
|
||||||
|
|
||||||
// chart
|
// chart
|
||||||
this.chartGraphics.lineStyle(50, 0xdddddd, 1);
|
var chartColor = 0xffffff;
|
||||||
|
if(bestRecord >= 0)
|
||||||
|
chartColor = 0xdddddd;
|
||||||
|
else
|
||||||
|
chartColor = 0xffaaaa;
|
||||||
|
this.chartGraphics.lineStyle(50, chartColor, 1);
|
||||||
this.chartGraphics.moveTo(posX, posY);
|
this.chartGraphics.moveTo(posX, posY);
|
||||||
this.chartGraphics.lineTo(posX, posY - Chart.CHART_HEIGHT * ( (bestRecord - min) / (max - min) ));
|
this.chartGraphics.lineTo(posX, posY - Chart.CHART_HEIGHT * ( (absRecordValue - min) / (max - min) ));
|
||||||
}
|
}
|
||||||
|
|
||||||
Chart.prototype.drawText = function(posX, posY, text) {
|
Chart.prototype.drawText = function(posX, posY, text) {
|
||||||
var style = { font: "24px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
var style = { font: "22px Arial", fill: "#fff", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||||
|
|
||||||
|
var textObject = game.add.text(
|
||||||
|
posX, posY,
|
||||||
|
text, style
|
||||||
|
);
|
||||||
|
textObject.anchor.set(0.5);
|
||||||
|
textObject.stroke = "#333";
|
||||||
|
textObject.strokeThickness = 3;
|
||||||
|
|
||||||
|
return textObject;
|
||||||
|
}
|
||||||
|
|
||||||
|
Chart.prototype.drawDisqualificationText = function(posX, posY, text) {
|
||||||
|
var style = { font: "22px Arial", fill: "#faa", align: "left", boundsAlignH: "center", boundsAlignV: "middle" };
|
||||||
|
|
||||||
var textObject = game.add.text(
|
var textObject = game.add.text(
|
||||||
posX, posY,
|
posX, posY,
|
||||||
|
|||||||
@@ -45,16 +45,31 @@ HistoryRecordManager.prototype.getBestRecordAt = function(index) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HistoryRecordManager.prototype.minValueOfArray = function() {
|
HistoryRecordManager.prototype.minValueOfArray = function() {
|
||||||
|
var absArray = [];
|
||||||
var numberArray = this.getBestRecordArray(this.historyRecords);
|
var numberArray = this.getBestRecordArray(this.historyRecords);
|
||||||
return Math.min.apply(Math, numberArray);
|
for(var i = 0; i < numberArray.length; i++) {
|
||||||
|
var data = numberArray[i];
|
||||||
|
absArray.push(Math.abs(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
// console.log(numberArray);
|
||||||
|
// console.log(absArray);
|
||||||
|
return Math.min.apply(Math, absArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryRecordManager.prototype.maxValueOfArray = function() {
|
HistoryRecordManager.prototype.maxValueOfArray = function() {
|
||||||
|
var absArray = [];
|
||||||
var numberArray = this.getBestRecordArray(this.historyRecords);
|
var numberArray = this.getBestRecordArray(this.historyRecords);
|
||||||
return Math.max.apply(Math, numberArray);
|
for(var i = 0; i < numberArray.length; i++) {
|
||||||
|
var data = numberArray[i];
|
||||||
|
absArray.push(Math.abs(data));
|
||||||
|
}
|
||||||
|
|
||||||
|
return Math.max.apply(Math, absArray);
|
||||||
}
|
}
|
||||||
|
|
||||||
HistoryRecordManager.prototype.underValueForGraph = function() {
|
HistoryRecordManager.prototype.underValueForGraph = function() {
|
||||||
|
console.log("this.minValueOfRecord : " + this.minValueOfRecord);
|
||||||
var minNumberOfDigits = NumberUtil.numberOfDigits(this.minValueOfRecord);
|
var minNumberOfDigits = NumberUtil.numberOfDigits(this.minValueOfRecord);
|
||||||
var underMinValue =
|
var underMinValue =
|
||||||
Math.floor( (this.minValueOfRecord / Math.pow(10, minNumberOfDigits - 2) ) )
|
Math.floor( (this.minValueOfRecord / Math.pow(10, minNumberOfDigits - 2) ) )
|
||||||
|
|||||||
@@ -168,6 +168,8 @@ var Start = {
|
|||||||
|
|
||||||
var underValue = historyRecordManager.underValueForGraph();
|
var underValue = historyRecordManager.underValueForGraph();
|
||||||
var upperValue = historyRecordManager.upperValueForGraph();
|
var upperValue = historyRecordManager.upperValueForGraph();
|
||||||
|
console.log("underValue : " + underValue);
|
||||||
|
console.log("upperValue : " + upperValue);
|
||||||
|
|
||||||
var minValue = underValue - (upperValue - underValue) / 10;
|
var minValue = underValue - (upperValue - underValue) / 10;
|
||||||
var maxValue = upperValue;// + (upperValue - underValue) / 10;
|
var maxValue = upperValue;// + (upperValue - underValue) / 10;
|
||||||
@@ -178,12 +180,13 @@ var Start = {
|
|||||||
// break;
|
// break;
|
||||||
|
|
||||||
var historyRecord = historyRecordManager.getAt(i);
|
var historyRecord = historyRecordManager.getAt(i);
|
||||||
this.chart.drawRecordGraph(
|
|
||||||
i,
|
var dateText = historyRecord === undefined ? "-" : historyRecord.date;
|
||||||
historyRecord === undefined ? "-" : historyRecord.date,
|
var record = historyRecord === undefined ? "" : historyRecord.bestRecord;
|
||||||
historyRecord === undefined ? "" : historyRecord.bestRecord,
|
// console.log("record : " + record);
|
||||||
minValue, maxValue
|
// console.log("minValue : " + minValue);
|
||||||
);
|
// console.log("maxValue : " + maxValue);
|
||||||
|
this.chart.drawRecordGraph(i, dateText, record, minValue, maxValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.chart.printChartBaseLine();
|
this.chart.printChartBaseLine();
|
||||||
|
|||||||
Reference in New Issue
Block a user