提交 26f09ec6 编写于 作者: HQChart's avatar HQChart

ver 8836

8835 ChartBand() 修正不支持多段数据。
8833 K线Setoption 支持设置动态叠加指标
8832 CreateOverlayWindowsIndex() 支持叠加动态脚本指标
8829 增加  EnableShowCorssCursorLine()是否显示十字光标的十字线
上级 bdaf4506
...@@ -260,6 +260,7 @@ React 例子:[demo-react.md](/教程/demo-react.md) <br> ...@@ -260,6 +260,7 @@ React 例子:[demo-react.md](/教程/demo-react.md) <br>
## 高级应用实战教程(付费文章) ## 高级应用实战教程(付费文章)
1. [HQChart实战教程19 - PC端分时图定制tooltip](https://blog.csdn.net/jones2000/article/details/108633991)<br> 1. [HQChart实战教程19 - PC端分时图定制tooltip](https://blog.csdn.net/jones2000/article/details/108633991)<br>
2. [HQChart实战教程20 - PC端K线图定制tooltip](https://blog.csdn.net/jones2000/article/details/108639960)<br> 2. [HQChart实战教程20 - PC端K线图定制tooltip](https://blog.csdn.net/jones2000/article/details/108639960)<br>
3. [HQChart实战教程21 - unapp app端分时图定制tooltip](https://blog.csdn.net/jones2000/article/details/108657043)<br>
......
...@@ -4084,9 +4084,11 @@ function JSChart(divElement) ...@@ -4084,9 +4084,11 @@ function JSChart(divElement)
{ {
var item=option.OverlayIndex[i]; var item=option.OverlayIndex[i];
if (item.Windows>=chart.Frame.SubFrame.length) continue; if (item.Windows>=chart.Frame.SubFrame.length) continue;
var obj={ WindowIndex:item.Windows,IndexName: item.Index, ShowRightText:item.ShowRightText };
if (item.Args) obj.Args=item.Args; var itemString = JSON.stringify(item);
if (item.API) obj.API=item.API; var obj = JSON.parse(itemString);
if (item.Index) obj.IndexName=item.Index;
if (item.Windows>=0) obj.WindowIndex=item.Windows;
chart.CreateOverlayWindowsIndex(obj); chart.CreateOverlayWindowsIndex(obj);
} }
...@@ -7488,6 +7490,14 @@ function JSChartContainer(uielement) ...@@ -7488,6 +7490,14 @@ function JSChartContainer(uielement)
if (IFrameSplitOperator.IsBool(option.IsLockScreen)) this.ChartDrawOption.IsLockScreen=option.IsLockScreen; if (IFrameSplitOperator.IsBool(option.IsLockScreen)) this.ChartDrawOption.IsLockScreen=option.IsLockScreen;
if (IFrameSplitOperator.IsNumber(option.Zoom) && option.Zoom>=0) this.ChartDrawOption.Zoom=option.Zoom; if (IFrameSplitOperator.IsNumber(option.Zoom) && option.Zoom>=0) this.ChartDrawOption.Zoom=option.Zoom;
} }
//是否显示十字光标的十字线
this.EnableShowCorssCursorLine=function(bShow)
{
if (!this.ChartCorssCursor) return;
this.ChartCorssCursor.IsShowCorss=bShow;
}
} }
function GetDevicePixelRatio() function GetDevicePixelRatio()
...@@ -17979,58 +17989,72 @@ function ChartBand() ...@@ -17979,58 +17989,72 @@ function ChartBand()
var y2 = 0; var y2 = 0;
var firstlinePoints = []; var firstlinePoints = [];
var secondlinePoints = []; var secondlinePoints = [];
var lIndex = 0; for(var i=this.Data.DataOffset,j=0; i<this.Data.Data.length && j<xPointCount;++i, ++j, xOffset+=(dataWidth+distanceWidth))
for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
{ {
var value=this.Data.Data[i]; firstlinePoints = [];
if (value==null || value.Value==null || value.Value2 == null) continue; secondlinePoints = [];
x=this.ChartFrame.GetXFromIndex(j); for(;i<this.Data.Data.length && j<xPointCount;++i, ++j, xOffset+=(dataWidth+distanceWidth))
y=this.ChartFrame.GetYFromData(value.Value);
y2 = this.ChartFrame.GetYFromData(value.Value2);
firstlinePoints[lIndex] = {x:x,y:y};
secondlinePoints[lIndex] = {x:x,y:y2};
lIndex++;
}
if (firstlinePoints.length > 1)
{
this.Canvas.save();
this.Canvas.beginPath();
for (var i = 0; i < firstlinePoints.length; ++i)
{ {
if (i == 0) var value=this.Data.Data[i];
this.Canvas.moveTo(firstlinePoints[i].x, firstlinePoints[i].y); if (value==null || value.Value==null || value.Value2 == null) break;
else x=this.ChartFrame.GetXFromIndex(j);
this.Canvas.lineTo(firstlinePoints[i].x, firstlinePoints[i].y); y=this.ChartFrame.GetYFromData(value.Value);
} y2 = this.ChartFrame.GetYFromData(value.Value2);
for (var j = secondlinePoints.length-1; j >= 0; --j) firstlinePoints.push({x:x,y:y});
{ secondlinePoints.push({x:x,y:y2});
this.Canvas.lineTo(secondlinePoints[j].x, secondlinePoints[j].y);
}
this.Canvas.closePath();
this.Canvas.clip();
this.Canvas.beginPath();
this.Canvas.moveTo(firstlinePoints[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < firstlinePoints.length; ++i)
{
this.Canvas.lineTo(firstlinePoints[i].x, firstlinePoints[i].y);
} }
this.Canvas.lineTo(firstlinePoints[firstlinePoints.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath(); if (firstlinePoints.length>1 && secondlinePoints.length>1)
this.Canvas.fillStyle = this.FirstColor;
this.Canvas.fill();
this.Canvas.beginPath();
this.Canvas.moveTo(secondlinePoints[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < secondlinePoints.length; ++i)
{ {
this.Canvas.lineTo(secondlinePoints[i].x, secondlinePoints[i].y); this.DrawBand(firstlinePoints, secondlinePoints);
} }
this.Canvas.lineTo(secondlinePoints[secondlinePoints.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath();
this.Canvas.fillStyle = this.SecondColor;
this.Canvas.fill();
this.Canvas.restore();
} }
} }
this.DrawBand=function(aryFrist, arySecond)
{
this.Canvas.save();
this.Canvas.beginPath();
for(var i=0;i<aryFrist.length;++i)
{
if (i == 0)
this.Canvas.moveTo(aryFrist[i].x, aryFrist[i].y);
else
this.Canvas.lineTo(aryFrist[i].x, aryFrist[i].y);
}
for (var i = arySecond.length-1; i >= 0; --i)
{
this.Canvas.lineTo(arySecond[i].x, arySecond[i].y);
}
this.Canvas.closePath();
this.Canvas.clip();
this.Canvas.moveTo(aryFrist[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < aryFrist.length; ++i)
{
this.Canvas.lineTo(aryFrist[i].x, aryFrist[i].y);
}
this.Canvas.lineTo(aryFrist[aryFrist.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath();
this.Canvas.fillStyle = this.FirstColor;
this.Canvas.fill();
this.Canvas.beginPath();
this.Canvas.moveTo(arySecond[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < arySecond.length; ++i)
{
this.Canvas.lineTo(arySecond[i].x, arySecond[i].y);
}
this.Canvas.lineTo(arySecond[arySecond.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath();
this.Canvas.fillStyle = this.SecondColor;
this.Canvas.fill();
this.Canvas.restore();
}
this.GetMaxMin=function() this.GetMaxMin=function()
{ {
var xPointCount=this.ChartFrame.XPointCount; var xPointCount=this.ChartFrame.XPointCount;
...@@ -33020,6 +33044,11 @@ function KLineChartContainer(uielement) ...@@ -33020,6 +33044,11 @@ function KLineChartContainer(uielement)
{ {
apiItem=obj.API; apiItem=obj.API;
} }
else if (obj.Script) //动态执行脚本
{
indexInfo={ Script:obj.Script, ID:obj.indexName, Name:obj.indexName};
if (obj.Name) indexInfo.Name=obj.Name;
}
else else
{ {
let scriptData = new JSIndexScript(); let scriptData = new JSIndexScript();
...@@ -33063,13 +33092,7 @@ function KLineChartContainer(uielement) ...@@ -33063,13 +33092,7 @@ function KLineChartContainer(uielement)
} }
else if (indexInfo) else if (indexInfo)
{ {
let indexData = let indexData = indexInfo;
{
Name:indexInfo.Name, Script:indexInfo.Script, Args: indexInfo.Args, ID:indexName ,
//扩展属性 可以是空
KLineType:indexInfo.KLineType, YSpecificMaxMin:indexInfo.YSpecificMaxMin, YSplitScale:indexInfo.YSplitScale,
FloatPrecision:indexInfo.FloatPrecision, Condition:indexInfo.Condition,
};
if (obj.Args) indexData.Args=obj.Args; //外部可以设置参数 if (obj.Args) indexData.Args=obj.Args; //外部可以设置参数
var scriptIndex=new OverlayScriptIndex(indexData.Name,indexData.Script,indexData.Args,indexData); //脚本执行 var scriptIndex=new OverlayScriptIndex(indexData.Name,indexData.Script,indexData.Args,indexData); //脚本执行
...@@ -397,9 +397,11 @@ function JSChart(divElement) ...@@ -397,9 +397,11 @@ function JSChart(divElement)
{ {
var item=option.OverlayIndex[i]; var item=option.OverlayIndex[i];
if (item.Windows>=chart.Frame.SubFrame.length) continue; if (item.Windows>=chart.Frame.SubFrame.length) continue;
var obj={ WindowIndex:item.Windows,IndexName: item.Index, ShowRightText:item.ShowRightText };
if (item.Args) obj.Args=item.Args; var itemString = JSON.stringify(item);
if (item.API) obj.API=item.API; var obj = JSON.parse(itemString);
if (item.Index) obj.IndexName=item.Index;
if (item.Windows>=0) obj.WindowIndex=item.Windows;
chart.CreateOverlayWindowsIndex(obj); chart.CreateOverlayWindowsIndex(obj);
} }
...@@ -3801,6 +3803,14 @@ function JSChartContainer(uielement) ...@@ -3801,6 +3803,14 @@ function JSChartContainer(uielement)
if (IFrameSplitOperator.IsBool(option.IsLockScreen)) this.ChartDrawOption.IsLockScreen=option.IsLockScreen; if (IFrameSplitOperator.IsBool(option.IsLockScreen)) this.ChartDrawOption.IsLockScreen=option.IsLockScreen;
if (IFrameSplitOperator.IsNumber(option.Zoom) && option.Zoom>=0) this.ChartDrawOption.Zoom=option.Zoom; if (IFrameSplitOperator.IsNumber(option.Zoom) && option.Zoom>=0) this.ChartDrawOption.Zoom=option.Zoom;
} }
//是否显示十字光标的十字线
this.EnableShowCorssCursorLine=function(bShow)
{
if (!this.ChartCorssCursor) return;
this.ChartCorssCursor.IsShowCorss=bShow;
}
} }
function GetDevicePixelRatio() function GetDevicePixelRatio()
...@@ -14292,58 +14302,72 @@ function ChartBand() ...@@ -14292,58 +14302,72 @@ function ChartBand()
var y2 = 0; var y2 = 0;
var firstlinePoints = []; var firstlinePoints = [];
var secondlinePoints = []; var secondlinePoints = [];
var lIndex = 0; for(var i=this.Data.DataOffset,j=0; i<this.Data.Data.length && j<xPointCount;++i, ++j, xOffset+=(dataWidth+distanceWidth))
for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
{
var value=this.Data.Data[i];
if (value==null || value.Value==null || value.Value2 == null) continue;
x=this.ChartFrame.GetXFromIndex(j);
y=this.ChartFrame.GetYFromData(value.Value);
y2 = this.ChartFrame.GetYFromData(value.Value2);
firstlinePoints[lIndex] = {x:x,y:y};
secondlinePoints[lIndex] = {x:x,y:y2};
lIndex++;
}
if (firstlinePoints.length > 1)
{ {
this.Canvas.save(); firstlinePoints = [];
this.Canvas.beginPath(); secondlinePoints = [];
for (var i = 0; i < firstlinePoints.length; ++i) for(;i<this.Data.Data.length && j<xPointCount;++i, ++j, xOffset+=(dataWidth+distanceWidth))
{
if (i == 0)
this.Canvas.moveTo(firstlinePoints[i].x, firstlinePoints[i].y);
else
this.Canvas.lineTo(firstlinePoints[i].x, firstlinePoints[i].y);
}
for (var j = secondlinePoints.length-1; j >= 0; --j)
{
this.Canvas.lineTo(secondlinePoints[j].x, secondlinePoints[j].y);
}
this.Canvas.closePath();
this.Canvas.clip();
this.Canvas.beginPath();
this.Canvas.moveTo(firstlinePoints[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < firstlinePoints.length; ++i)
{ {
this.Canvas.lineTo(firstlinePoints[i].x, firstlinePoints[i].y); var value=this.Data.Data[i];
if (value==null || value.Value==null || value.Value2 == null) break;
x=this.ChartFrame.GetXFromIndex(j);
y=this.ChartFrame.GetYFromData(value.Value);
y2 = this.ChartFrame.GetYFromData(value.Value2);
firstlinePoints.push({x:x,y:y});
secondlinePoints.push({x:x,y:y2});
} }
this.Canvas.lineTo(firstlinePoints[firstlinePoints.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath(); if (firstlinePoints.length>1 && secondlinePoints.length>1)
this.Canvas.fillStyle = this.FirstColor;
this.Canvas.fill();
this.Canvas.beginPath();
this.Canvas.moveTo(secondlinePoints[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < secondlinePoints.length; ++i)
{ {
this.Canvas.lineTo(secondlinePoints[i].x, secondlinePoints[i].y); this.DrawBand(firstlinePoints, secondlinePoints);
} }
this.Canvas.lineTo(secondlinePoints[secondlinePoints.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath();
this.Canvas.fillStyle = this.SecondColor;
this.Canvas.fill();
this.Canvas.restore();
} }
} }
this.DrawBand=function(aryFrist, arySecond)
{
this.Canvas.save();
this.Canvas.beginPath();
for(var i=0;i<aryFrist.length;++i)
{
if (i == 0)
this.Canvas.moveTo(aryFrist[i].x, aryFrist[i].y);
else
this.Canvas.lineTo(aryFrist[i].x, aryFrist[i].y);
}
for (var i = arySecond.length-1; i >= 0; --i)
{
this.Canvas.lineTo(arySecond[i].x, arySecond[i].y);
}
this.Canvas.closePath();
this.Canvas.clip();
this.Canvas.moveTo(aryFrist[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < aryFrist.length; ++i)
{
this.Canvas.lineTo(aryFrist[i].x, aryFrist[i].y);
}
this.Canvas.lineTo(aryFrist[aryFrist.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath();
this.Canvas.fillStyle = this.FirstColor;
this.Canvas.fill();
this.Canvas.beginPath();
this.Canvas.moveTo(arySecond[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < arySecond.length; ++i)
{
this.Canvas.lineTo(arySecond[i].x, arySecond[i].y);
}
this.Canvas.lineTo(arySecond[arySecond.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath();
this.Canvas.fillStyle = this.SecondColor;
this.Canvas.fill();
this.Canvas.restore();
}
this.GetMaxMin=function() this.GetMaxMin=function()
{ {
var xPointCount=this.ChartFrame.XPointCount; var xPointCount=this.ChartFrame.XPointCount;
...@@ -29333,6 +29357,11 @@ function KLineChartContainer(uielement) ...@@ -29333,6 +29357,11 @@ function KLineChartContainer(uielement)
{ {
apiItem=obj.API; apiItem=obj.API;
} }
else if (obj.Script) //动态执行脚本
{
indexInfo={ Script:obj.Script, ID:obj.indexName, Name:obj.indexName};
if (obj.Name) indexInfo.Name=obj.Name;
}
else else
{ {
let scriptData = new JSIndexScript(); let scriptData = new JSIndexScript();
...@@ -29376,13 +29405,7 @@ function KLineChartContainer(uielement) ...@@ -29376,13 +29405,7 @@ function KLineChartContainer(uielement)
} }
else if (indexInfo) else if (indexInfo)
{ {
let indexData = let indexData = indexInfo;
{
Name:indexInfo.Name, Script:indexInfo.Script, Args: indexInfo.Args, ID:indexName ,
//扩展属性 可以是空
KLineType:indexInfo.KLineType, YSpecificMaxMin:indexInfo.YSpecificMaxMin, YSplitScale:indexInfo.YSplitScale,
FloatPrecision:indexInfo.FloatPrecision, Condition:indexInfo.Condition,
};
if (obj.Args) indexData.Args=obj.Args; //外部可以设置参数 if (obj.Args) indexData.Args=obj.Args; //外部可以设置参数
var scriptIndex=new OverlayScriptIndex(indexData.Name,indexData.Script,indexData.Args,indexData); //脚本执行 var scriptIndex=new OverlayScriptIndex(indexData.Name,indexData.Script,indexData.Args,indexData); //脚本执行
...@@ -4128,9 +4128,11 @@ function JSChart(divElement) ...@@ -4128,9 +4128,11 @@ function JSChart(divElement)
{ {
var item=option.OverlayIndex[i]; var item=option.OverlayIndex[i];
if (item.Windows>=chart.Frame.SubFrame.length) continue; if (item.Windows>=chart.Frame.SubFrame.length) continue;
var obj={ WindowIndex:item.Windows,IndexName: item.Index, ShowRightText:item.ShowRightText };
if (item.Args) obj.Args=item.Args; var itemString = JSON.stringify(item);
if (item.API) obj.API=item.API; var obj = JSON.parse(itemString);
if (item.Index) obj.IndexName=item.Index;
if (item.Windows>=0) obj.WindowIndex=item.Windows;
chart.CreateOverlayWindowsIndex(obj); chart.CreateOverlayWindowsIndex(obj);
} }
...@@ -7532,6 +7534,14 @@ function JSChartContainer(uielement) ...@@ -7532,6 +7534,14 @@ function JSChartContainer(uielement)
if (IFrameSplitOperator.IsBool(option.IsLockScreen)) this.ChartDrawOption.IsLockScreen=option.IsLockScreen; if (IFrameSplitOperator.IsBool(option.IsLockScreen)) this.ChartDrawOption.IsLockScreen=option.IsLockScreen;
if (IFrameSplitOperator.IsNumber(option.Zoom) && option.Zoom>=0) this.ChartDrawOption.Zoom=option.Zoom; if (IFrameSplitOperator.IsNumber(option.Zoom) && option.Zoom>=0) this.ChartDrawOption.Zoom=option.Zoom;
} }
//是否显示十字光标的十字线
this.EnableShowCorssCursorLine=function(bShow)
{
if (!this.ChartCorssCursor) return;
this.ChartCorssCursor.IsShowCorss=bShow;
}
} }
function GetDevicePixelRatio() function GetDevicePixelRatio()
...@@ -18023,58 +18033,72 @@ function ChartBand() ...@@ -18023,58 +18033,72 @@ function ChartBand()
var y2 = 0; var y2 = 0;
var firstlinePoints = []; var firstlinePoints = [];
var secondlinePoints = []; var secondlinePoints = [];
var lIndex = 0; for(var i=this.Data.DataOffset,j=0; i<this.Data.Data.length && j<xPointCount;++i, ++j, xOffset+=(dataWidth+distanceWidth))
for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
{ {
var value=this.Data.Data[i]; firstlinePoints = [];
if (value==null || value.Value==null || value.Value2 == null) continue; secondlinePoints = [];
x=this.ChartFrame.GetXFromIndex(j); for(;i<this.Data.Data.length && j<xPointCount;++i, ++j, xOffset+=(dataWidth+distanceWidth))
y=this.ChartFrame.GetYFromData(value.Value);
y2 = this.ChartFrame.GetYFromData(value.Value2);
firstlinePoints[lIndex] = {x:x,y:y};
secondlinePoints[lIndex] = {x:x,y:y2};
lIndex++;
}
if (firstlinePoints.length > 1)
{
this.Canvas.save();
this.Canvas.beginPath();
for (var i = 0; i < firstlinePoints.length; ++i)
{ {
if (i == 0) var value=this.Data.Data[i];
this.Canvas.moveTo(firstlinePoints[i].x, firstlinePoints[i].y); if (value==null || value.Value==null || value.Value2 == null) break;
else x=this.ChartFrame.GetXFromIndex(j);
this.Canvas.lineTo(firstlinePoints[i].x, firstlinePoints[i].y); y=this.ChartFrame.GetYFromData(value.Value);
} y2 = this.ChartFrame.GetYFromData(value.Value2);
for (var j = secondlinePoints.length-1; j >= 0; --j) firstlinePoints.push({x:x,y:y});
{ secondlinePoints.push({x:x,y:y2});
this.Canvas.lineTo(secondlinePoints[j].x, secondlinePoints[j].y);
}
this.Canvas.closePath();
this.Canvas.clip();
this.Canvas.beginPath();
this.Canvas.moveTo(firstlinePoints[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < firstlinePoints.length; ++i)
{
this.Canvas.lineTo(firstlinePoints[i].x, firstlinePoints[i].y);
} }
this.Canvas.lineTo(firstlinePoints[firstlinePoints.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath(); if (firstlinePoints.length>1 && secondlinePoints.length>1)
this.Canvas.fillStyle = this.FirstColor;
this.Canvas.fill();
this.Canvas.beginPath();
this.Canvas.moveTo(secondlinePoints[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < secondlinePoints.length; ++i)
{ {
this.Canvas.lineTo(secondlinePoints[i].x, secondlinePoints[i].y); this.DrawBand(firstlinePoints, secondlinePoints);
} }
this.Canvas.lineTo(secondlinePoints[secondlinePoints.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath();
this.Canvas.fillStyle = this.SecondColor;
this.Canvas.fill();
this.Canvas.restore();
} }
} }
this.DrawBand=function(aryFrist, arySecond)
{
this.Canvas.save();
this.Canvas.beginPath();
for(var i=0;i<aryFrist.length;++i)
{
if (i == 0)
this.Canvas.moveTo(aryFrist[i].x, aryFrist[i].y);
else
this.Canvas.lineTo(aryFrist[i].x, aryFrist[i].y);
}
for (var i = arySecond.length-1; i >= 0; --i)
{
this.Canvas.lineTo(arySecond[i].x, arySecond[i].y);
}
this.Canvas.closePath();
this.Canvas.clip();
this.Canvas.moveTo(aryFrist[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < aryFrist.length; ++i)
{
this.Canvas.lineTo(aryFrist[i].x, aryFrist[i].y);
}
this.Canvas.lineTo(aryFrist[aryFrist.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath();
this.Canvas.fillStyle = this.FirstColor;
this.Canvas.fill();
this.Canvas.beginPath();
this.Canvas.moveTo(arySecond[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < arySecond.length; ++i)
{
this.Canvas.lineTo(arySecond[i].x, arySecond[i].y);
}
this.Canvas.lineTo(arySecond[arySecond.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath();
this.Canvas.fillStyle = this.SecondColor;
this.Canvas.fill();
this.Canvas.restore();
}
this.GetMaxMin=function() this.GetMaxMin=function()
{ {
var xPointCount=this.ChartFrame.XPointCount; var xPointCount=this.ChartFrame.XPointCount;
...@@ -33064,6 +33088,11 @@ function KLineChartContainer(uielement) ...@@ -33064,6 +33088,11 @@ function KLineChartContainer(uielement)
{ {
apiItem=obj.API; apiItem=obj.API;
} }
else if (obj.Script) //动态执行脚本
{
indexInfo={ Script:obj.Script, ID:obj.indexName, Name:obj.indexName};
if (obj.Name) indexInfo.Name=obj.Name;
}
else else
{ {
let scriptData = new JSIndexScript(); let scriptData = new JSIndexScript();
...@@ -33107,13 +33136,7 @@ function KLineChartContainer(uielement) ...@@ -33107,13 +33136,7 @@ function KLineChartContainer(uielement)
} }
else if (indexInfo) else if (indexInfo)
{ {
let indexData = let indexData = indexInfo;
{
Name:indexInfo.Name, Script:indexInfo.Script, Args: indexInfo.Args, ID:indexName ,
//扩展属性 可以是空
KLineType:indexInfo.KLineType, YSpecificMaxMin:indexInfo.YSpecificMaxMin, YSplitScale:indexInfo.YSplitScale,
FloatPrecision:indexInfo.FloatPrecision, Condition:indexInfo.Condition,
};
if (obj.Args) indexData.Args=obj.Args; //外部可以设置参数 if (obj.Args) indexData.Args=obj.Args; //外部可以设置参数
var scriptIndex=new OverlayScriptIndex(indexData.Name,indexData.Script,indexData.Args,indexData); //脚本执行 var scriptIndex=new OverlayScriptIndex(indexData.Name,indexData.Script,indexData.Args,indexData); //脚本执行
...@@ -397,9 +397,11 @@ function JSChart(divElement) ...@@ -397,9 +397,11 @@ function JSChart(divElement)
{ {
var item=option.OverlayIndex[i]; var item=option.OverlayIndex[i];
if (item.Windows>=chart.Frame.SubFrame.length) continue; if (item.Windows>=chart.Frame.SubFrame.length) continue;
var obj={ WindowIndex:item.Windows,IndexName: item.Index, ShowRightText:item.ShowRightText };
if (item.Args) obj.Args=item.Args; var itemString = JSON.stringify(item);
if (item.API) obj.API=item.API; var obj = JSON.parse(itemString);
if (item.Index) obj.IndexName=item.Index;
if (item.Windows>=0) obj.WindowIndex=item.Windows;
chart.CreateOverlayWindowsIndex(obj); chart.CreateOverlayWindowsIndex(obj);
} }
...@@ -3801,6 +3803,14 @@ function JSChartContainer(uielement) ...@@ -3801,6 +3803,14 @@ function JSChartContainer(uielement)
if (IFrameSplitOperator.IsBool(option.IsLockScreen)) this.ChartDrawOption.IsLockScreen=option.IsLockScreen; if (IFrameSplitOperator.IsBool(option.IsLockScreen)) this.ChartDrawOption.IsLockScreen=option.IsLockScreen;
if (IFrameSplitOperator.IsNumber(option.Zoom) && option.Zoom>=0) this.ChartDrawOption.Zoom=option.Zoom; if (IFrameSplitOperator.IsNumber(option.Zoom) && option.Zoom>=0) this.ChartDrawOption.Zoom=option.Zoom;
} }
//是否显示十字光标的十字线
this.EnableShowCorssCursorLine=function(bShow)
{
if (!this.ChartCorssCursor) return;
this.ChartCorssCursor.IsShowCorss=bShow;
}
} }
function GetDevicePixelRatio() function GetDevicePixelRatio()
...@@ -14292,58 +14302,72 @@ function ChartBand() ...@@ -14292,58 +14302,72 @@ function ChartBand()
var y2 = 0; var y2 = 0;
var firstlinePoints = []; var firstlinePoints = [];
var secondlinePoints = []; var secondlinePoints = [];
var lIndex = 0; for(var i=this.Data.DataOffset,j=0; i<this.Data.Data.length && j<xPointCount;++i, ++j, xOffset+=(dataWidth+distanceWidth))
for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
{
var value=this.Data.Data[i];
if (value==null || value.Value==null || value.Value2 == null) continue;
x=this.ChartFrame.GetXFromIndex(j);
y=this.ChartFrame.GetYFromData(value.Value);
y2 = this.ChartFrame.GetYFromData(value.Value2);
firstlinePoints[lIndex] = {x:x,y:y};
secondlinePoints[lIndex] = {x:x,y:y2};
lIndex++;
}
if (firstlinePoints.length > 1)
{ {
this.Canvas.save(); firstlinePoints = [];
this.Canvas.beginPath(); secondlinePoints = [];
for (var i = 0; i < firstlinePoints.length; ++i) for(;i<this.Data.Data.length && j<xPointCount;++i, ++j, xOffset+=(dataWidth+distanceWidth))
{
if (i == 0)
this.Canvas.moveTo(firstlinePoints[i].x, firstlinePoints[i].y);
else
this.Canvas.lineTo(firstlinePoints[i].x, firstlinePoints[i].y);
}
for (var j = secondlinePoints.length-1; j >= 0; --j)
{
this.Canvas.lineTo(secondlinePoints[j].x, secondlinePoints[j].y);
}
this.Canvas.closePath();
this.Canvas.clip();
this.Canvas.beginPath();
this.Canvas.moveTo(firstlinePoints[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < firstlinePoints.length; ++i)
{ {
this.Canvas.lineTo(firstlinePoints[i].x, firstlinePoints[i].y); var value=this.Data.Data[i];
if (value==null || value.Value==null || value.Value2 == null) break;
x=this.ChartFrame.GetXFromIndex(j);
y=this.ChartFrame.GetYFromData(value.Value);
y2 = this.ChartFrame.GetYFromData(value.Value2);
firstlinePoints.push({x:x,y:y});
secondlinePoints.push({x:x,y:y2});
} }
this.Canvas.lineTo(firstlinePoints[firstlinePoints.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath(); if (firstlinePoints.length>1 && secondlinePoints.length>1)
this.Canvas.fillStyle = this.FirstColor;
this.Canvas.fill();
this.Canvas.beginPath();
this.Canvas.moveTo(secondlinePoints[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < secondlinePoints.length; ++i)
{ {
this.Canvas.lineTo(secondlinePoints[i].x, secondlinePoints[i].y); this.DrawBand(firstlinePoints, secondlinePoints);
} }
this.Canvas.lineTo(secondlinePoints[secondlinePoints.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath();
this.Canvas.fillStyle = this.SecondColor;
this.Canvas.fill();
this.Canvas.restore();
} }
} }
this.DrawBand=function(aryFrist, arySecond)
{
this.Canvas.save();
this.Canvas.beginPath();
for(var i=0;i<aryFrist.length;++i)
{
if (i == 0)
this.Canvas.moveTo(aryFrist[i].x, aryFrist[i].y);
else
this.Canvas.lineTo(aryFrist[i].x, aryFrist[i].y);
}
for (var i = arySecond.length-1; i >= 0; --i)
{
this.Canvas.lineTo(arySecond[i].x, arySecond[i].y);
}
this.Canvas.closePath();
this.Canvas.clip();
this.Canvas.moveTo(aryFrist[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < aryFrist.length; ++i)
{
this.Canvas.lineTo(aryFrist[i].x, aryFrist[i].y);
}
this.Canvas.lineTo(aryFrist[aryFrist.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath();
this.Canvas.fillStyle = this.FirstColor;
this.Canvas.fill();
this.Canvas.beginPath();
this.Canvas.moveTo(arySecond[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < arySecond.length; ++i)
{
this.Canvas.lineTo(arySecond[i].x, arySecond[i].y);
}
this.Canvas.lineTo(arySecond[arySecond.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath();
this.Canvas.fillStyle = this.SecondColor;
this.Canvas.fill();
this.Canvas.restore();
}
this.GetMaxMin=function() this.GetMaxMin=function()
{ {
var xPointCount=this.ChartFrame.XPointCount; var xPointCount=this.ChartFrame.XPointCount;
...@@ -29333,6 +29357,11 @@ function KLineChartContainer(uielement) ...@@ -29333,6 +29357,11 @@ function KLineChartContainer(uielement)
{ {
apiItem=obj.API; apiItem=obj.API;
} }
else if (obj.Script) //动态执行脚本
{
indexInfo={ Script:obj.Script, ID:obj.indexName, Name:obj.indexName};
if (obj.Name) indexInfo.Name=obj.Name;
}
else else
{ {
let scriptData = new JSIndexScript(); let scriptData = new JSIndexScript();
...@@ -29376,13 +29405,7 @@ function KLineChartContainer(uielement) ...@@ -29376,13 +29405,7 @@ function KLineChartContainer(uielement)
} }
else if (indexInfo) else if (indexInfo)
{ {
let indexData = let indexData = indexInfo;
{
Name:indexInfo.Name, Script:indexInfo.Script, Args: indexInfo.Args, ID:indexName ,
//扩展属性 可以是空
KLineType:indexInfo.KLineType, YSpecificMaxMin:indexInfo.YSpecificMaxMin, YSplitScale:indexInfo.YSplitScale,
FloatPrecision:indexInfo.FloatPrecision, Condition:indexInfo.Condition,
};
if (obj.Args) indexData.Args=obj.Args; //外部可以设置参数 if (obj.Args) indexData.Args=obj.Args; //外部可以设置参数
var scriptIndex=new OverlayScriptIndex(indexData.Name,indexData.Script,indexData.Args,indexData); //脚本执行 var scriptIndex=new OverlayScriptIndex(indexData.Name,indexData.Script,indexData.Args,indexData); //脚本执行
...@@ -397,9 +397,11 @@ function JSChart(divElement) ...@@ -397,9 +397,11 @@ function JSChart(divElement)
{ {
var item=option.OverlayIndex[i]; var item=option.OverlayIndex[i];
if (item.Windows>=chart.Frame.SubFrame.length) continue; if (item.Windows>=chart.Frame.SubFrame.length) continue;
var obj={ WindowIndex:item.Windows,IndexName: item.Index, ShowRightText:item.ShowRightText };
if (item.Args) obj.Args=item.Args; var itemString = JSON.stringify(item);
if (item.API) obj.API=item.API; var obj = JSON.parse(itemString);
if (item.Index) obj.IndexName=item.Index;
if (item.Windows>=0) obj.WindowIndex=item.Windows;
chart.CreateOverlayWindowsIndex(obj); chart.CreateOverlayWindowsIndex(obj);
} }
...@@ -3801,6 +3803,14 @@ function JSChartContainer(uielement) ...@@ -3801,6 +3803,14 @@ function JSChartContainer(uielement)
if (IFrameSplitOperator.IsBool(option.IsLockScreen)) this.ChartDrawOption.IsLockScreen=option.IsLockScreen; if (IFrameSplitOperator.IsBool(option.IsLockScreen)) this.ChartDrawOption.IsLockScreen=option.IsLockScreen;
if (IFrameSplitOperator.IsNumber(option.Zoom) && option.Zoom>=0) this.ChartDrawOption.Zoom=option.Zoom; if (IFrameSplitOperator.IsNumber(option.Zoom) && option.Zoom>=0) this.ChartDrawOption.Zoom=option.Zoom;
} }
//是否显示十字光标的十字线
this.EnableShowCorssCursorLine=function(bShow)
{
if (!this.ChartCorssCursor) return;
this.ChartCorssCursor.IsShowCorss=bShow;
}
} }
function GetDevicePixelRatio() function GetDevicePixelRatio()
...@@ -14292,58 +14302,72 @@ function ChartBand() ...@@ -14292,58 +14302,72 @@ function ChartBand()
var y2 = 0; var y2 = 0;
var firstlinePoints = []; var firstlinePoints = [];
var secondlinePoints = []; var secondlinePoints = [];
var lIndex = 0; for(var i=this.Data.DataOffset,j=0; i<this.Data.Data.length && j<xPointCount;++i, ++j, xOffset+=(dataWidth+distanceWidth))
for(var i=this.Data.DataOffset,j=0;i<this.Data.Data.length && j<xPointCount;++i,++j,xOffset+=(dataWidth+distanceWidth))
{
var value=this.Data.Data[i];
if (value==null || value.Value==null || value.Value2 == null) continue;
x=this.ChartFrame.GetXFromIndex(j);
y=this.ChartFrame.GetYFromData(value.Value);
y2 = this.ChartFrame.GetYFromData(value.Value2);
firstlinePoints[lIndex] = {x:x,y:y};
secondlinePoints[lIndex] = {x:x,y:y2};
lIndex++;
}
if (firstlinePoints.length > 1)
{ {
this.Canvas.save(); firstlinePoints = [];
this.Canvas.beginPath(); secondlinePoints = [];
for (var i = 0; i < firstlinePoints.length; ++i) for(;i<this.Data.Data.length && j<xPointCount;++i, ++j, xOffset+=(dataWidth+distanceWidth))
{
if (i == 0)
this.Canvas.moveTo(firstlinePoints[i].x, firstlinePoints[i].y);
else
this.Canvas.lineTo(firstlinePoints[i].x, firstlinePoints[i].y);
}
for (var j = secondlinePoints.length-1; j >= 0; --j)
{
this.Canvas.lineTo(secondlinePoints[j].x, secondlinePoints[j].y);
}
this.Canvas.closePath();
this.Canvas.clip();
this.Canvas.beginPath();
this.Canvas.moveTo(firstlinePoints[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < firstlinePoints.length; ++i)
{ {
this.Canvas.lineTo(firstlinePoints[i].x, firstlinePoints[i].y); var value=this.Data.Data[i];
if (value==null || value.Value==null || value.Value2 == null) break;
x=this.ChartFrame.GetXFromIndex(j);
y=this.ChartFrame.GetYFromData(value.Value);
y2 = this.ChartFrame.GetYFromData(value.Value2);
firstlinePoints.push({x:x,y:y});
secondlinePoints.push({x:x,y:y2});
} }
this.Canvas.lineTo(firstlinePoints[firstlinePoints.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath(); if (firstlinePoints.length>1 && secondlinePoints.length>1)
this.Canvas.fillStyle = this.FirstColor;
this.Canvas.fill();
this.Canvas.beginPath();
this.Canvas.moveTo(secondlinePoints[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < secondlinePoints.length; ++i)
{ {
this.Canvas.lineTo(secondlinePoints[i].x, secondlinePoints[i].y); this.DrawBand(firstlinePoints, secondlinePoints);
} }
this.Canvas.lineTo(secondlinePoints[secondlinePoints.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath();
this.Canvas.fillStyle = this.SecondColor;
this.Canvas.fill();
this.Canvas.restore();
} }
} }
this.DrawBand=function(aryFrist, arySecond)
{
this.Canvas.save();
this.Canvas.beginPath();
for(var i=0;i<aryFrist.length;++i)
{
if (i == 0)
this.Canvas.moveTo(aryFrist[i].x, aryFrist[i].y);
else
this.Canvas.lineTo(aryFrist[i].x, aryFrist[i].y);
}
for (var i = arySecond.length-1; i >= 0; --i)
{
this.Canvas.lineTo(arySecond[i].x, arySecond[i].y);
}
this.Canvas.closePath();
this.Canvas.clip();
this.Canvas.moveTo(aryFrist[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < aryFrist.length; ++i)
{
this.Canvas.lineTo(aryFrist[i].x, aryFrist[i].y);
}
this.Canvas.lineTo(aryFrist[aryFrist.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath();
this.Canvas.fillStyle = this.FirstColor;
this.Canvas.fill();
this.Canvas.beginPath();
this.Canvas.moveTo(arySecond[0].x, this.ChartBorder.GetBottom());
for (var i = 0; i < arySecond.length; ++i)
{
this.Canvas.lineTo(arySecond[i].x, arySecond[i].y);
}
this.Canvas.lineTo(arySecond[arySecond.length-1].x, this.ChartBorder.GetBottom());
this.Canvas.closePath();
this.Canvas.fillStyle = this.SecondColor;
this.Canvas.fill();
this.Canvas.restore();
}
this.GetMaxMin=function() this.GetMaxMin=function()
{ {
var xPointCount=this.ChartFrame.XPointCount; var xPointCount=this.ChartFrame.XPointCount;
...@@ -29333,6 +29357,11 @@ function KLineChartContainer(uielement) ...@@ -29333,6 +29357,11 @@ function KLineChartContainer(uielement)
{ {
apiItem=obj.API; apiItem=obj.API;
} }
else if (obj.Script) //动态执行脚本
{
indexInfo={ Script:obj.Script, ID:obj.indexName, Name:obj.indexName};
if (obj.Name) indexInfo.Name=obj.Name;
}
else else
{ {
let scriptData = new JSIndexScript(); let scriptData = new JSIndexScript();
...@@ -29376,13 +29405,7 @@ function KLineChartContainer(uielement) ...@@ -29376,13 +29405,7 @@ function KLineChartContainer(uielement)
} }
else if (indexInfo) else if (indexInfo)
{ {
let indexData = let indexData = indexInfo;
{
Name:indexInfo.Name, Script:indexInfo.Script, Args: indexInfo.Args, ID:indexName ,
//扩展属性 可以是空
KLineType:indexInfo.KLineType, YSpecificMaxMin:indexInfo.YSpecificMaxMin, YSplitScale:indexInfo.YSplitScale,
FloatPrecision:indexInfo.FloatPrecision, Condition:indexInfo.Condition,
};
if (obj.Args) indexData.Args=obj.Args; //外部可以设置参数 if (obj.Args) indexData.Args=obj.Args; //外部可以设置参数
var scriptIndex=new OverlayScriptIndex(indexData.Name,indexData.Script,indexData.Args,indexData); //脚本执行 var scriptIndex=new OverlayScriptIndex(indexData.Name,indexData.Script,indexData.Args,indexData); //脚本执行
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册