Skip to content

Commit

Permalink
Merge branch 'zcZhang' into zcZhang_test
Browse files Browse the repository at this point in the history
  • Loading branch information
zcZhang123 committed Oct 31, 2019
2 parents dfb12fe + 046c24b commit ac2ca3f
Show file tree
Hide file tree
Showing 12 changed files with 90 additions and 68 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.2.6",
"version": "0.2.7",
"description": "jccdex kline",
"main": "index.js",
"scripts": {
Expand Down
1 change: 1 addition & 0 deletions src/components/IndicatorChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
class="close-icon"
></i>
<div
id="Indicator"
ref="Indicator"
:style="{height: `${IndicatorSize.height}`, width: `${IndicatorSize.width}`}"
@mousemove="getToolTipIndex()"
Expand Down
38 changes: 14 additions & 24 deletions src/components/klineChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
@click="chooseCycle('everyhour')"
:class="this.cycle === 'everyhour' ? 'kline-cycle-btn kline-btn-active' : 'kline-cycle-btn'"
>{{message.timeSharing}}</div>
<!-- 均线显示隐藏按钮-->
<!-- <div @click="showMA" class="kline-cycle-btn">均线</div> -->
</div>
<!-- tooltip数据显示 -->
<div
Expand All @@ -92,7 +90,7 @@
<font class="tooltip-data-name">{{message.volume}}{{this.toolTipData.volume}}</font>
<br />
</div>
<div v-if="outspreadMA && this.showIndicatorMA">
<div v-if="outspreadMA && this.outspreadMA">
<font
v-for="MAitem in this.klineConfig.MA"
:key="MAitem.id"
Expand Down Expand Up @@ -555,7 +553,7 @@ export default {
this.coinType = this.klineDataObj.coinType;
}
this.changeCycleLanguage(this.cycle);
this.changeChartDataObj(this.klineDataObj, this.showIndicatorMA);
this.changeChartDataObj(this.klineDataObj, this.outspreadMA);
},
fullscreen() {
if (this.fullscreen && getLanguage().language === "en") {
Expand All @@ -571,10 +569,7 @@ export default {
}
},
methods: {
showMA() {
this.showIndicatorMA = !this.showIndicatorMA;
this.changeChartDataObj(this.klineDataObj, this.showIndicatorMA);
},
showMA() {},
clickMinCycle() {
this.showMinCycle = !this.showMinCycle;
if (this.showMinCycle) {
Expand Down Expand Up @@ -658,17 +653,15 @@ export default {
let cycle = data.cycle;
if (data.klineData) {
candleData = splitData(data.klineData);
if (MA) {
for (var i = 0; i < this.klineConfig.MA.length; i++) {
MAData[i] = {};
MAData[i].name = this.klineConfig.MA[i].name;
MAData[i].data = calculateMA(
this.klineConfig.MA[i].name.substring(2) * 1,
candleData
);
}
for (var i = 0; i < this.klineConfig.MA.length; i++) {
MAData[i] = {};
MAData[i].name = this.klineConfig.MA[i].name;
MAData[i].data = calculateMA(
this.klineConfig.MA[i].name.substring(2) * 1,
candleData
);
}
candleData.showIndicatorMA = this.showIndicatorMA;
candleData.showIndicatorMA = this.outspreadMA;
candleData.MAData = MAData;
candleData.precision = precision;
}
Expand All @@ -695,11 +688,8 @@ export default {
};
},
showMAData() {
if (!this.outspreadMA) {
this.outspreadMA = true;
} else {
this.outspreadMA = false;
}
this.outspreadMA = !this.outspreadMA;
this.changeChartDataObj(this.klineDataObj, this.outspreadMA);
},
showIndicatorChart(indicator) {
if (indicator === this.showIndicator) {
Expand All @@ -711,7 +701,7 @@ export default {
}
this.showIndicatorOpt = false;
this.resize();
this.changeChartDataObj(this.klineDataObj, this.showIndicatorMA);
this.changeChartDataObj(this.klineDataObj, this.outspreadMA);
},
// 获取当前鼠标所在点的数据
getTipDataIndex(index) {
Expand Down
19 changes: 8 additions & 11 deletions src/components/mobileChart.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
<font class="mobile-tooltip-name">{{message.volumeMobile}}</font>
<font class="mobile-tooltip-data">{{this.toolTipData.volume}}</font>
</div>
<!-- 均线显示隐藏按钮-->
<!-- <div @click="showMA" class="mobile-ma-btn">均线</div> -->
<div v-show="showIndicatorMA" style="font-size:0.16rem; margin-top: 0.1rem;">
<font
v-for="MAitem in this.klineConfig.MA"
Expand Down Expand Up @@ -69,6 +67,7 @@
v-on:listenToChildEvent="changeCycle"
v-on:listenTipIndex="getTipDataIndex"
v-on:listenIndicatorChartOpenClose="getIndicatorOpenClose"
@listenShowMA="showMA"
:kline-config="klineConfig"
:chart-data-obj="chartDataObj"
></KLine>
Expand Down Expand Up @@ -224,15 +223,13 @@ export default {
};
if (chartData.cycle !== "everyhour" && chartData.klineData) {
candleData = splitData(chartData.klineData);
if (MA) {
for (var i = 0; i < this.klineConfig.MA.length; i++) {
MAData[i] = {};
MAData[i].name = this.klineConfig.MA[i].name;
MAData[i].data = calculateMA(
this.klineConfig.MA[i].name.substring(2) * 1,
candleData
);
}
for (var i = 0; i < this.klineConfig.MA.length; i++) {
MAData[i] = {};
MAData[i].name = this.klineConfig.MA[i].name;
MAData[i].data = calculateMA(
this.klineConfig.MA[i].name.substring(2) * 1,
candleData
);
}
candleData.MAData = MAData;
candleData.showIndicatorMA = this.showIndicatorMA;
Expand Down
13 changes: 12 additions & 1 deletion src/components/mobileKline.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
<div class="indicator-font">
<font>{{message.indicator}}</font>
</div>
<div
@click="showMA"
:class="this.showIndicatorMA ? 'mobile-indicator-div-active' : 'mobile-indicator-div'"
>{{message.MA}}</div>
<div
@click="showIndicatorChart('MACD')"
:class="this.showIndicator ==='MACD' ? 'mobile-indicator-div-active' : 'mobile-indicator-div'"
Expand Down Expand Up @@ -216,7 +220,8 @@ export default {
showIndicatorDiv: false,
showIndicator: "",
watchLoading: true,
loadingTime: 0
loadingTime: 0,
showIndicatorMA: true //是否展示MA均线
};
},
props: {
Expand Down Expand Up @@ -430,6 +435,12 @@ export default {
this.showMinCycle = false;
this.showIndicatorDiv = !this.showIndicatorDiv;
},
// 点击显示、隐藏MA事件
showMA() {
this.showIndicatorMA = !this.showIndicatorMA;
this.$emit("listenShowMA", this.showIndicatorMA);
this.showIndicatorDiv = false;
},
showIndicatorChart(indicator) {
let dataZoom = this.kline.getMobileKlineDataZoom();
let indicatorData = {
Expand Down
1 change: 1 addition & 0 deletions src/components/volumeChart.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<template>
<div
id="volume"
ref="volume"
:style="{height: `${volumeSize.height}`, width: `${volumeSize.width}`}"
@mousemove="getToolTipIndex()"
Expand Down
16 changes: 16 additions & 0 deletions src/css/common.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
#kline>div>canvas:active {
cursor: pointer;
}

#Indicator>div>canvas:active {
cursor: pointer;
}

#timeSharing>div>canvas:active {
cursor: pointer;
}

#volume>div>canvas:active {
cursor: pointer;
}

.kline-cycle {
position: absolute;
left: 10px;
Expand Down
1 change: 1 addition & 0 deletions src/i18n/en-GB.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
"buy": "Buy",
"sell": "Sell",
"indicator": "Indicator",
"MA": "MA",
"MACD": "MACD",
"Volume": "Volume",
"KDJ": "KDJ",
Expand Down
3 changes: 2 additions & 1 deletion src/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,9 @@
"buy": "买入",
"sell": "卖出",
"indicator": "指标",
"MACD": "MACD",
"Volume": "成交量",
"MA": "MA",
"MACD": "MACD",
"KDJ": "KDJ",
"RSI": "RSI",
"OBV": "OBV",
Expand Down
30 changes: 16 additions & 14 deletions src/js/KLineMobileSetChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,21 +222,23 @@ class KLineMobileSetChartController {
}
}
];
for (var i = 0; i < data.MAData.length; i++) {
s[i + 1] = {
name: data.MAData[i].name,
data: data.MAData[i].data,
type: 'line',
smooth: true,
showSymbol: false,
lineStyle: {
normal: {
color: config.MA[i].color,
opacity: 1,
width: 1
if (data.showIndicatorMA) {
for (var i = 0; i < data.MAData.length; i++) {
s[i + 1] = {
name: data.MAData[i].name,
data: data.MAData[i].data,
type: 'line',
smooth: true,
showSymbol: false,
lineStyle: {
normal: {
color: config.MA[i].color,
opacity: 1,
width: 1
}
}
}
};
};
}
}
return s;
}
Expand Down
32 changes: 17 additions & 15 deletions src/js/KLineSetChart.js
Original file line number Diff line number Diff line change
Expand Up @@ -207,22 +207,24 @@ class KLineSetChartController {
}
}
}];
for (var i = 0; i < data.MAData.length; i++) {
s[i + 1] = {
name: data.MAData[i].name,
data: data.MAData[i].data,
type: 'line',
symbol: 'none', //
smooth: true, // 是否平滑显示
showSymbol: false, // 是否显示 symbol, 如果 false 则只有在 tooltip hover 的时候显示。
lineStyle: { // 线的样式
normal: {
color: config.MA[i].color, // 颜色
opacity: 1, // 图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形
width: 1 // 线宽
if (data.showIndicatorMA) {
for (var i = 0; i < data.MAData.length; i++) {
s[i + 1] = {
name: data.MAData[i].name,
data: data.MAData[i].data,
type: 'line',
symbol: 'none', //
smooth: true, // 是否平滑显示
showSymbol: false, // 是否显示 symbol, 如果 false 则只有在 tooltip hover 的时候显示。
lineStyle: { // 线的样式
normal: {
color: config.MA[i].color, // 颜色
opacity: 1, // 图形透明度。支持从 0 到 1 的数字,为 0 时不绘制该图形
width: 1 // 线宽
}
}
}
};
};
}
}
return s;
}
Expand Down

0 comments on commit ac2ca3f

Please sign in to comment.