Skip to content

Commit

Permalink
ver 13059
Browse files Browse the repository at this point in the history
13058 指标标题数值上涨下跌箭头使用独立的颜色显示
13056 修正Y轴刻度延长线长度计算错误
13054 修正Y轴自定义刻度,右侧多行没有右对齐
  • Loading branch information
jones2000 committed Mar 8, 2024
1 parent ece2e81 commit 515c3b9
Show file tree
Hide file tree
Showing 11 changed files with 545 additions and 75 deletions.
124 changes: 109 additions & 15 deletions umychart_uniapp_h5/umychart.uniapp.h5.js
Original file line number Diff line number Diff line change
Expand Up @@ -15408,7 +15408,7 @@ function AverageWidthFrame()
else
{
var bgTop=yText-textHeight/2-1*pixelTatio;
if (i==0)
if (i==0 && textInfo.Text.length==0)
{
var textLeft=right;
rtText.Left=textLeft;
Expand All @@ -15428,7 +15428,7 @@ function AverageWidthFrame()
var exLine=item.ExtendLine[1];
if (IFrameSplitOperator.IsNumber(exLine.Width))
{
if (i==0) this.DrawLine(right,right+exLine.Width,y,item.LineColor,item.LineType,item);
if (i==0) this.DrawLine(right,textLeft+exLine.Width,y,item.LineColor,item.LineType,item);
textLeft+=exLine.Width;
}
}
Expand Down Expand Up @@ -54880,6 +54880,13 @@ function DynamicChartTitlePainting()
this.MerginLeft=g_JSChartResource.IndexTitleMerginLeft; //标题输出左边间距

this.Buttons=[]; //按钮

this.UpDownArrowConfig=
{
UpColor:g_JSChartResource.IndexTitle.UpDownArrow.UpColor,
DownColor:g_JSChartResource.IndexTitle.UpDownArrow.DownColor,
UnchangeColor:g_JSChartResource.IndexTitle.UpDownArrow.UnchangeColor
};


//动态标题
Expand Down Expand Up @@ -55420,27 +55427,68 @@ function DynamicChartTitlePainting()
else text=titleItem.Text;

var space=this.ParamSpace*GetDevicePixelRatio();
var textWidth=this.Canvas.measureText(text).width+space;
if ((left+textWidth)>right) break;
var indexTextWidth=this.Canvas.measureText(text).width; //标题+数值长度
var textWidth=indexTextWidth;

if (IFrameSplitOperator.IsNonEmptyArray(titleItem.TextEx))
{
var xLeft=left;
for(var n=0; n<titleItem.TextEx.length; ++n)
{
var outItem=titleItem.TextEx[n];
var outTextWidth=this.Canvas.measureText(outItem.Text).width+2;
outItem.Width=outTextWidth;
outItem.Left=xLeft;

textWidth+=outTextWidth;
xLeft+=outTextWidth;
}
}

if ((left+textWidth+space)>right) break;

if (titleItem.BG) //背景
{
var textHeight=this.Canvas.measureText("擎").width+2;
var textWidth=this.Canvas.measureText(text).width+2;
var rtBG={ Left:left, Top:bottom-textHeight/2, Width:textWidth, Height:textHeight };
this.Canvas.fillStyle=titleItem.BG;
this.Canvas.fillRect(rtBG.Left,rtBG.Top-1, rtBG.Width, rtBG.Height);

this.Canvas.fillStyle=titleItem.Color;
this.Canvas.fillText(text,rtBG.Left+1,bottom,textWidth);
this.Canvas.fillText(text,rtBG.Left+1,bottom,indexTextWidth);
left+=indexTextWidth;

if (IFrameSplitOperator.IsNonEmptyArray(titleItem.TextEx))
{
for(var n=0; n<titleItem.TextEx.length; ++n)
{
var outItem=titleItem.TextEx[n];
this.Canvas.fillStyle=outItem.TextColor;
this.Canvas.fillText(outItem.Text,left,bottom,outItem.Width);
left+=outItem.Width;
}
}

left+=(textWidth+space);
left+=space;
}
else
{
this.Canvas.fillStyle=titleItem.Color;
this.Canvas.fillText(text,left,bottom,textWidth);
left+=textWidth;
this.Canvas.fillText(text,left,bottom,indexTextWidth);
left+=indexTextWidth;

if (IFrameSplitOperator.IsNonEmptyArray(titleItem.TextEx))
{
for(var n=0; n<titleItem.TextEx.length; ++n)
{
var outItem=titleItem.TextEx[n];
this.Canvas.fillStyle=outItem.TextColor;
this.Canvas.fillText(outItem.Text,left,bottom,outItem.Width);
left+=outItem.Width;
}
}

left+=space;
}
}
}
Expand Down Expand Up @@ -55623,17 +55671,17 @@ function DynamicChartTitlePainting()
}
}

var arrow=null;
var arrowSuper=null; //独立颜色

if (this.IsShowUpDownArrow)
{
var preValue=null;
if (dataIndex-1>=0) preValue=item.Data.Data[dataIndex-1];
if (IFrameSplitOperator.IsNumber(preValue))
{
if (preValue>value) arrow='↓';
else if (preValue<value) arrow='↑';
else arrow='→';
if (preValue>value) arrowSuper={ Text:'↓', TextColor:this.UpDownArrowConfig.DownColor };
else if (preValue<value) arrowSuper={ Text:'↑', TextColor:this.UpDownArrowConfig.UpColor};
else arrowSuper={ Text:'→', TextColor:this.UpDownArrowConfig.UnchangeColor };
}
}

Expand All @@ -55644,7 +55692,21 @@ function DynamicChartTitlePainting()
if (dyValue) valueText=dyValue;
}

if (arrow) valueText+=arrow;
if (arrowSuper)
{
var outItem={ Name:null, Text:valueText, Color:item.Color, TextEx:[arrowSuper] };
if (item.Name)
{
var text=item.Name;
var dyTitle=this.GetDynamicOutName(item.Name); //动态标题
if (dyTitle) text=dyTitle;
outItem.Name=text;
}
//outItem.BG='rgb(100,100,100)';

aryText=[outItem];
valueText=null;
}
}
}

Expand Down Expand Up @@ -66483,6 +66545,16 @@ function JSChartResource()
this.OverlayIndexTitleBGColor='rgba(255,255,255,0.7)';
this.IndexTitleMerginLeft=1; //指标输出左边间距

this.IndexTitle=
{
UpDownArrow: //数值涨跌箭头
{
UpColor:"rgb(238,21,21)", //上涨
DownColor:"rgb(25,158,0)", //下跌
UnchangeColor:"rgb(0,0,0)" //不变
}
}

this.Title={
TradeIndexColor:'rgb(105,105,105)', //交易指标颜色
ColorIndexColor:'rgb(112,128,144)', //五彩K线颜色
Expand Down Expand Up @@ -67591,6 +67663,18 @@ function JSChartResource()
if (style.SelFrameBorderColor) this.SelFrameBorderColor=style.SelFrameBorderColor;
if (IFrameSplitOperator.IsNumber(style.IndexTitleMerginLeft)) this.IndexTitleMerginLeft = style.IndexTitleMerginLeft;

if (style.IndexTitle)
{
var item=style.IndexTitle;
if (item.UpDownArrow)
{
var subItem=item.UpDownArrow;
if (subItem.UpColor) this.IndexTitle.UpDownArrow.UpColor = subItem.UpColor;
if (subItem.DownColor) this.IndexTitle.UpDownArrow.DownColor = subItem.DownColor;
if (subItem.UnchangeColor) this.IndexTitle.UpDownArrow.UnchangeColor = subItem.UnchangeColor;
}
}

if (style.Frame)
{
if (style.Frame.XBottomOffset) this.Frame.XBottomOffset=style.Frame.XBottomOffset;
Expand Down Expand Up @@ -119330,6 +119414,16 @@ function GetBlackStyle()
DownTextColor: "rgb(25,158,0)",
UnchagneTextColor: "rgb(190, 190 ,190)",
CloseLineColor: 'rgb(250,250,250)',

IndexTitle:
{
UpDownArrow: //数值涨跌箭头
{
UpColor:"rgb(238,21,21)", //上涨
DownColor:"rgb(25,158,0)", //下跌
UnchangeColor:"rgb(190, 190 ,190)" //不变
}
},

Title:
{
Expand Down Expand Up @@ -130141,7 +130235,7 @@ function ScrollBarBGChart()



var HQCHART_VERSION="1.1.13050";
var HQCHART_VERSION="1.1.13058";

function PrintHQChartVersion()
{
Expand Down
Loading

0 comments on commit 515c3b9

Please sign in to comment.