Skip to content

Commit

Permalink
代码合并
Browse files Browse the repository at this point in the history
  • Loading branch information
cjzhang1230 committed Feb 26, 2019
2 parents eebd2b5 + d450a19 commit 6f051ed
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 24 deletions.
5 changes: 2 additions & 3 deletions src/components/fullScreenMobileKline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,12 @@ export default {
if (this.klineDataObj.cycle !== "everyhour" && mobileKlineData.values !== null && mobileKlineData.volumes !== null && mobileKlineData.categoryData !== null) {
this.toolTipData = this.kline.updateMobileOption(mobileKlineData);
}
if (this.klineDataObj.cycle === "everyhour") {
if (this.klineDataObj.cycle === "everyhour" && this.klineDataObj.timeDivisionData) {
let timeDivisionData = this.klineDataObj.timeDivisionData
timeDivisionData.precision = precision
let divisionData = handleDivisionData(timeDivisionData)
this.divisionTime = divisionData.divisionTime
if (timeDivisionData !== null && divisionData.times !== null && divisionData.averages !== null && divisionData.prices !== null && divisionData.volumes !== null) {
this.timeDivisionTipData = this.kline.updateTimeDivisionOption(timeDivisionData, divisionData);
this.timeDivisionTipData = this.kline.updateTimeDivisionOption(timeDivisionData, divisionData, precision);
}
}
}
Expand Down
21 changes: 12 additions & 9 deletions src/components/marketDepth.vue
Original file line number Diff line number Diff line change
Expand Up @@ -40,17 +40,20 @@ export default {
price: this.klineDataObj.pricePrecision,
amount: this.klineDataObj.amountPrecision
}
let depthData = getDepthData(this.klineDataObj.depthData, this.klineDataObj.coinType, precision);
depthData.precision = precision;
if (depthData) {
if(JSON.stringify(this.coinType) !== JSON.stringify(this.klineDataObj.coinType)) {
this.clearChart();
this.depth.setDepthOption(depthData)
this.coinType = this.klineDataObj.coinType
}else {
this.depth.updateDepthOption(depthData)
if (this.klineDataObj.depthData) {
let depthData = getDepthData(this.klineDataObj.depthData, this.klineDataObj.coinType, precision);
depthData.precision = precision;
if (depthData) {
if(JSON.stringify(this.coinType) !== JSON.stringify(this.klineDataObj.coinType)) {
this.clearChart();
this.depth.setDepthOption(depthData)
this.coinType = this.klineDataObj.coinType
}else {
this.depth.updateDepthOption(depthData)
}
}
}
}
},
klineConfig() {
Expand Down
5 changes: 2 additions & 3 deletions src/components/mobileKline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,13 +104,12 @@ export default {
if (this.klineDataObj.cycle !== "everyhour" && mobileKlineData.values !== null && mobileKlineData.volumes !== null && mobileKlineData.categoryData !== null) {
this.toolTipData = this.kline.updateMobileOption(mobileKlineData);
}
if (this.klineDataObj.cycle === "everyhour") {
if (this.klineDataObj.cycle === "everyhour" && this.klineDataObj.timeDivisionData) {
let timeDivisionData = this.klineDataObj.timeDivisionData
timeDivisionData.precision = precision
let divisionData = handleDivisionData(timeDivisionData)
this.divisionTime = divisionData.divisionTime
if (timeDivisionData !== null && divisionData.times !== null && divisionData.averages !== null && divisionData.prices !== null && divisionData.volumes !== null) {
this.timeDivisionTipData = this.kline.updateTimeDivisionOption(timeDivisionData, divisionData);
this.timeDivisionTipData = this.kline.updateTimeDivisionOption(timeDivisionData, divisionData, precision);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/js/KLine.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ class KLineController {
return this.setMobileKLineChart.updateOption(data);
}

updateTimeDivisionOption(timeDivisionData, divisionData) {
return this.setMobileKLineChart.updateTimeDivisionOption(timeDivisionData, divisionData);
updateTimeDivisionOption(timeDivisionData, divisionData, precision) {
return this.setMobileKLineChart.updateTimeDivisionOption(timeDivisionData, divisionData, precision);
}

changeMobileDataZoom(type) {
Expand Down
6 changes: 3 additions & 3 deletions src/js/KLineMobileSetChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,9 @@ class KLineMobileSetChartController {
return toolTipData;
}

updateTimeDivisionOption(timeDivisionData, data) {
pricePrecision = !isNaN(timeDivisionData.precision.price) ? timeDivisionData.precision.price : pricePrecision;
amountsPrecision = !isNaN(timeDivisionData.precision.amount) ? timeDivisionData.precision.amount : amountsPrecision;
updateTimeDivisionOption(timeDivisionData, data, precision) {
pricePrecision = !isNaN(precision.price) ? precision.price : pricePrecision;
amountsPrecision = !isNaN(precision.amount) ? precision.amount : amountsPrecision;
let { times, averages, prices, volumes } = data;
let length = timeDivisionData.length - 1;
if (!toolTipData) {
Expand Down
2 changes: 1 addition & 1 deletion src/js/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const getClientHeight = () => {

export const formatDecimal = function (f, n, sep) {
// var num = parseFloat(f);
n = parseInt(n)
n = parseInt(n);
if (isNaN(f)) {
return f;
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit/specs/KLine.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ describe('test KLine', () => {
const element = document.createElement('div');
mobileKline.initMobileChart(element)
mobileKline.setTimeDivisionsOption(size)
mobileKline.updateTimeDivisionOption(timeDivisionData, divisionData)
mobileKline.updateTimeDivisionOption(timeDivisionData, divisionData, precision)
expect(mobileKline.setMobileKLineChart.kline.getOption()).not.toBeNull()
})

Expand Down
4 changes: 2 additions & 2 deletions test/unit/specs/KLineMobileSetChart.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ describe('test KLineMobileSetChart', () => {
let mobileKline = new klineMobileSetChart(mobileOption);
mobileKline.initMobileECharts(element)
mobileKline.setTimeDivisionsOption(size)
mobileKline.updateTimeDivisionOption(timeDivisionData, divisionData)
mobileKline.updateTimeDivisionOption(timeDivisionData, divisionData, precision)
expect(mobileKline.kline.getOption()).not.toBeNull();
})

Expand Down Expand Up @@ -169,7 +169,7 @@ describe('test KLineMobileSetChart', () => {
let mobileKline = new klineMobileSetChart(mobileOption);
mobileKline.initMobileECharts(element)
mobileKline.setTimeDivisionsOption(size)
mobileKline.updateTimeDivisionOption(timeDivisionData, divisionData)
mobileKline.updateTimeDivisionOption(timeDivisionData, divisionData, precision)
mobileKline.changeDataZoom('enlarge')
expect(mobileKline.kline.getOption().dataZoom[0].start).toBe(65);
expect(mobileKline.kline.getOption().dataZoom[0].end).toBe(100);
Expand Down

0 comments on commit 6f051ed

Please sign in to comment.