Skip to content

Commit

Permalink
ver 10697
Browse files Browse the repository at this point in the history
10697 小程序K线支持阴线阳新都为空心柱
10695 右键菜单K线类型增加空心阳线阴线
10693 K图支持完全空心K线柱
  • Loading branch information
jones2000 committed Feb 12, 2022
1 parent b8aaa89 commit 211960f
Show file tree
Hide file tree
Showing 6 changed files with 402 additions and 79 deletions.
81 changes: 68 additions & 13 deletions umychart_uniapp_h5/umychart.uniapp.h5.js
Original file line number Diff line number Diff line change
Expand Up @@ -19910,7 +19910,7 @@ function ChartKLine()

this.ClassName='ChartKLine'; //类名
this.Symbol; //股票代码
this.DrawType=0; // 0=实心K线柱子 1=收盘价线 2=美国线 3=空心K线柱子 4=收盘价面积图 5=订单流
this.DrawType=0; // 0=实心K线柱子 1=收盘价线 2=美国线 3=空心K线柱子 4=收盘价面积图 5=订单流 6=空心K线柱子2(全部空心)
this.CloseLineColor=g_JSChartResource.CloseLineColor;
this.CloseLineAreaColor=g_JSChartResource.CloseLineAreaColor;
this.CloseLineWidth=g_JSChartResource.CloseLineWidth;
Expand Down Expand Up @@ -20420,9 +20420,10 @@ function ChartKLine()

this.DrawKBar_Up=function(data, dataWidth, upColor, drawType, x, y, left, right, yLow, yHigh, yOpen, yClose, isHScreen) //阳线
{
var isEmptyBar=(drawType==3 || drawType==6);
if (dataWidth>=4)
{
if (drawType==3)
if (isEmptyBar)
{
if ((dataWidth%2)!=0) dataWidth-=1;
}
Expand All @@ -20438,7 +20439,7 @@ function ChartKLine()
}
else
{
if (drawType==3)
if (isEmptyBar)
{
var xFixed=left+dataWidth/2;
this.Canvas.moveTo(ToFixedPoint(xFixed),ToFixedPoint(y));
Expand Down Expand Up @@ -20468,7 +20469,7 @@ function ChartKLine()
}
else
{
if (drawType==3) //空心柱
if (isEmptyBar) //空心柱
{
this.Canvas.beginPath();
this.Canvas.rect(ToFixedPoint(y),ToFixedPoint(left),ToFixedRect(yOpen-y),ToFixedRect(dataWidth));
Expand All @@ -20488,7 +20489,7 @@ function ChartKLine()
}
else
{
if (drawType==3) //空心柱
if (isEmptyBar) //空心柱
{
this.Canvas.beginPath();
this.Canvas.rect(ToFixedPoint(left),ToFixedPoint(y),ToFixedRect(dataWidth),ToFixedRect(yOpen-y));
Expand All @@ -20511,7 +20512,7 @@ function ChartKLine()
}
else
{
if (drawType==3)
if (isEmptyBar)
{
var xFixed=left+dataWidth/2;
this.Canvas.moveTo(ToFixedPoint(xFixed),ToFixedPoint(Math.max(yClose,yOpen)));
Expand Down Expand Up @@ -20547,8 +20548,14 @@ function ChartKLine()

this.DrawKBar_Down=function(data, dataWidth, downColor, drawType, x, y, left, right, yLow, yHigh, yOpen, yClose, isHScreen) //阴线
{
var isEmptyBar=(drawType==6);
if (dataWidth>=4)
{
if (isEmptyBar)
{
if ((dataWidth%2)!=0) dataWidth-=1;
}

this.Canvas.strokeStyle=downColor;
if (data.High>data.Close) //上影线
{
Expand All @@ -20560,8 +20567,17 @@ function ChartKLine()
}
else
{
this.Canvas.moveTo(ToFixedPoint(x),ToFixedPoint(y));
this.Canvas.lineTo(ToFixedPoint(x),ToFixedPoint(yOpen));
if (isEmptyBar)
{
var xFixed=left+dataWidth/2;
this.Canvas.moveTo(ToFixedPoint(xFixed),ToFixedPoint(y));
this.Canvas.lineTo(ToFixedPoint(xFixed),ToFixedPoint(Math.min(yClose,yOpen)));
}
else
{
this.Canvas.moveTo(ToFixedPoint(x),ToFixedPoint(y));
this.Canvas.lineTo(ToFixedPoint(x),ToFixedPoint(yOpen));
}
}
this.Canvas.stroke();
y=yOpen;
Expand All @@ -20579,8 +20595,24 @@ function ChartKLine()
}
else
{
if (Math.abs(yClose-y)<1) this.Canvas.fillRect(ToFixedRect(left),ToFixedRect(y),ToFixedRect(dataWidth),1); //高度小于1,统一使用高度1
else this.Canvas.fillRect(ToFixedRect(left),ToFixedRect(Math.min(y,yClose)),ToFixedRect(dataWidth),ToFixedRect(Math.abs(yClose-y)));
if (Math.abs(yClose-y)<1)
{
this.Canvas.fillRect(ToFixedRect(left),ToFixedRect(y),ToFixedRect(dataWidth),1); //高度小于1,统一使用高度1
}
else
{
if (isEmptyBar) //空心柱
{
this.Canvas.beginPath();
this.Canvas.rect(ToFixedPoint(left),ToFixedPoint(Math.min(y,yClose)),ToFixedRect(dataWidth),ToFixedRect(Math.abs(yClose-y)));
this.Canvas.stroke();
}
else
{
this.Canvas.fillRect(ToFixedRect(left),ToFixedRect(Math.min(y,yClose)),ToFixedRect(dataWidth),ToFixedRect(Math.abs(yClose-y)));
}

}
}

if (data.Open>data.Low) //下影线
Expand All @@ -20593,8 +20625,17 @@ function ChartKLine()
}
else
{
this.Canvas.moveTo(ToFixedPoint(x),ToFixedPoint(y));
this.Canvas.lineTo(ToFixedPoint(x),ToFixedPoint(yLow));
if (isEmptyBar)
{
var xFixed=left+dataWidth/2;
this.Canvas.moveTo(ToFixedPoint(xFixed),ToFixedPoint(Math.max(yClose,yOpen)));
this.Canvas.lineTo(ToFixedPoint(xFixed),ToFixedPoint(yLow));
}
else
{
this.Canvas.moveTo(ToFixedPoint(x),ToFixedPoint(y));
this.Canvas.lineTo(ToFixedPoint(x),ToFixedPoint(yLow));
}
}
this.Canvas.stroke();
}
Expand Down Expand Up @@ -24193,7 +24234,14 @@ function ChartVolStick()

var height=ToFixedRect(Math.abs(yBottom-y)>=1?yBottom-y:1);//高度调整为整数, 如果小于1, 统一使用1
y=yBottom-height;
if (bUp && (this.KLineDrawType==1 || this.KLineDrawType==2 || this.KLineDrawType==3)) //空心柱子
if (this.KLineDrawType==6) //完全空心柱
{
this.Canvas.strokeStyle=barColor.Color;
this.Canvas.beginPath();
this.Canvas.rect(ToFixedPoint(left),ToFixedPoint(y),ToFixedRect(dataWidth),height);
this.Canvas.stroke();
}
else if (bUp && (this.KLineDrawType==1 || this.KLineDrawType==2 || this.KLineDrawType==3)) //空心柱子
{
this.Canvas.strokeStyle=this.UpColor;
this.Canvas.beginPath();
Expand Down Expand Up @@ -63626,6 +63674,10 @@ function KLineRightMenu(divElement)
{
text: "收盘面积",
click: function () { chart.ChangeKLineDrawType(4); }
},
{
text: "K线(空心阳线阴线)",
click: function () { chart.ChangeKLineDrawType(6);}
}
];

Expand All @@ -63646,6 +63698,9 @@ function KLineRightMenu(divElement)
case 4:
data[4].selected=true;
break;
case 6:
data[5].selected=true;
break;
}
return data;
}
Expand Down
81 changes: 68 additions & 13 deletions vuehqchart/src/jscommon/umychart.js
Original file line number Diff line number Diff line change
Expand Up @@ -15944,7 +15944,7 @@ function ChartKLine()

this.ClassName='ChartKLine'; //类名
this.Symbol; //股票代码
this.DrawType=0; // 0=实心K线柱子 1=收盘价线 2=美国线 3=空心K线柱子 4=收盘价面积图 5=订单流
this.DrawType=0; // 0=实心K线柱子 1=收盘价线 2=美国线 3=空心K线柱子 4=收盘价面积图 5=订单流 6=空心K线柱子2(全部空心)
this.CloseLineColor=g_JSChartResource.CloseLineColor;
this.CloseLineAreaColor=g_JSChartResource.CloseLineAreaColor;
this.CloseLineWidth=g_JSChartResource.CloseLineWidth;
Expand Down Expand Up @@ -16454,9 +16454,10 @@ function ChartKLine()

this.DrawKBar_Up=function(data, dataWidth, upColor, drawType, x, y, left, right, yLow, yHigh, yOpen, yClose, isHScreen) //阳线
{
var isEmptyBar=(drawType==3 || drawType==6);
if (dataWidth>=4)
{
if (drawType==3)
if (isEmptyBar)
{
if ((dataWidth%2)!=0) dataWidth-=1;
}
Expand All @@ -16472,7 +16473,7 @@ function ChartKLine()
}
else
{
if (drawType==3)
if (isEmptyBar)
{
var xFixed=left+dataWidth/2;
this.Canvas.moveTo(ToFixedPoint(xFixed),ToFixedPoint(y));
Expand Down Expand Up @@ -16502,7 +16503,7 @@ function ChartKLine()
}
else
{
if (drawType==3) //空心柱
if (isEmptyBar) //空心柱
{
this.Canvas.beginPath();
this.Canvas.rect(ToFixedPoint(y),ToFixedPoint(left),ToFixedRect(yOpen-y),ToFixedRect(dataWidth));
Expand All @@ -16522,7 +16523,7 @@ function ChartKLine()
}
else
{
if (drawType==3) //空心柱
if (isEmptyBar) //空心柱
{
this.Canvas.beginPath();
this.Canvas.rect(ToFixedPoint(left),ToFixedPoint(y),ToFixedRect(dataWidth),ToFixedRect(yOpen-y));
Expand All @@ -16545,7 +16546,7 @@ function ChartKLine()
}
else
{
if (drawType==3)
if (isEmptyBar)
{
var xFixed=left+dataWidth/2;
this.Canvas.moveTo(ToFixedPoint(xFixed),ToFixedPoint(Math.max(yClose,yOpen)));
Expand Down Expand Up @@ -16581,8 +16582,14 @@ function ChartKLine()

this.DrawKBar_Down=function(data, dataWidth, downColor, drawType, x, y, left, right, yLow, yHigh, yOpen, yClose, isHScreen) //阴线
{
var isEmptyBar=(drawType==6);
if (dataWidth>=4)
{
if (isEmptyBar)
{
if ((dataWidth%2)!=0) dataWidth-=1;
}

this.Canvas.strokeStyle=downColor;
if (data.High>data.Close) //上影线
{
Expand All @@ -16594,8 +16601,17 @@ function ChartKLine()
}
else
{
this.Canvas.moveTo(ToFixedPoint(x),ToFixedPoint(y));
this.Canvas.lineTo(ToFixedPoint(x),ToFixedPoint(yOpen));
if (isEmptyBar)
{
var xFixed=left+dataWidth/2;
this.Canvas.moveTo(ToFixedPoint(xFixed),ToFixedPoint(y));
this.Canvas.lineTo(ToFixedPoint(xFixed),ToFixedPoint(Math.min(yClose,yOpen)));
}
else
{
this.Canvas.moveTo(ToFixedPoint(x),ToFixedPoint(y));
this.Canvas.lineTo(ToFixedPoint(x),ToFixedPoint(yOpen));
}
}
this.Canvas.stroke();
y=yOpen;
Expand All @@ -16613,8 +16629,24 @@ function ChartKLine()
}
else
{
if (Math.abs(yClose-y)<1) this.Canvas.fillRect(ToFixedRect(left),ToFixedRect(y),ToFixedRect(dataWidth),1); //高度小于1,统一使用高度1
else this.Canvas.fillRect(ToFixedRect(left),ToFixedRect(Math.min(y,yClose)),ToFixedRect(dataWidth),ToFixedRect(Math.abs(yClose-y)));
if (Math.abs(yClose-y)<1)
{
this.Canvas.fillRect(ToFixedRect(left),ToFixedRect(y),ToFixedRect(dataWidth),1); //高度小于1,统一使用高度1
}
else
{
if (isEmptyBar) //空心柱
{
this.Canvas.beginPath();
this.Canvas.rect(ToFixedPoint(left),ToFixedPoint(Math.min(y,yClose)),ToFixedRect(dataWidth),ToFixedRect(Math.abs(yClose-y)));
this.Canvas.stroke();
}
else
{
this.Canvas.fillRect(ToFixedRect(left),ToFixedRect(Math.min(y,yClose)),ToFixedRect(dataWidth),ToFixedRect(Math.abs(yClose-y)));
}

}
}

if (data.Open>data.Low) //下影线
Expand All @@ -16627,8 +16659,17 @@ function ChartKLine()
}
else
{
this.Canvas.moveTo(ToFixedPoint(x),ToFixedPoint(y));
this.Canvas.lineTo(ToFixedPoint(x),ToFixedPoint(yLow));
if (isEmptyBar)
{
var xFixed=left+dataWidth/2;
this.Canvas.moveTo(ToFixedPoint(xFixed),ToFixedPoint(Math.max(yClose,yOpen)));
this.Canvas.lineTo(ToFixedPoint(xFixed),ToFixedPoint(yLow));
}
else
{
this.Canvas.moveTo(ToFixedPoint(x),ToFixedPoint(y));
this.Canvas.lineTo(ToFixedPoint(x),ToFixedPoint(yLow));
}
}
this.Canvas.stroke();
}
Expand Down Expand Up @@ -20227,7 +20268,14 @@ function ChartVolStick()

var height=ToFixedRect(Math.abs(yBottom-y)>=1?yBottom-y:1);//高度调整为整数, 如果小于1, 统一使用1
y=yBottom-height;
if (bUp && (this.KLineDrawType==1 || this.KLineDrawType==2 || this.KLineDrawType==3)) //空心柱子
if (this.KLineDrawType==6) //完全空心柱
{
this.Canvas.strokeStyle=barColor.Color;
this.Canvas.beginPath();
this.Canvas.rect(ToFixedPoint(left),ToFixedPoint(y),ToFixedRect(dataWidth),height);
this.Canvas.stroke();
}
else if (bUp && (this.KLineDrawType==1 || this.KLineDrawType==2 || this.KLineDrawType==3)) //空心柱子
{
this.Canvas.strokeStyle=this.UpColor;
this.Canvas.beginPath();
Expand Down Expand Up @@ -59660,6 +59708,10 @@ function KLineRightMenu(divElement)
{
text: "收盘面积",
click: function () { chart.ChangeKLineDrawType(4); }
},
{
text: "K线(空心阳线阴线)",
click: function () { chart.ChangeKLineDrawType(6);}
}
];

Expand All @@ -59680,6 +59732,9 @@ function KLineRightMenu(divElement)
case 4:
data[4].selected=true;
break;
case 6:
data[5].selected=true;
break;
}
return data;
}
Expand Down
Loading

0 comments on commit 211960f

Please sign in to comment.