Skip to content

Commit

Permalink
代码合并
Browse files Browse the repository at this point in the history
  • Loading branch information
cjzhang1230 committed Apr 22, 2019
2 parents bdc041f + be32d05 commit 77a4c23
Show file tree
Hide file tree
Showing 47 changed files with 1,730 additions and 1,749 deletions.
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jcc_kline",
"version": "0.1.27",
"version": "0.1.36",
"description": "jccdex kline",
"main": "index.js",
"scripts": {
Expand Down
198 changes: 198 additions & 0 deletions src/components/BRARChart.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,198 @@
<template>
<div>
<div
:class="this.klineConfig.platform === 'pc' ? 'kline-tip' : 'mobile-kline-tip'"
v-if="toolTipData"
>
<font style="color: #e6e6e6;">BR:{{this.toolTipData.BR}}</font>
<font style="color: #f6d026;">AR:{{this.toolTipData.AR}}</font>
</div>
<i
@click="closeChart"
style="position:absolute;right:70px;z-index:5;"
class="icon iconfont icon-popover-close"
></i>
<div
ref="BRAR"
:style="{height: `${BRARSize.height}`, width: `${BRARSize.width}`}"
@mousemove="getToolTipIndex()"
></div>
</div>
</template>
<script>
import { getBRARData } from "../js/CalculateIndicator";
import IndicatorChart from "../js/IndicatorChart";
import { getLanguage } from "../js/utils";
export default {
name: "BRAR",
data() {
return {
indicator: null,
indicatorsData: null,
BRARData: null,
coinType: "",
currentCycle: "",
isRefresh: true,
chartType: "indicator",
toolTipData: null,
BRARSize: {
height: "",
width: ""
}
};
},
props: {
chartDataObj: {
type: Object,
default: () => {
return {};
}
},
klineConfig: {
type: Object,
default: () => {
return {};
}
},
resizeSize: {
type: Object,
default: () => {
return {};
}
},
toolTipIndex: {
type: Number,
default: null
},
cycle: {
type: String,
default: "hour"
}
},
watch: {
cycle() {
if (this.cycle !== this.currentCycle) {
this.init(true);
this.isRefresh = true;
}
this.currentCycle = JSON.parse(JSON.stringify(this.cycle));
},
toolTipIndex() {
let index = this.toolTipIndex;
if (index) {
if (this.chartDataObj.candleData && !this.BRARData) {
let data = JSON.parse(
JSON.stringify(this.chartDataObj.candleData.values)
);
this.BRARData = getBRARData(data, 24);
}
if (this.BRARData) {
this.toolTipData = {
BR: parseFloat(this.BRARData.BR[index]).toFixed(4),
AR: parseFloat(this.BRARData.AR[index]).toFixed(4)
};
}
}
},
resizeSize() {
this.resize();
},
chartDataObj() {
if (this.chartDataObj.candleData) {
this.indicatorsData = {
indicator: this.chartDataObj.indicators,
categoryData: this.chartDataObj.candleData.categoryData
};
this.BRARData = getBRARData(this.chartDataObj.candleData.values, 24);
let index = this.chartDataObj.index;
this.$emit("listenToTipIndex", index);
this.indicatorsData.indicatorData = this.BRARData;
}
if (this.indicatorsData && this.indicatorsData.indicatorData) {
if (
JSON.stringify(this.coinType) !==
JSON.stringify(this.chartDataObj.coinType) ||
this.isRefresh
) {
this.init(true);
this.BRAR.setIndicatorOption(this.indicatorsData, this.currentCycle);
this.isRefresh = false;
this.coinType = this.chartDataObj.coinType;
} else {
this.BRAR.updateIndicatorOption(
this.indicatorsData,
this.currentCycle
);
}
}
},
klineConfig() {
if (this.klineConfig.platform === "pc") {
let size = {
width: this.klineConfig.size.width + "px",
height: this.klineConfig.size.height + "px"
};
if (
JSON.stringify(size) !== JSON.stringify(this.BRARSize) &&
this.klineConfig.defaultSize === false
) {
this.BRARSize = {
width: this.klineConfig.size.width + "px",
height: this.klineConfig.size.height * 0.25 + "px"
};
this.resize();
}
}
}
},
created() {
if (this.klineConfig.platform === "pc") {
if (!this.klineConfig.defaultSize) {
this.BRARSize.height = this.klineConfig.size.height * 0.25 + "px";
this.BRARSize.width = this.klineConfig.size.width + "px";
} else {
this.BRARSize = {
height: "132px",
width: "100%"
};
}
} else {
this.BRARSize.height = this.klineConfig.size.height * 0.4 + "px";
this.BRARSize.width = this.klineConfig.size.width + "px";
}
this.klineConfig.chartType = "indicator";
this.BRAR = new IndicatorChart(this.klineConfig);
},
mounted() {
this.init();
},
beforeDestroy() {
this.dispose();
},
methods: {
init(clear) {
this.BRAR.initIndicatorChart(this.$refs.BRAR, clear);
this.resize();
},
getToolTipIndex() {
let index = this.BRAR.getIndicatorTipData();
this.$emit("listenToTipIndex", index);
},
closeChart() {
this.$emit("listenIndicatorChartClose", true);
},
resize() {
if (this.klineConfig.platform === "pc") {
this.BRAR.resizeIndicatorChart(
this.$refs.BRAR,
this.resizeSize.isFullScreen,
this.klineConfig.size
);
}
},
dispose() {
this.BRAR.disposeIndicatorEChart();
}
}
};
</script>
18 changes: 6 additions & 12 deletions src/components/DMIChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
<font style="color: #67ff7c;">ADXR:{{this.toolTipData.ADXR}}</font>
</div>
<i
v-if
@click="closeChart"
style="position:absolute;right:70px;z-index:5;"
class="icon iconfont icon-popover-close"
Expand All @@ -23,7 +22,7 @@
</div>
</template>
<script>
import { getDMIData } from "../js/processData";
import { getDMIData } from "../js/CalculateIndicator";
import IndicatorChart from "../js/IndicatorChart";
import { getLanguage } from "../js/utils";
export default {
Expand Down Expand Up @@ -75,8 +74,7 @@ export default {
watch: {
cycle() {
if (this.cycle !== this.currentCycle) {
this.DMI.clearIndicatorEcharts();
this.DMI.showLoading();
this.init(true);
this.isRefresh = true;
}
this.currentCycle = JSON.parse(JSON.stringify(this.cycle));
Expand Down Expand Up @@ -120,13 +118,9 @@ export default {
JSON.stringify(this.chartDataObj.coinType) ||
this.isRefresh
) {
this.DMI.clearIndicatorEcharts();
this.init(true);
this.DMI.setIndicatorOption(this.indicatorsData, this.currentCycle);
this.isRefresh = false;
this.$emit(
"listenIndicatorChartEvent",
this.DMI.getIndicatorEchart()
);
this.coinType = this.chartDataObj.coinType;
} else {
this.DMI.updateIndicatorOption(
Expand Down Expand Up @@ -180,16 +174,16 @@ export default {
this.dispose();
},
methods: {
init() {
this.DMI.initIndicatorChart(this.$refs.DMI);
init(clear) {
this.DMI.initIndicatorChart(this.$refs.DMI, clear);
this.resize();
},
getToolTipIndex() {
let index = this.DMI.getIndicatorTipData();
this.$emit("listenToTipIndex", index);
},
closeChart() {
this.$emit("listenIndicatorChartClose", true)
this.$emit("listenIndicatorChartClose", true);
},
resize() {
if (this.klineConfig.platform === "pc") {
Expand Down
15 changes: 5 additions & 10 deletions src/components/KDJChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
</div>
</template>
<script>
import { getKDJData } from "../js/processData";
import { getKDJData } from "../js/CalculateIndicator";
import IndicatorChart from "../js/IndicatorChart";
import { getLanguage } from "../js/utils";
export default {
Expand Down Expand Up @@ -73,8 +73,7 @@ export default {
watch: {
cycle () {
if (this.cycle !== this.currentCycle) {
this.stochastic.clearStochasticEcharts();
this.stochastic.showStochasticLoading()
this.init(true)
this.isRefresh = true
}
this.currentCycle = JSON.parse(JSON.stringify(this.cycle))
Expand Down Expand Up @@ -118,13 +117,9 @@ export default {
JSON.stringify(this.chartDataObj.coinType) ||
this.isRefresh
) {
this.stochastic.clearStochasticEcharts();
this.init(true)
this.stochastic.setStochasticOption(this.KDJData, this.currentCycle);
this.isRefresh = false
this.$emit(
"listenStochasticChartEvent",
this.stochastic.getStochasticEchart()
);
this.coinType = this.chartDataObj.coinType;
} else {
this.stochastic.updateStochasticOption(this.KDJData, this.currentCycle);
Expand Down Expand Up @@ -176,8 +171,8 @@ export default {
this.dispose();
},
methods: {
init() {
this.stochastic.initStochasticChart(this.$refs.stochastic);
init(clear) {
this.stochastic.initStochasticChart(this.$refs.stochastic, clear);
this.resize();
},
getToolTipData() {
Expand Down
Loading

0 comments on commit 77a4c23

Please sign in to comment.