提交 7e904ba8 编写于 作者: HQChart's avatar HQChart

ver 7180

7179 脚本函数 DRAWRECTREL 迁移到小程序
7178 ChartRectangle::Draw() 修正变量未定义
7176 指标标题数据显示格式设置 迁移到小程序
上级 458ba3a3
......@@ -21,7 +21,7 @@
FloatPrecision: 小数位数 缺省=2
YSplitScale: Y固定刻度 [1,8,10]
YSpecificMaxMin: 固定Y轴最大最小值 { Max: 9, Min: 0, Count: 3 };
StringFormat: 1=带单位万/亿 1=原始格式
StringFormat: 1=带单位万/亿 2=原始格式
Condition: 限制条件 { Symbol:'Index'/'Stock'(只支持指数/股票),Period:[](支持的周期), }
*/
......
......@@ -11042,8 +11042,8 @@ function ChartRectangle()
top=this.ChartBorder.GetTopEx()+top;
right=this.ChartBorder.GetLeft()+right;
bottom=this.ChartBorder.GetTopEx()+bottom;
width=Math.abs(left-right);
height=Math.abs(top-bottom);
var width=Math.abs(left-right);
var height=Math.abs(top-bottom);
if (bFill) this.Canvas.fillRect(left, top,width, height);
this.Canvas.rect(ToFixedPoint(left), ToFixedPoint(top),ToFixedRect(width), ToFixedRect(height));
this.Canvas.stroke();
......@@ -21,7 +21,7 @@
FloatPrecision: 小数位数 缺省=2
YSplitScale: Y固定刻度 [1,8,10]
YSpecificMaxMin: 固定Y轴最大最小值 { Max: 9, Min: 0, Count: 3 };
StringFormat: 1=带单位万/亿 1=原始格式
StringFormat: 1=带单位万/亿 2=原始格式
Condition: 限制条件 { Symbol:'Index'/'Stock'(只支持指数/股票),Period:[](支持的周期), }
*/
......
......@@ -11042,8 +11042,8 @@ function ChartRectangle()
top=this.ChartBorder.GetTopEx()+top;
right=this.ChartBorder.GetLeft()+right;
bottom=this.ChartBorder.GetTopEx()+bottom;
width=Math.abs(left-right);
height=Math.abs(top-bottom);
var width=Math.abs(left-right);
var height=Math.abs(top-bottom);
if (bFill) this.Canvas.fillRect(left, top,width, height);
this.Canvas.rect(ToFixedPoint(left), ToFixedPoint(top),ToFixedRect(width), ToFixedRect(height));
this.Canvas.stroke();
......@@ -21,7 +21,7 @@
FloatPrecision: 小数位数 缺省=2
YSplitScale: Y固定刻度 [1,8,10]
YSpecificMaxMin: 固定Y轴最大最小值 { Max: 9, Min: 0, Count: 3 };
StringFormat: 1=带单位万/亿 1=原始格式
StringFormat: 1=带单位万/亿 2=原始格式
Condition: 限制条件 { Symbol:'Index'/'Stock'(只支持指数/股票),Period:[](支持的周期), }
*/
......
......@@ -11042,8 +11042,8 @@ function ChartRectangle()
top=this.ChartBorder.GetTopEx()+top;
right=this.ChartBorder.GetLeft()+right;
bottom=this.ChartBorder.GetTopEx()+bottom;
width=Math.abs(left-right);
height=Math.abs(top-bottom);
var width=Math.abs(left-right);
var height=Math.abs(top-bottom);
if (bFill) this.Canvas.fillRect(left, top,width, height);
this.Canvas.rect(ToFixedPoint(left), ToFixedPoint(top),ToFixedRect(width), ToFixedRect(height));
this.Canvas.stroke();
......@@ -740,6 +740,80 @@ function ChartStickLine()
}
}
//画矩形
function ChartRectangle()
{
this.newMethod = IChartPainting; //派生
this.newMethod();
delete this.newMethod;
this.Color = [];
this.Rect;
this.BorderColor = g_JSChartResource.FrameBorderPen;
this.Draw = function ()
{
if (!this.IsShow) return;
if (!this.Color || !this.Rect) return;
if (this.Color.length <= 0) return;
this.Canvas.strokeStyle = this.BorderColor;
var bFill = false;
if (this.Color.length == 2)
{
/* TODO 渐变下次做吧
if (this.ColorAngle==0)
{
var ptStart={ X:this.ChartBorder.GetLeft(), Y:this.ChartBorder.GetTopEx() };
var ptEnd={ X:this.ChartBorder.GetLeft(), Y:this.ChartBorder.GetBottomEx() };
}
else
{
var ptStart={ X:this.ChartBorder.GetLeft(), Y:this.ChartBorder.GetTopEx() };
var ptEnd={ X:this.ChartBorder.GetRight(), Y:this.ChartBorder.GetTopEx() };
}
let gradient = this.Canvas.createLinearGradient(ptStart.X,ptStart.Y, ptEnd.X,ptEnd.Y);
gradient.addColorStop(0, this.Color[0]);
gradient.addColorStop(1, this.Color[1]);
this.Canvas.fillStyle=gradient;
*/
this.Canvas.fillStyle = this.Color[0];
bFill = true;
}
else if (this.Color.length == 1)
{
if (this.Color[0])
{
this.Canvas.fillStyle = this.Color[0];
bFill = true;
}
}
else
{
return;
}
var chartWidth = this.ChartBorder.GetWidth();
var chartHeight = this.ChartBorder.GetHeightEx();
var left = this.Rect.Left / 1000 * chartWidth;
var top = this.Rect.Top / 1000 * chartHeight;
var right = this.Rect.Right / 1000 * chartWidth;
var bottom = this.Rect.Bottom / 1000 * chartHeight;
left = this.ChartBorder.GetLeft() + left
top = this.ChartBorder.GetTopEx() + top;
right = this.ChartBorder.GetLeft() + right;
bottom = this.ChartBorder.GetTopEx() + bottom;
var width = Math.abs(left - right);
var height = Math.abs(top - bottom);
if (bFill) this.Canvas.fillRect(left, top, width, height);
this.Canvas.rect(ToFixedPoint(left), ToFixedPoint(top), ToFixedRect(width), ToFixedRect(height));
this.Canvas.stroke();
}
}
//K线叠加
function ChartOverlayKLine()
{
......@@ -2124,6 +2198,7 @@ module.exports =
ChartStickLine: ChartStickLine,
ChartOverlayKLine: ChartOverlayKLine,
ChartMinuteInfo: ChartMinuteInfo,
ChartRectangle: ChartRectangle,
ChartPie: ChartPie,
ChartCircle: ChartCircle,
......@@ -2145,4 +2220,5 @@ module.exports =
JSCommonChartPaint_ChartChinaMap: ChartChinaMap,
JSCommonChartPaint_ChartRadar: ChartRadar,
JSCommonChartPaint_ChartMinuteInfo: ChartMinuteInfo,
JSCommonChartPaint_ChartRectangle: ChartRectangle,
};
\ No newline at end of file
......@@ -790,6 +790,7 @@ function DynamicMinuteTitlePainting()
var STRING_FORMAT_TYPE =
{
DEFAULT: 1, //默认 2位小数 单位自动转化 (万 亿)
ORIGINAL: 2, //原始数据
THOUSANDS: 21, //千分位分割
};
......@@ -822,11 +823,14 @@ function DynamicChartTitlePainting()
this.EraseRect;
this.EraseColor = g_JSChartResource.BGColor; //用来擦出的背景色
this.FormatValue = function (value, item) {
this.FormatValue = function (value, item)
{
if (item.StringFormat == STRING_FORMAT_TYPE.DEFAULT)
return IFrameSplitOperator.FormatValueString(value, item.FloatPrecision);
else if (item.StringFormat = STRING_FORMAT_TYPE.THOUSANDS)
return IFrameSplitOperator.FormatValueThousandsString(value, item.FloatPrecision);
else if (item.StringFormat == STRING_FORMAT_TYPE.ORIGINAL)
return value.toFixed(item.FloatPrecision).toString();
}
this.FormatMultiReport = function (data, format) {
......
......@@ -5341,6 +5341,31 @@ function JSDraw(errorHandler, symbolData)
return result;
}
// 相对位置上画矩形.
//用法: DRAWRECTREL(LEFT,TOP,RIGHT,BOTTOM,COLOR),以图形窗口(LEFT,TOP)为左上角,(RIGHT,BOTTOM)为右下角绘制矩形,坐标单位是窗口沿水平和垂直方向的1/1000,取值范围是0—999,超出范围则可能显示在图形窗口外,矩形中间填充颜色COLOR,COLOR为0表示不填充.
//例如: DRAWRECTREL(0,0,500,500,RGB(255,255,0))表示在图形最左上部1/4位置用黄色绘制矩形
this.DRAWRECTREL = function (left, top, right, bottom, color)
{
let drawData = { Rect: { Left: left, Top: top, Right: right, Bottom: bottom }, Color: color };
if (color == 0) drawData.Color = null;
let result = { DrawData: drawData, DrawType: 'DRAWRECTREL' };
return result;
}
this.RGB = function (r, g, b)
{
var rgb = `rgb(${r},${g},${b})`;
return rgb;
}
this.RGBA = function (r, g, b, a)
{
var rgba = `rgba(${r},${g},${b},${a})`;
return rgba;
}
}
......@@ -5388,7 +5413,7 @@ JSDraw.prototype.IsNumber = function (value)
JSDraw.prototype.IsDrawFunction=function(name)
{
let setFunctionName = new Set(["STICKLINE", "DRAWTEXT", 'SUPERDRAWTEXT','DRAWLINE', 'DRAWBAND', 'DRAWKLINE', 'DRAWKLINE_IF', 'PLOYLINE', 'POLYLINE', 'DRAWNUMBER','DRAWICON']);
let setFunctionName = new Set(["STICKLINE", "DRAWTEXT", 'SUPERDRAWTEXT', 'DRAWLINE', 'DRAWBAND', 'DRAWKLINE', 'DRAWKLINE_IF', 'PLOYLINE', 'POLYLINE', 'DRAWNUMBER', 'DRAWICON','DRAWRECTREL']);
if (setFunctionName.has(name)) return true;
return false;
......@@ -7807,6 +7832,13 @@ function JSExecute(ast,option)
node.Draw = this.Draw.DRAWNUMBER(args[0], args[1], args[2]);
node.Out = node.Draw.DrawData.Value;
break;
case 'RGB':
node.Out = this.Draw.RGB(args[0], args[1], args[2]);
break;
case 'DRAWRECTREL':
node.Draw = this.Draw.DRAWRECTREL(args[0], args[1], args[2], args[3], args[4]);
node.Out = [];
break;
case 'CODELIKE':
node.Out=this.SymbolData.CODELIKE(args[0]);
break;
......
......@@ -18,6 +18,7 @@
KLineType:K线设置 -1=主图不显示K线(只在主图有效) 0=在副图显示K线 1=在副图显示K线(收盘价线) 2=在副图显示K线(美国线)
InstructionType: 1=专家指示 2=五彩K线
FloatPrecision: 小数位数 缺省=2
StringFormat: 1=带单位万/亿 2=原始格式 缺省=1
YSplitScale: Y固定刻度 [1,8,10]
YSpecificMaxMin: 固定Y轴最大最小值 { Max: 9, Min: 0, Count: 3 };
*/
......@@ -129,7 +130,7 @@ JSIndexScript.prototype.MA=function()
{
let data=
{
Name:'MA', Description:'均线', IsMainIndex:true,
Name: 'MA', Description: '均线', IsMainIndex: true, StringFormat:2,
Args:[ { Name:'M1', Value:5}, { Name:'M2', Value:10 }, { Name:'M3', Value:20} ],
Script: //脚本
'MA1:MA(CLOSE,M1);\n\
......@@ -2902,9 +2903,7 @@ JSIndexScript.prototype.TEST = function ()
//'T1:INDEXC;'+
//'T2:=HYBLOCK;'
'B1:= WEEK = 1;'+
'S1:= WEEK = 5;'+
'DRAWLINE(B1, L, S1, H,0), COLORBLACK, LINETHICK4;'
'DRAWRECTREL(0,0,500,500,RGB(255,255,0)), COLORRED;'
};
return data;
......
......@@ -47,6 +47,7 @@ import {
JSCommonChartPaint_ChartStickLine as ChartStickLine,
JSCommonChartPaint_ChartOverlayKLine as ChartOverlayKLine,
JSCommonChartPaint_ChartMinuteInfo as ChartMinuteInfo,
JSCommonChartPaint_ChartRectangle as ChartRectangle,
JSCommonChartPaint_ChartPie as ChartPie,
JSCommonChartPaint_ChartCircle as ChartCircle,
JSCommonChartPaint_ChartChinaMap as ChartChinaMap,
......@@ -310,7 +311,11 @@ function JSChart(element)
if (item.Lock) indexInfo.Lock = item.Lock;
indexInfo.ID = item.Index;
chart.WindowIndex[i] = new ScriptIndex(indexInfo.Name, indexInfo.Script, indexInfo.Args, indexInfo); //脚本执行
var args = indexInfo.Args;
if (item.Args) args = item.Args;
chart.WindowIndex[i] = new ScriptIndex(indexInfo.Name, indexInfo.Script, args, indexInfo); //脚本执行
if (item.StringFormat > 0) chart.WindowIndex[i].StringFormat = item.StringFormat;
if (item.FloatPrecision >= 0) chart.WindowIndex[i].FloatPrecision = item.FloatPrecision;
}
}
......@@ -454,7 +459,8 @@ function JSChart(element)
if (item.StringFormat) chart.Frame.SubFrame[i].Frame.YSplitOperator.StringFormat = item.StringFormat;
if (item.XMessageAlign == 'bottom') chart.Frame.SubFrame[i].Frame.XMessageAlign = item.XMessageAlign;
if (item.IsShowLeftText === false || item.IsShowLeftText===true ) chart.Frame.SubFrame[i].Frame.IsShowYText[0] = item.IsShowLeftText; //显示左边刻度
if (item.IsShowRightText === false || item.IsShowRightText===true) chart.Frame.SubFrame[i].Frame.IsShowYText[1] = item.IsShowRightText; //显示右边刻度
if (item.IsShowRightText === false || item.IsShowRightText===true) chart.Frame.SubFrame[i].Frame.IsShowYText[1] = item.IsShowRightText; //显示右边刻度
if (item.Height > 0) chart.Frame.SubFrame[i].Height = item.Height;
}
}
......@@ -508,9 +514,12 @@ function JSChart(element)
{
let indexInfo = scriptData.Get(item.Index);
if (!indexInfo) continue;
var args = indexInfo.Args;
if (item.Args) args = item.Args;
if (item.Lock) indexInfo.Lock = item.Lock;
chart.WindowIndex[2 + parseInt(i)] = new ScriptIndex(indexInfo.Name, indexInfo.Script, indexInfo.Args, indexInfo); //脚本执行
chart.WindowIndex[2 + parseInt(i)] = new ScriptIndex(indexInfo.Name, indexInfo.Script, args, indexInfo); //脚本执行
if (item.StringFormat > 0) chart.WindowIndex[2 + parseInt(i)].StringFormat = item.StringFormat;
if (item.FloatPrecision >= 0) chart.WindowIndex[2 + parseInt(i)].FloatPrecision = item.FloatPrecision;
}
}
......@@ -734,11 +743,12 @@ function JSChart(element)
if (this.JSChartContainer) this.JSChartContainer.ChangeSymbol(symbol);
}
//K线切换指标
this.ChangeIndex = function (windowIndex, indexName) {
if (this.JSChartContainer && typeof (this.JSChartContainer.ChangeIndex) == 'function')
this.JSChartContainer.ChangeIndex(windowIndex, indexName);
}
//K线切换指标
this.ChangeIndex = function (windowIndex, indexName, option)
{
if (this.JSChartContainer && typeof (this.JSChartContainer.ChangeIndex) == 'function')
this.JSChartContainer.ChangeIndex(windowIndex, indexName, option);
}
//切换K线指标
this.ChangeScriptIndex = function (windowIndex, indexData) {
......@@ -8130,7 +8140,7 @@ function KLineChartContainer(uielement)
//切换指标 指定切换窗口指标
this.ChangeIndex = function (windowIndex, indexName)
this.ChangeIndex = function (windowIndex, indexName, option)
{
var indexItem = JSIndexMap.Get(indexName);
if (!indexItem)
......@@ -8152,8 +8162,16 @@ function KLineChartContainer(uielement)
Name: indexInfo.Name, Script: indexInfo.Script, Args: indexInfo.Args, ID: indexName,
//扩展属性 可以是空
KLineType: indexInfo.KLineType, YSpecificMaxMin: indexInfo.YSpecificMaxMin, YSplitScale: indexInfo.YSplitScale,
FloatPrecision: indexInfo.FloatPrecision,
FloatPrecision: indexInfo.FloatPrecision, StringFormat: indexInfo.StringFormat
};
if (option)
{
if (option.FloatPrecision >= 0) indexData.FloatPrecision = option.FloatPrecision;
if (option.StringFormat > 0) indexData.StringFormat = option.StringFormat;
if (option.Args) indexData.Args = option.Args;
}
return this.ChangeScriptIndex(windowIndex, indexData);
}
......@@ -9388,7 +9406,7 @@ function MinuteChartContainer(uielement)
this.Draw();
}
this.ChangeIndex = function (windowIndex, indexName)
this.ChangeIndex = function (windowIndex, indexName, option)
{
if (this.Frame.SubFrame.length < 3) return;
......@@ -9404,9 +9422,16 @@ function MinuteChartContainer(uielement)
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
FloatPrecision: indexInfo.FloatPrecision, Condition: indexInfo.Condition, StringFormat: indexInfo.StringFormat
};
if (option)
{
if (option.FloatPrecision >= 0) indexData.FloatPrecision = option.FloatPrecision;
if (option.StringFormat > 0) indexData.StringFormat = option.StringFormat;
if (option.Args) indexData.Args = option.Args;
}
return this.ChangeScriptIndex(windowIndex, indexData);
}
......@@ -11510,6 +11535,7 @@ function ScriptIndex(name, script, args, option)
this.OutVar = [];
this.ID; //指标ID
this.FloatPrecision = 2; //小数位数
this.StringFormat;
this.KLineType = null; //K线显示类型
this.InstructionType; //五彩K线, 交易指标
this.YSpecificMaxMin = null; //最大最小值
......@@ -11528,6 +11554,7 @@ function ScriptIndex(name, script, args, option)
if (option)
{
if (option.FloatPrecision >= 0) this.FloatPrecision = option.FloatPrecision;
if (option.StringFormat > 0) this.StringFormat = option.StringFormat;
if (option.ID) this.ID = option.ID;
if (option.KLineType) this.KLineType = option.KLineType;
if (option.InstructionType) this.InstructionType = option.InstructionType;
......@@ -11930,6 +11957,20 @@ function ScriptIndex(name, script, args, option)
hqChart.ChartPaint.push(chartText);
}
this.CreateRectangle = function (hqChart, windowIndex, varItem, i)
{
let chart = new ChartRectangle();
chart.Canvas = hqChart.Canvas;
chart.Name = varItem.Name;
chart.ChartBorder = hqChart.Frame.SubFrame[windowIndex].Frame.ChartBorder;
chart.ChartFrame = hqChart.Frame.SubFrame[windowIndex].Frame;
chart.Color = [varItem.Draw.DrawData.Color];
chart.Rect = varItem.Draw.DrawData.Rect;
if (varItem.Color) chart.BorderColor = this.GetColor(varItem.Color);
hqChart.ChartPaint.push(chart);
}
//创建K线背景
this.CreateSelfKLine = function (hqChart, windowIndex, hisData)
{
......@@ -12041,6 +12082,9 @@ function ScriptIndex(name, script, args, option)
case 'DRAWICON':
this.CreateIcon(hqChart, windowIndex, item, i);
break;
case 'DRAWRECTREL':
this.CreateRectangle(hqChart, windowIndex, item, i);
break;
}
}
else if (item.Type == 2)
......@@ -12063,6 +12107,13 @@ function ScriptIndex(name, script, args, option)
{
this.CreateVolStick(hqChart, windowIndex, item, i, hisData);
}
var titlePaint = hqChart.TitlePaint[windowIndex + 1];
if (titlePaint && titlePaint.Data && i < titlePaint.Data.length) //设置标题数值 小数位数和格式
{
if (this.StringFormat > 0) titlePaint.Data[i].StringFormat = this.StringFormat;
if (this.FloatPrecision >= 0) titlePaint.Data[i].FloatPrecision = this.FloatPrecision;
}
}
let titleIndex = windowIndex + 1;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册