hqchart 1.1.12693 → 1.1.12708
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +15 -47
- package/src/jscommon/readmo.txt +2 -2
- package/src/jscommon/umychart.resource/js/codemirror/javascript.js +1 -1
- package/.babelrc +0 -6
- package/.vscode/settings.json +0 -4
- package/Makefile +0 -9
- package/README.md +0 -452
- package/index.js +0 -17
- package/postcss.config.js +0 -5
- package/src/index.html +0 -18
- package/src/jscommon/backup/announcement.png +0 -0
- package/src/jscommon/backup/announcement2.png +0 -0
- package/src/jscommon/backup/blocktrading.png +0 -0
- package/src/jscommon/backup/investor.png +0 -0
- package/src/jscommon/backup/pforecast.png +0 -0
- package/src/jscommon/backup/research.png +0 -0
- package/src/jscommon/backup/tradedetail.png +0 -0
- package/src/jscommon/backup/umychart - backup.js +0 -17631
- package/src/jscommon/backup/umychart.macro.js +0 -4
- package/src/jscommon/backup/umychart.macro.vue.js +0 -3
- package/src/jscommon/commonindextree.json +0 -92
- package/src/jscommon/index.html +0 -13
- package/src/jscommon/jschinamapdata.js +0 -3
- package/src/jscommon/phoneHorizontal/hengping.css +0 -283
- package/src/jscommon/phoneHorizontal/phone.html +0 -448
- package/src/jscommon/phoneHorizontal/rem.js +0 -28
- package/src/jscommon/umychart.NetworkFilterTest.js +0 -48803
- package/src/jscommon/umychart.aliYunnetwork.js +0 -47
- package/src/jscommon/umychart.cninfo.components/readme.txt +0 -1
- package/src/jscommon/umychart.complier.js +0 -25293
- package/src/jscommon/umychart.complier.node/umychart.complier.controller.js +0 -559
- package/src/jscommon/umychart.complier.node/umychart.complier.node.js +0 -7043
- package/src/jscommon/umychart.complier.node/umychart.data.node.js +0 -816
- package/src/jscommon/umychart.console.js +0 -12
- package/src/jscommon/umychart.deal.js +0 -1452
- package/src/jscommon/umychart.dragdiv.js +0 -48
- package/src/jscommon/umychart.index.data.js +0 -4132
- package/src/jscommon/umychart.js +0 -90542
- package/src/jscommon/umychart.keyboard.js +0 -1659
- package/src/jscommon/umychart.listctrl.js +0 -690
- package/src/jscommon/umychart.mind.js +0 -2203
- package/src/jscommon/umychart.network.js +0 -44
- package/src/jscommon/umychart.news.js +0 -823
- package/src/jscommon/umychart.node.build/buildall.bat +0 -1
- package/src/jscommon/umychart.node.build/umychart.node.bat +0 -1
- package/src/jscommon/umychart.node.build/umychart.node.export.js +0 -40
- package/src/jscommon/umychart.regressiontest.js +0 -400
- package/src/jscommon/umychart.report.js +0 -5803
- package/src/jscommon/umychart.scrollbar.js +0 -1345
- package/src/jscommon/umychart.stock.js +0 -4218
- package/src/jscommon/umychart.style.js +0 -625
- package/src/jscommon/umychart.testdata.js +0 -150
- package/src/jscommon/umychart.uniapp.build/buildall.bat +0 -1
- package/src/jscommon/umychart.uniapp.build/umychart.bat +0 -1
- package/src/jscommon/umychart.uniapp.build/umychart.export.js +0 -70
- package/src/jscommon/umychart.user.js +0 -137
- package/src/jscommon/umychart.version.js +0 -30
- package/src/jscommon/umychart.vue/umychart.aliYunnetwork.vue.js +0 -56
- package/src/jscommon/umychart.vue.build/buildall.bat +0 -4
- package/src/jscommon/umychart.vue.build/copy_codemirror.bat +0 -2
- package/src/jscommon/umychart.vue.build/umychart.aliYunnetwork.vue.export.js +0 -9
- package/src/jscommon/umychart.vue.build/umychart.dragdiv.bat +0 -1
- package/src/jscommon/umychart.vue.build/umychart.dragdiv.export.js +0 -6
- package/src/jscommon/umychart.vue.build/umychart.index.data.bat +0 -1
- package/src/jscommon/umychart.vue.build/umychart.index.data.export.js +0 -4
- package/src/jscommon/umychart.vue.build/umychart.listctrl.vue.export.js +0 -15
- package/src/jscommon/umychart.vue.build/umychart.regressiontest.vue.export.js +0 -7
- package/src/jscommon/umychart.vue.build/umychart.regressiontest.wechat.export.js +0 -12
- package/src/jscommon/umychart.vue.build/umychart.stock.bat +0 -1
- package/src/jscommon/umychart.vue.build/umychart.stock.vue.export.js +0 -16
- package/src/jscommon/umychart.vue.build/umychart.testdata.bat +0 -3
- package/src/jscommon/umychart.vue.build/umychart.testdata.vue.export.js +0 -7
- package/src/jscommon/umychart.vue.build/umychart.vue.bat +0 -8
- package/src/jscommon/umychart.vue.build/umychart.vue.export.js +0 -112
- package/src/jscommon/umychart.vue.components/empyt.vue +0 -51
- package/src/jscommon/umychart.vue.components/historydayline.vue +0 -240
- package/src/jscommon/umychart.vue.components/jsloader.adddialog.vue +0 -315
- package/src/jscommon/umychart.vue.components/jsloader.vue +0 -93
- package/src/jscommon/umychart.vue.components/jsvuecontainer.vue +0 -160
- package/src/jscommon/umychart.vue.components/jsvuecontainer2.0.vue +0 -391
- package/src/jscommon/umychart.vue.components/login.vue +0 -178
- package/src/jscommon/umychart.vue.components/queryContent.vue +0 -750
- package/src/jscommon/umychart.vue.components/readme.txt +0 -8
- package/src/jscommon/umychart.vue.components/searchsymbol.vue +0 -299
- package/src/jscommon/umychart.vue.components/simulatetrade.vue +0 -1471
- package/src/jscommon/umychart.vue.components/stockchart.vue +0 -343
- package/src/jscommon/umychart.vue.components/stockchartV2.vue +0 -195
- package/src/jscommon/umychart.vue.components/stockdeal.vue +0 -358
- package/src/jscommon/umychart.vue.components/stockdealcount.vue +0 -262
- package/src/jscommon/umychart.vue.components/stockdeallastest.vue +0 -316
- package/src/jscommon/umychart.vue.components/stockdrawtool.vue +0 -343
- package/src/jscommon/umychart.vue.components/stockfull.vue +0 -355
- package/src/jscommon/umychart.vue.components/stockinfo.demo.vue +0 -153
- package/src/jscommon/umychart.vue.components/stockinfo.vue +0 -685
- package/src/jscommon/umychart.vue.components/stockkline.demo.vue +0 -1904
- package/src/jscommon/umychart.vue.components/stockmultiorder.vue +0 -174
- package/src/jscommon/umychart.vue.components/stockmultiperiod.vue +0 -222
- package/src/jscommon/umychart.vue.components/stockorder.vue +0 -320
- package/src/jscommon/umychart.vue.components/stocktradeinfo.demo.vue +0 -250
- package/src/jscommon/umychart.vue.components/stocktradeinfo.vue +0 -1907
- package/src/jscommon/umychart.vue.components/test.vue +0 -0
- package/src/jscommon/umychart.wechat/getDate.wechat.js +0 -91
- package/src/jscommon/umychart.wechat/lighter.news.wechat.js +0 -262
- package/src/jscommon/umychart.wechat/readme.txt +0 -3
- package/src/jscommon/umychart.wechat/umychart.analyze.wechat.js +0 -551
- package/src/jscommon/umychart.wechat/umychart.apidraw.wechat.js +0 -126
- package/src/jscommon/umychart.wechat/umychart.bigV.wechat.js +0 -2510
- package/src/jscommon/umychart.wechat/umychart.chartframe.wechat.js +0 -2942
- package/src/jscommon/umychart.wechat/umychart.chartpaint.wechat.js +0 -9752
- package/src/jscommon/umychart.wechat/umychart.charttitle.wechat.js +0 -2023
- package/src/jscommon/umychart.wechat/umychart.complier.wechat.js +0 -14726
- package/src/jscommon/umychart.wechat/umychart.console.wechat.js +0 -8
- package/src/jscommon/umychart.wechat/umychart.coordinatedata.wechat.js +0 -3654
- package/src/jscommon/umychart.wechat/umychart.data.wechat.js +0 -2243
- package/src/jscommon/umychart.wechat/umychart.element.wechart.js +0 -132
- package/src/jscommon/umychart.wechat/umychart.explainer.wechat.js +0 -1077
- package/src/jscommon/umychart.wechat/umychart.extendchart.wechat.js +0 -1140
- package/src/jscommon/umychart.wechat/umychart.framesplit.wechat.js +0 -2247
- package/src/jscommon/umychart.wechat/umychart.hqIndexformula.wechat.js +0 -941
- package/src/jscommon/umychart.wechat/umychart.index.data.wechat.js +0 -3628
- package/src/jscommon/umychart.wechat/umychart.index.wechat.js +0 -4074
- package/src/jscommon/umychart.wechat/umychart.klineinfo.wechat.js +0 -836
- package/src/jscommon/umychart.wechat/umychart.markethot.js +0 -50
- package/src/jscommon/umychart.wechat/umychart.network.wechart.js +0 -62
- package/src/jscommon/umychart.wechat/umychart.news.wechat.js +0 -3568
- package/src/jscommon/umychart.wechat/umychart.regressiontest.wechat.js +0 -412
- package/src/jscommon/umychart.wechat/umychart.report.wechat.js +0 -3983
- package/src/jscommon/umychart.wechat/umychart.resource.wechat.js +0 -919
- package/src/jscommon/umychart.wechat/umychart.shareimage.wechat.js +0 -681
- package/src/jscommon/umychart.wechat/umychart.simulatetrade.wechat.js +0 -238
- package/src/jscommon/umychart.wechat/umychart.stock.wechat.js +0 -4035
- package/src/jscommon/umychart.wechat/umychart.style.wechat.js +0 -419
- package/src/jscommon/umychart.wechat/umychart.uniapp.canvas.helper.js +0 -99
- package/src/jscommon/umychart.wechat/umychart.user.wechat.js +0 -588
- package/src/jscommon/umychart.wechat/umychart.userlog.wechat.js +0 -240
- package/src/jscommon/umychart.wechat/umychart.vedio.wechat.js +0 -112
- package/src/jscommon/umychart.wechat/umychart.version.wechat.js +0 -36
- package/src/jscommon/umychart.wechat/umychart.wechat.3.0.js +0 -12055
- package/src/jscommon/umychart.wechat/umychart.wechat.js +0 -15460
- package/src/jscommon/umychart.worker.js +0 -114
- package/src/jscommon/umychart.ws.stock.js +0 -110
- package/src/jscommon/umychart_python/.vscode/launch.json +0 -15
- package/src/jscommon/umychart_python/__init__.py +0 -4
- package/src/jscommon/umychart_python/build.cmd +0 -2
- package/src/jscommon/umychart_python/setup.py +0 -25
- package/src/jscommon/umychart_python/umychart_cache_testcase.py +0 -165
- package/src/jscommon/umychart_python/umychart_complier_data.py +0 -781
- package/src/jscommon/umychart_python/umychart_complier_help.py +0 -175
- package/src/jscommon/umychart_python/umychart_complier_job.py +0 -193
- package/src/jscommon/umychart_python/umychart_complier_jsalgorithm.py +0 -4144
- package/src/jscommon/umychart_python/umychart_complier_jscomplier.py +0 -177
- package/src/jscommon/umychart_python/umychart_complier_jsexecute.py +0 -517
- package/src/jscommon/umychart_python/umychart_complier_jsparser.py +0 -864
- package/src/jscommon/umychart_python/umychart_complier_jssymboldata.py +0 -1238
- package/src/jscommon/umychart_python/umychart_complier_jssymboldata_cache.py +0 -146
- package/src/jscommon/umychart_python/umychart_complier_jssymboldata_json.py +0 -106
- package/src/jscommon/umychart_python/umychart_complier_pandas_help.py +0 -80
- package/src/jscommon/umychart_python/umychart_complier_scanner.py +0 -554
- package/src/jscommon/umychart_python/umychart_complier_testcase.py +0 -362
- package/src/jscommon/umychart_python/umychart_complier_util.py +0 -30
- package/src/jscommon/umychart_python/umychart_webtemplate.py +0 -131
- package/src/jscommon/umychart_python/updatehqchartweb.bat +0 -5
- package/src/jscommon/vendor.js +0 -2
- package/src/pages/block.list.demo.page/App.vue +0 -117
- package/src/pages/block.list.demo.page/index.js +0 -12
- package/src/pages/brushTool.demo.page/App.vue +0 -19
- package/src/pages/brushTool.demo.page/index.js +0 -12
- package/src/pages/container.demo.page/App.vue +0 -118
- package/src/pages/container.demo.page/index.js +0 -18
- package/src/pages/dataZoom.demo.page/App.vue +0 -265
- package/src/pages/dataZoom.demo.page/components/dataZoom.vue +0 -303
- package/src/pages/dataZoom.demo.page/index.js +0 -12
- package/src/pages/historydayline.demo.page/App.vue +0 -57
- package/src/pages/historydayline.demo.page/index.js +0 -12
- package/src/pages/hq.demo.page/App.vue +0 -163
- package/src/pages/hq.demo.page/index.js +0 -12
- package/src/pages/hqchart.black/App.vue +0 -90
- package/src/pages/hqchart.black/components/searchsymbol.vue +0 -299
- package/src/pages/hqchart.black/components/stockdrawtool.vue +0 -300
- package/src/pages/hqchart.black/components/stockfull.vue +0 -313
- package/src/pages/hqchart.black/components/stockinfo.vue +0 -428
- package/src/pages/hqchart.black/components/stockkline.demo.vue +0 -1652
- package/src/pages/hqchart.black/components/stocktradeinfo.vue +0 -1337
- package/src/pages/hqchart.black/index.js +0 -30
- package/src/pages/hqchart.black/router/candlestickChart.vue +0 -108
- package/src/pages/hqchart.black/router/pricePointsTable.vue +0 -294
- package/src/pages/hqchart.black/router/stockDeallas.vue +0 -417
- package/src/pages/hqchart.black/router/timeShareChart.vue +0 -108
- package/src/pages/hqchart.page/App.vue +0 -101
- package/src/pages/hqchart.page/index.js +0 -18
- package/src/pages/index/App.vue +0 -1408
- package/src/pages/index/index.js +0 -7
- package/src/pages/indexHq/App.vue +0 -110
- package/src/pages/indexHq/index.js +0 -18
- package/src/pages/login.demo.page/App.vue +0 -22
- package/src/pages/login.demo.page/index.js +0 -12
- package/src/pages/queryContent.demo.page/App.vue +0 -29
- package/src/pages/queryContent.demo.page/index.js +0 -18
- package/src/pages/ranking.black/App.vue +0 -199
- package/src/pages/ranking.black/index.js +0 -18
- package/src/pages/search.demo.page/App.vue +0 -28
- package/src/pages/search.demo.page/index.js +0 -12
- package/src/pages/simulatetrade.demo.page/app.vue +0 -121
- package/src/pages/simulatetrade.demo.page/index.js +0 -17
- package/src/pages/stockdeal.demo.page/App.vue +0 -63
- package/src/pages/stockdeal.demo.page/index.js +0 -19
- package/src/pages/stockdealcount.demo.page/App.vue +0 -37
- package/src/pages/stockdealcount.demo.page/index.js +0 -12
- package/src/pages/stockdeallastest.demo.page/App.vue +0 -74
- package/src/pages/stockdeallastest.demo.page/index.js +0 -18
- package/src/pages/stockinfo.demo.page/App.vue +0 -92
- package/src/pages/stockinfo.demo.page/index.html +0 -13
- package/src/pages/stockinfo.demo.page/index.js +0 -19
- package/src/pages/stockkline.demo.page/App.vue +0 -55
- package/src/pages/stockkline.demo.page/index.js +0 -18
- package/src/pages/stockmultiorder.demo.page/App.vue +0 -149
- package/src/pages/stockmultiorder.demo.page/index.js +0 -18
- package/src/pages/stockmultiperiod.demo.page/App.vue +0 -87
- package/src/pages/stockmultiperiod.demo.page/index.js +0 -18
- package/src/pages/stockorder.demo.page/App.vue +0 -69
- package/src/pages/stockorder.demo.page/index.js +0 -18
- package/src/pages/test/App.vue +0 -22
- package/src/pages/test/index.js +0 -7
- package/src/pages/tradeinfopage/app.vue +0 -40
- package/src/pages/tradeinfopage/index.js +0 -7
- package/src/pages/tradeinfopage/tradeinfo.html +0 -12
- package/src/utils/urlObj.js +0 -81
- package/src/vendor.js +0 -2
- package/webpack.config.js +0 -104
|
@@ -1,2942 +0,0 @@
|
|
|
1
|
-
/*
|
|
2
|
-
copyright (c) 2018 jones
|
|
3
|
-
|
|
4
|
-
http://www.apache.org/licenses/LICENSE-2.0
|
|
5
|
-
|
|
6
|
-
开源项目 https://github.com/jones2000/HQChart
|
|
7
|
-
|
|
8
|
-
jones_2000@163.com
|
|
9
|
-
|
|
10
|
-
指标窗口
|
|
11
|
-
*/
|
|
12
|
-
|
|
13
|
-
//日志
|
|
14
|
-
import { JSConsole } from "./umychart.console.wechat.js"
|
|
15
|
-
|
|
16
|
-
import
|
|
17
|
-
{
|
|
18
|
-
g_JSChartResource,
|
|
19
|
-
JSCHART_LANGUAGE_ID,
|
|
20
|
-
g_JSChartLocalization,
|
|
21
|
-
} from './umychart.resource.wechat.js'
|
|
22
|
-
|
|
23
|
-
import
|
|
24
|
-
{
|
|
25
|
-
Guid,
|
|
26
|
-
JSCHART_EVENT_ID,
|
|
27
|
-
ToFixedPoint,
|
|
28
|
-
ToFixedRect,
|
|
29
|
-
} from "./umychart.data.wechat.js";
|
|
30
|
-
|
|
31
|
-
import
|
|
32
|
-
{
|
|
33
|
-
CoordinateInfo,
|
|
34
|
-
IFrameSplitOperator,
|
|
35
|
-
FrameSplitKLinePriceY,
|
|
36
|
-
FrameSplitY,
|
|
37
|
-
FrameSplitKLineX,
|
|
38
|
-
FrameSplitMinutePriceY,
|
|
39
|
-
FrameSplitMinuteX,
|
|
40
|
-
FrameSplitXData,
|
|
41
|
-
SplitData,
|
|
42
|
-
PriceSplitData,
|
|
43
|
-
FrameSplitXDepth,
|
|
44
|
-
|
|
45
|
-
IChangeStringFormat,
|
|
46
|
-
HQPriceStringFormat,
|
|
47
|
-
HQDateStringFormat,
|
|
48
|
-
HQMinuteTimeStringFormat,
|
|
49
|
-
g_DivTooltipDataForamt,
|
|
50
|
-
} from './umychart.framesplit.wechat.js'
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
function IChartFramePainting()
|
|
54
|
-
{
|
|
55
|
-
this.HorizontalInfo = new Array(); //Y轴
|
|
56
|
-
this.VerticalInfo = new Array(); //X轴
|
|
57
|
-
this.ClassName='IChartFramePainting';
|
|
58
|
-
this.Canvas; //画布
|
|
59
|
-
|
|
60
|
-
this.Identify; //窗口标识
|
|
61
|
-
|
|
62
|
-
this.ChartBorder;
|
|
63
|
-
this.PenBorder = g_JSChartResource.FrameBorderPen; //边框颜色
|
|
64
|
-
this.TitleBGColor = g_JSChartResource.FrameTitleBGColor; //标题背景色
|
|
65
|
-
this.IsShow = true; //是否显示
|
|
66
|
-
this.SizeChange = true; //大小是否改变
|
|
67
|
-
this.XYSplit = true; //XY轴坐标信息改变
|
|
68
|
-
this.XSplit=true; //X轴坐标信息改变
|
|
69
|
-
|
|
70
|
-
this.HorizontalMax; //Y轴最大值
|
|
71
|
-
this.HorizontalMin; //Y轴最小值
|
|
72
|
-
this.XPointCount = 10; //X轴数据个数
|
|
73
|
-
this.YMaxMin={ Max:null, Min:null }; //Y轴原始的最大值 最小值
|
|
74
|
-
|
|
75
|
-
this.YSplitOperator; //Y轴分割
|
|
76
|
-
this.XSplitOperator; //X轴分割
|
|
77
|
-
this.Data; //主数据
|
|
78
|
-
|
|
79
|
-
this.YSpecificMaxMin = null; //指定Y轴最大最小值
|
|
80
|
-
this.YSplitScale=null; //固定分割刻度数组 [2,5,8]
|
|
81
|
-
|
|
82
|
-
this.IsShowBorder = true; //是否显示边框
|
|
83
|
-
this.IsShowIndexName = true; //是否显示指标名字
|
|
84
|
-
this.IndexParamSpace = 2; //指标参数数值显示间距
|
|
85
|
-
this.IndexTitleSpace=0; //指标标题到参数之间的间距
|
|
86
|
-
|
|
87
|
-
//上锁信息
|
|
88
|
-
this.IsLocked = false; //是否上锁
|
|
89
|
-
this.LockPaint = null;
|
|
90
|
-
|
|
91
|
-
this.BorderLine=null; //1=上 2=下 4=左 8=右
|
|
92
|
-
this.IsMinSize=false; //窗口是否最小化
|
|
93
|
-
|
|
94
|
-
this.LogoTextColor=g_JSChartResource.FrameLogo.TextColor;
|
|
95
|
-
this.LogoTextFont=g_JSChartResource.FrameLogo.Font;
|
|
96
|
-
|
|
97
|
-
this.Draw = function ()
|
|
98
|
-
{
|
|
99
|
-
this.DrawFrame();
|
|
100
|
-
this.DrawBorder();
|
|
101
|
-
|
|
102
|
-
this.SizeChange = false;
|
|
103
|
-
this.XYSplit = false;
|
|
104
|
-
this.XSplit=false;
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
this.DrawFrame = function () { }
|
|
108
|
-
|
|
109
|
-
this.GetBorder=function()
|
|
110
|
-
{
|
|
111
|
-
if (this.IsHScreen) return this.ChartBorder.GetHScreenBorder();
|
|
112
|
-
else return this.ChartBorder.GetBorder();
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
this.ClearCoordinateText=function(option)
|
|
116
|
-
{
|
|
117
|
-
if (IFrameSplitOperator.IsNonEmptyArray(this.HorizontalInfo))
|
|
118
|
-
{
|
|
119
|
-
for(var i=0;i<this.HorizontalInfo.length;++i)
|
|
120
|
-
{
|
|
121
|
-
var item=this.HorizontalInfo[i];
|
|
122
|
-
item.Message[0]=item.Message[1]=null;
|
|
123
|
-
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (IFrameSplitOperator.IsNonEmptyArray(this.VerticalInfo))
|
|
127
|
-
{
|
|
128
|
-
for(var i=0;i<this.VerticalInfo.length;++i)
|
|
129
|
-
{
|
|
130
|
-
var item=this.VerticalInfo[i];
|
|
131
|
-
item.Message[0]=item.Message[1]=null;
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
//画边框
|
|
137
|
-
this.DrawBorder = function ()
|
|
138
|
-
{
|
|
139
|
-
if (!this.IsShowBorder) return;
|
|
140
|
-
if (this.IsMinSize) return;
|
|
141
|
-
|
|
142
|
-
var left = ToFixedPoint(this.ChartBorder.GetLeft());
|
|
143
|
-
var top = ToFixedPoint(this.ChartBorder.GetTop());
|
|
144
|
-
var right = ToFixedPoint(this.ChartBorder.GetRight());
|
|
145
|
-
var bottom = ToFixedPoint(this.ChartBorder.GetBottom());
|
|
146
|
-
var width = right - left;
|
|
147
|
-
var height = bottom - top;
|
|
148
|
-
if (this.BorderLine==null)
|
|
149
|
-
{
|
|
150
|
-
this.Canvas.strokeStyle = this.PenBorder;
|
|
151
|
-
this.Canvas.strokeRect(left, top, width, height);
|
|
152
|
-
}
|
|
153
|
-
else if (IFrameSplitOperator.IsNumber(this.BorderLine))
|
|
154
|
-
{
|
|
155
|
-
this.Canvas.strokeStyle=this.PenBorder;
|
|
156
|
-
this.Canvas.beginPath();
|
|
157
|
-
|
|
158
|
-
if ((this.BorderLine&1)>0) //上
|
|
159
|
-
{
|
|
160
|
-
this.Canvas.moveTo(left,top);
|
|
161
|
-
this.Canvas.lineTo(right,top);
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
if ((this.BorderLine&2)>0) //下
|
|
165
|
-
{
|
|
166
|
-
this.Canvas.moveTo(left,bottom);
|
|
167
|
-
this.Canvas.lineTo(right,bottom);
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
if ((this.BorderLine&4)>0) //左
|
|
171
|
-
{
|
|
172
|
-
this.Canvas.moveTo(left,top);
|
|
173
|
-
this.Canvas.lineTo(left,bottom);
|
|
174
|
-
}
|
|
175
|
-
|
|
176
|
-
if ((this.BorderLine&8)>0) //右
|
|
177
|
-
{
|
|
178
|
-
this.Canvas.moveTo(right,top);
|
|
179
|
-
this.Canvas.lineTo(right,bottom);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
this.Canvas.stroke();
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
//左右刻度文字宽度
|
|
187
|
-
this.GetScaleTextWidth=function() { }
|
|
188
|
-
|
|
189
|
-
//画标题背景色
|
|
190
|
-
this.DrawTitleBG = function ()
|
|
191
|
-
{
|
|
192
|
-
/* 指标信息背景色不画,画了感觉框架变小了
|
|
193
|
-
if (this.ChartBorder.TitleHeight<=0) return;
|
|
194
|
-
|
|
195
|
-
var left=ToFixedPoint(this.ChartBorder.GetLeft());
|
|
196
|
-
var top=ToFixedPoint(this.ChartBorder.GetTop());
|
|
197
|
-
var right=ToFixedPoint(this.ChartBorder.GetRight());
|
|
198
|
-
var bottom=ToFixedPoint(this.ChartBorder.GetTopEx());
|
|
199
|
-
var width=right-left;
|
|
200
|
-
var height=bottom-top;
|
|
201
|
-
|
|
202
|
-
this.Canvas.fillStyle=this.TitleBGColor;
|
|
203
|
-
this.Canvas.fillRect(left,top,width,height);
|
|
204
|
-
*/
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
this.DrawLock = function ()
|
|
208
|
-
{
|
|
209
|
-
if (this.IsLocked)
|
|
210
|
-
{
|
|
211
|
-
if (this.LockPaint == null) this.LockPaint = new ChartLock();
|
|
212
|
-
|
|
213
|
-
this.LockPaint.Canvas = this.Canvas;
|
|
214
|
-
this.LockPaint.ChartBorder = this.ChartBorder;
|
|
215
|
-
this.LockPaint.ChartFrame = this;
|
|
216
|
-
this.LockPaint.Draw();
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
|
|
220
|
-
this.DrawLogo=function()
|
|
221
|
-
{
|
|
222
|
-
var border=this.GetBorder();
|
|
223
|
-
var text=g_JSChartResource.FrameLogo.Text;
|
|
224
|
-
if (!text) return;
|
|
225
|
-
|
|
226
|
-
this.Canvas.fillStyle=this.LogoTextColor;
|
|
227
|
-
this.Canvas.font=this.LogoTextFont;
|
|
228
|
-
this.Canvas.textAlign = 'left';
|
|
229
|
-
this.Canvas.textBaseline = 'bottom';
|
|
230
|
-
if (this.IsHScreen)
|
|
231
|
-
{
|
|
232
|
-
var x=border.Left+5;
|
|
233
|
-
var y=border.Top+5;
|
|
234
|
-
this.Canvas.save();
|
|
235
|
-
this.Canvas.translate(x,y);
|
|
236
|
-
this.Canvas.rotate(90 * Math.PI / 180);
|
|
237
|
-
this.Canvas.fillText(text,0,0);
|
|
238
|
-
this.Canvas.restore();
|
|
239
|
-
}
|
|
240
|
-
else
|
|
241
|
-
{
|
|
242
|
-
var x=border.Left+5;
|
|
243
|
-
var y=border.Bottom-5;
|
|
244
|
-
this.Canvas.fillText(text,x,y);
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
//设施上锁
|
|
249
|
-
this.SetLock = function (lockData)
|
|
250
|
-
{
|
|
251
|
-
if (!lockData) //空数据不上锁
|
|
252
|
-
{
|
|
253
|
-
this.IsLocked = false;
|
|
254
|
-
return;
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
this.IsLocked = true;
|
|
258
|
-
if (!this.LockPaint) this.LockPaint = new ChartLock(); //创建锁
|
|
259
|
-
if (lockData.Callback) this.LockPaint.Callback = lockData.Callback; //回调
|
|
260
|
-
if (lockData.IndexName) this.LockPaint.IndexName = lockData.IndexName; //指标名字
|
|
261
|
-
if (lockData.ID) this.LockPaint.LockID = lockData.ID; //锁ID
|
|
262
|
-
if (lockData.BG) this.LockPaint.BGColor = lockData.BG; //背景色
|
|
263
|
-
if (lockData.Text) this.LockPaint.Title = lockData.Text;
|
|
264
|
-
if (lockData.TextColor) this.LockPaint.TextColor = lockData.TextColor;
|
|
265
|
-
if (lockData.Font) this.LockPaint.Font = lockData.Font;
|
|
266
|
-
if (lockData.Count) this.LockPaint.LockCount = lockData.Count;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
this.GetLockRect=function()
|
|
270
|
-
{
|
|
271
|
-
if (!this.IsLocked) return null;
|
|
272
|
-
if (!this.LockPaint) return null;
|
|
273
|
-
return this.LockPaint.LockRect;
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
this.GetFontHeight=function(font)
|
|
277
|
-
{
|
|
278
|
-
if (font) this.Canvas.font=font;
|
|
279
|
-
return this.Canvas.measureText("擎").width;
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
//空框架只画边框
|
|
285
|
-
function NoneFrame()
|
|
286
|
-
{
|
|
287
|
-
this.newMethod = IChartFramePainting; //派生
|
|
288
|
-
this.newMethod();
|
|
289
|
-
delete this.newMethod;
|
|
290
|
-
this.ClassName='NoneFrame';
|
|
291
|
-
|
|
292
|
-
this.Snapshot = function () { }
|
|
293
|
-
|
|
294
|
-
this.DrawInsideHorizontal = function () { }
|
|
295
|
-
|
|
296
|
-
this.SetSizeChage = function (sizeChange)
|
|
297
|
-
{
|
|
298
|
-
this.SizeChange = sizeChange;
|
|
299
|
-
|
|
300
|
-
//画布的位置
|
|
301
|
-
this.Position =
|
|
302
|
-
{
|
|
303
|
-
X: this.ChartBorder.UIElement.offsetLeft,
|
|
304
|
-
Y: this.ChartBorder.UIElement.offsetTop,
|
|
305
|
-
W: this.ChartBorder.UIElement.clientWidth,
|
|
306
|
-
H: this.ChartBorder.UIElement.clientHeight
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
function AverageWidthFrame()
|
|
312
|
-
{
|
|
313
|
-
this.newMethod = IChartFramePainting; //派生
|
|
314
|
-
this.newMethod();
|
|
315
|
-
delete this.newMethod;
|
|
316
|
-
this.ClassName='AverageWidthFrame';
|
|
317
|
-
|
|
318
|
-
this.DataWidth = 50;
|
|
319
|
-
this.DistanceWidth = 10;
|
|
320
|
-
this.MinXDistance = 30; //X轴刻度最小间距
|
|
321
|
-
this.MinYDistance=10;
|
|
322
|
-
this.XMessageAlign = 'top'; //X轴刻度文字上下对齐方式
|
|
323
|
-
this.IsShowTitle = true; //是否显示动态标题
|
|
324
|
-
this.IsShowYText = [true, true]; //是否显示Y轴坐标坐标 [0=左侧] [1=右侧]
|
|
325
|
-
this.XBottomOffset = g_JSChartResource.Frame.XBottomOffset; //X轴文字显示向下偏移
|
|
326
|
-
this.YTextTopOffset=g_JSChartResource.Frame.YTopOffset; //Y轴顶部文字向下偏移
|
|
327
|
-
this.YTextPosition=[0,0], //是坐标否强制画在内部 [0=左侧] [1=右侧] 1=OUT" , 2=INSIDE
|
|
328
|
-
this.YTextPadding=[g_JSChartResource.Frame.YTextPadding[0], g_JSChartResource.Frame.YTextPadding[1]], //Y轴文字和边框间距 [0=左侧] [1=右侧]
|
|
329
|
-
this.IsShowXLine=true; //是否显示X轴刻度线
|
|
330
|
-
this.IsShowYLine=true;
|
|
331
|
-
this.YTextBaseline=0; //0=居中 1=上部 (目前就支持内部刻度)
|
|
332
|
-
|
|
333
|
-
this.ShortYLineLength=5;
|
|
334
|
-
this.ShortXLineLength=5;
|
|
335
|
-
|
|
336
|
-
this.DrawOtherChart; //其他画法调用
|
|
337
|
-
this.GetEventCallback; //事件回调
|
|
338
|
-
|
|
339
|
-
this.DrawFrame = function ()
|
|
340
|
-
{
|
|
341
|
-
if (this.XPointCount > 0)
|
|
342
|
-
{
|
|
343
|
-
this.DistanceWidth = this.ChartBorder.GetWidth() / (4 * this.XPointCount);
|
|
344
|
-
this.DataWidth = 2 * this.DistanceWidth;
|
|
345
|
-
}
|
|
346
|
-
|
|
347
|
-
this.DrawHorizontal();
|
|
348
|
-
this.DrawVertical();
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
this.GetYFromData = function (value)
|
|
352
|
-
{
|
|
353
|
-
if (value <= this.HorizontalMin) return this.ChartBorder.GetBottomEx();
|
|
354
|
-
if (value >= this.HorizontalMax) return this.ChartBorder.GetTopEx();
|
|
355
|
-
|
|
356
|
-
var height = this.ChartBorder.GetHeightEx() * (value - this.HorizontalMin) / (this.HorizontalMax - this.HorizontalMin);
|
|
357
|
-
return this.ChartBorder.GetBottomEx() - height;
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
//Y刻度画在内部
|
|
361
|
-
this.DrawInsideHorizontal = function ()
|
|
362
|
-
{
|
|
363
|
-
if (this.IsHScreen === true) return; //横屏不画
|
|
364
|
-
if (this.IsMinSize) return;
|
|
365
|
-
if (this.IsShowYText[0] === false && this.IsShowYText[1] === false) return;
|
|
366
|
-
|
|
367
|
-
var left = this.ChartBorder.GetLeft();
|
|
368
|
-
var right = this.ChartBorder.GetRight();
|
|
369
|
-
var bottom = this.ChartBorder.GetBottom();
|
|
370
|
-
var top = this.ChartBorder.GetTopTitle();
|
|
371
|
-
var borderRight = this.ChartBorder.Right;
|
|
372
|
-
var borderLeft = this.ChartBorder.Left;
|
|
373
|
-
var titleHeight = this.ChartBorder.TitleHeight;
|
|
374
|
-
if (borderLeft >= 10) return;
|
|
375
|
-
|
|
376
|
-
if ((borderLeft < 10 && this.IsShowYText[0] === true) || (borderRight < 10 && this.IsShowYText[1] === true))
|
|
377
|
-
{
|
|
378
|
-
var yPrev = null; //上一个坐标y的值
|
|
379
|
-
for (var i = this.HorizontalInfo.length - 1; i >= 0; --i) //从上往下画分割线
|
|
380
|
-
{
|
|
381
|
-
var item = this.HorizontalInfo[i];
|
|
382
|
-
if (!item) continue;
|
|
383
|
-
var y = this.GetYFromData(item.Value);
|
|
384
|
-
if (y != null && yPrev !=null && Math.abs(y - yPrev) < this.MinYDistance) continue; //两个坐标在近了 就不画了
|
|
385
|
-
|
|
386
|
-
//坐标信息 左边 间距小于10 画在内部
|
|
387
|
-
if (item.Message[0] != null && borderLeft < 10 && this.IsShowYText[0] === true)
|
|
388
|
-
{
|
|
389
|
-
if (item.Font != null) this.Canvas.font = item.Font;
|
|
390
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
391
|
-
this.Canvas.textAlign = "left";
|
|
392
|
-
var yText=y;
|
|
393
|
-
if (y >= bottom - 2)
|
|
394
|
-
{
|
|
395
|
-
this.Canvas.textBaseline = 'bottom';
|
|
396
|
-
}
|
|
397
|
-
else if (y <= top + 2)
|
|
398
|
-
{
|
|
399
|
-
this.Canvas.textBaseline = 'top';
|
|
400
|
-
yText+=this.YTextTopOffset;
|
|
401
|
-
}
|
|
402
|
-
else
|
|
403
|
-
{
|
|
404
|
-
if (this.YTextBaseline==1) this.Canvas.textBaseline = "bottom";
|
|
405
|
-
else this.Canvas.textBaseline = "middle";
|
|
406
|
-
}
|
|
407
|
-
var textObj = { X: left, Y: yText, Text: { BaseLine: this.Canvas.textBaseline, Font: this.Canvas.font, Value: item.Message[0] } };
|
|
408
|
-
if (!this.IsOverlayMaxMin || !this.IsOverlayMaxMin(textObj)) this.Canvas.fillText(item.Message[0], left + 1, yText);
|
|
409
|
-
}
|
|
410
|
-
|
|
411
|
-
if (item.Message[1] != null && borderRight < 10 && this.IsShowYText[1] === true)
|
|
412
|
-
{
|
|
413
|
-
if (item.Font != null) this.Canvas.font = item.Font;
|
|
414
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
415
|
-
this.Canvas.textAlign = "right";
|
|
416
|
-
var yText=y;
|
|
417
|
-
if (y >= bottom - 2)
|
|
418
|
-
{
|
|
419
|
-
this.Canvas.textBaseline = 'bottom';
|
|
420
|
-
}
|
|
421
|
-
else if (y <= top + 2)
|
|
422
|
-
{
|
|
423
|
-
this.Canvas.textBaseline = 'top';
|
|
424
|
-
yText+=this.YTextTopOffset;
|
|
425
|
-
}
|
|
426
|
-
else
|
|
427
|
-
{
|
|
428
|
-
if (this.YTextBaseline==1) this.Canvas.textBaseline = "bottom";
|
|
429
|
-
else this.Canvas.textBaseline = "middle";
|
|
430
|
-
}
|
|
431
|
-
var textWidth = this.Canvas.measureText(item.Message[1]).width;
|
|
432
|
-
var textObj = { X: right - textWidth, Y: yText, Text: { BaseLine: this.Canvas.textBaseline, TextAlign: this.Canvas.textAlign, Font: this.Canvas.font, Value: item.Message[1] } };
|
|
433
|
-
if (!this.IsOverlayMaxMin || !this.IsOverlayMaxMin(textObj))
|
|
434
|
-
this.Canvas.fillText(item.Message[1], right - 1, yText);
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
yPrev = y;
|
|
438
|
-
}
|
|
439
|
-
}
|
|
440
|
-
}
|
|
441
|
-
|
|
442
|
-
//画Y轴
|
|
443
|
-
this.DrawHorizontal = function ()
|
|
444
|
-
{
|
|
445
|
-
var left = this.ChartBorder.GetLeft();
|
|
446
|
-
var right = this.ChartBorder.GetRight();
|
|
447
|
-
var bottom = this.ChartBorder.GetBottom();
|
|
448
|
-
var top = this.ChartBorder.GetTopTitle();
|
|
449
|
-
var borderRight = this.ChartBorder.Right;
|
|
450
|
-
var borderLeft = this.ChartBorder.Left;
|
|
451
|
-
var titleHeight = this.ChartBorder.TitleHeight;
|
|
452
|
-
|
|
453
|
-
this.Canvas.save();
|
|
454
|
-
var yPrev = null; //上一个坐标y的值
|
|
455
|
-
for (var i = this.HorizontalInfo.length - 1; i >= 0; --i) //从上往下画分割线
|
|
456
|
-
{
|
|
457
|
-
var item = this.HorizontalInfo[i];
|
|
458
|
-
var y = this.GetYFromData(item.Value);
|
|
459
|
-
if (y != null && yPrev != null && Math.abs(y - yPrev) <this.MinYDistance) continue; //两个坐标在近了 就不画了
|
|
460
|
-
|
|
461
|
-
var yFixed=ToFixedPoint(y);
|
|
462
|
-
if (bottom!=y && this.IsShowYLine) //和底部线段重叠了就不绘制
|
|
463
|
-
{
|
|
464
|
-
if (item.LineType==2)
|
|
465
|
-
{
|
|
466
|
-
this.Canvas.strokeStyle = item.LineColor;
|
|
467
|
-
if (item.LineDash) this.Canvas.setLineDash(item.LineDash);
|
|
468
|
-
else this.Canvas.setLineDash([5,5]);
|
|
469
|
-
this.Canvas.beginPath();
|
|
470
|
-
this.Canvas.moveTo(left, yFixed);
|
|
471
|
-
this.Canvas.lineTo(right,yFixed);
|
|
472
|
-
this.Canvas.stroke();
|
|
473
|
-
this.Canvas.setLineDash([]);
|
|
474
|
-
}
|
|
475
|
-
else if (item.LineType==3) //只在刻度边上画一个短横线
|
|
476
|
-
{
|
|
477
|
-
|
|
478
|
-
}
|
|
479
|
-
else if (item.LineType>0)
|
|
480
|
-
{
|
|
481
|
-
this.Canvas.strokeStyle = item.LineColor;
|
|
482
|
-
if(g_JSChartResource.FrameYLineDash)
|
|
483
|
-
{
|
|
484
|
-
this.Canvas.setLineDash(g_JSChartResource.FrameYLineDash); //虚线
|
|
485
|
-
this.Canvas.beginPath();
|
|
486
|
-
this.Canvas.moveTo(left, yFixed);
|
|
487
|
-
this.Canvas.lineTo(right, yFixed);
|
|
488
|
-
this.Canvas.stroke();
|
|
489
|
-
this.Canvas.setLineDash([]);
|
|
490
|
-
}
|
|
491
|
-
else
|
|
492
|
-
{
|
|
493
|
-
this.Canvas.beginPath();
|
|
494
|
-
this.Canvas.moveTo(left, yFixed);
|
|
495
|
-
this.Canvas.lineTo(right, yFixed);
|
|
496
|
-
this.Canvas.stroke();
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
var yText=y;
|
|
501
|
-
if (y >= bottom - 2)
|
|
502
|
-
{
|
|
503
|
-
this.Canvas.textBaseline = 'bottom';
|
|
504
|
-
}
|
|
505
|
-
else if (y <= top + 2)
|
|
506
|
-
{
|
|
507
|
-
this.Canvas.textBaseline = 'top';
|
|
508
|
-
yText+=this.YTextTopOffset;
|
|
509
|
-
}
|
|
510
|
-
else
|
|
511
|
-
{
|
|
512
|
-
this.Canvas.textBaseline = "middle";
|
|
513
|
-
}
|
|
514
|
-
|
|
515
|
-
//坐标信息 左边 间距小于10 不画坐标
|
|
516
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
517
|
-
this.Canvas.strokeStyle = item.TextColor;
|
|
518
|
-
if (item.Message[0] != null && borderLeft > 10 && this.IsShowYText[0] === true)
|
|
519
|
-
{
|
|
520
|
-
if (item.Font != null) this.Canvas.font = item.Font;
|
|
521
|
-
|
|
522
|
-
this.Canvas.textAlign = "right";
|
|
523
|
-
this.Canvas.fillText(item.Message[0], left - this.YTextPadding[0], yText);
|
|
524
|
-
}
|
|
525
|
-
|
|
526
|
-
//坐标信息 右边 间距小于10 不画坐标
|
|
527
|
-
if (item.Message[1] != null && borderRight > 10 && this.IsShowYText[1] === true)
|
|
528
|
-
{
|
|
529
|
-
if (item.Font != null) this.Canvas.font = item.Font;
|
|
530
|
-
|
|
531
|
-
var xText=right;
|
|
532
|
-
if (item.LineType==3)
|
|
533
|
-
{
|
|
534
|
-
var lineLength=this.ShortYLineLength;
|
|
535
|
-
this.Canvas.beginPath();
|
|
536
|
-
this.Canvas.moveTo(xText,yFixed);
|
|
537
|
-
this.Canvas.lineTo(xText+lineLength,yFixed);
|
|
538
|
-
this.Canvas.stroke();
|
|
539
|
-
|
|
540
|
-
xText+=lineLength;
|
|
541
|
-
}
|
|
542
|
-
|
|
543
|
-
this.Canvas.textAlign = "left";
|
|
544
|
-
this.Canvas.fillText(item.Message[1], xText + this.YTextPadding[1], yText);
|
|
545
|
-
}
|
|
546
|
-
|
|
547
|
-
yPrev = y;
|
|
548
|
-
}
|
|
549
|
-
|
|
550
|
-
this.Canvas.restore();
|
|
551
|
-
}
|
|
552
|
-
|
|
553
|
-
this.GetXFromIndex = function (index)
|
|
554
|
-
{
|
|
555
|
-
var count = this.XPointCount;
|
|
556
|
-
|
|
557
|
-
if (count == 1)
|
|
558
|
-
{
|
|
559
|
-
if (index == 0) return this.ChartBorder.GetLeft();
|
|
560
|
-
else return this.ChartBorder.GetRight();
|
|
561
|
-
}
|
|
562
|
-
else if (count <= 0)
|
|
563
|
-
{
|
|
564
|
-
return this.ChartBorder.GetLeft();
|
|
565
|
-
}
|
|
566
|
-
else if (index >= count)
|
|
567
|
-
{
|
|
568
|
-
return this.ChartBorder.GetRight();
|
|
569
|
-
}
|
|
570
|
-
else
|
|
571
|
-
{
|
|
572
|
-
var offset = this.ChartBorder.GetLeft() + this.ChartBorder.GetWidth() * index / count;
|
|
573
|
-
return offset;
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
|
|
577
|
-
//画X轴
|
|
578
|
-
this.DrawVertical = function ()
|
|
579
|
-
{
|
|
580
|
-
var top = this.ChartBorder.GetTopTitle();
|
|
581
|
-
var bottom = this.ChartBorder.GetBottom();
|
|
582
|
-
var right = this.ChartBorder.GetRight();
|
|
583
|
-
|
|
584
|
-
if (this.ChartBorder.Bottom<=5) return; //高度不够 不显示
|
|
585
|
-
|
|
586
|
-
var yText = bottom;
|
|
587
|
-
if (this.XMessageAlign == 'bottom') yText = this.ChartBorder.GetChartHeight();
|
|
588
|
-
else this.XMessageAlign = 'top';
|
|
589
|
-
|
|
590
|
-
var xPrev = null; //上一个坐标x的值
|
|
591
|
-
let xPrevTextRight = null;
|
|
592
|
-
for (var i in this.VerticalInfo)
|
|
593
|
-
{
|
|
594
|
-
var x = this.GetXFromIndex(this.VerticalInfo[i].Value);
|
|
595
|
-
if (x > right) break;
|
|
596
|
-
if (xPrev != null && Math.abs(x - xPrev) < this.MinXDistance) continue;
|
|
597
|
-
|
|
598
|
-
var item=this.VerticalInfo[i];
|
|
599
|
-
var xFixed=ToFixedPoint(x);
|
|
600
|
-
if (this.IsShowXLine && item.LineType > 0)
|
|
601
|
-
{
|
|
602
|
-
if (item.LineType==2)
|
|
603
|
-
{
|
|
604
|
-
this.Canvas.strokeStyle = item.LineColor;
|
|
605
|
-
if (item.LineDash) this.Canvas.setLineDash(item.LineDash);
|
|
606
|
-
else this.Canvas.setLineDash([5,5]);
|
|
607
|
-
this.Canvas.beginPath();
|
|
608
|
-
this.Canvas.moveTo(xFixed, top);
|
|
609
|
-
this.Canvas.lineTo(xFixed, bottom);
|
|
610
|
-
this.Canvas.stroke();
|
|
611
|
-
this.Canvas.setLineDash([]);
|
|
612
|
-
}
|
|
613
|
-
else if (item.LineType==3)
|
|
614
|
-
{
|
|
615
|
-
|
|
616
|
-
}
|
|
617
|
-
else if (item.LineType>0)
|
|
618
|
-
{
|
|
619
|
-
if(g_JSChartResource.FrameXLineDash)
|
|
620
|
-
{
|
|
621
|
-
this.Canvas.strokeStyle = item.LineColor;
|
|
622
|
-
this.Canvas.beginPath();
|
|
623
|
-
this.Canvas.setLineDash(g_JSChartResource.FrameXLineDash);
|
|
624
|
-
this.Canvas.moveTo(xFixed, top);
|
|
625
|
-
this.Canvas.lineTo(xFixed, bottom);
|
|
626
|
-
this.Canvas.stroke();
|
|
627
|
-
this.Canvas.setLineDash([]);
|
|
628
|
-
}
|
|
629
|
-
else
|
|
630
|
-
{
|
|
631
|
-
this.Canvas.strokeStyle = item.LineColor;
|
|
632
|
-
this.Canvas.beginPath();
|
|
633
|
-
this.Canvas.moveTo(xFixed, top);
|
|
634
|
-
this.Canvas.lineTo(xFixed, bottom);
|
|
635
|
-
this.Canvas.stroke();
|
|
636
|
-
}
|
|
637
|
-
}
|
|
638
|
-
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
if (this.VerticalInfo[i].Message[0] != null && this.ChartBorder.Bottom > 5)
|
|
642
|
-
{
|
|
643
|
-
let xTextRight = null;
|
|
644
|
-
let xTextLeft = null;
|
|
645
|
-
if (this.VerticalInfo[i].Font != null)
|
|
646
|
-
this.Canvas.font = this.VerticalInfo[i].Font;
|
|
647
|
-
this.Canvas.fillStyle=item.TextColor;
|
|
648
|
-
this.Canvas.strokeStyle=item.TextColor;
|
|
649
|
-
|
|
650
|
-
var testWidth = this.Canvas.measureText(this.VerticalInfo[i].Message[0]).width;
|
|
651
|
-
if (x < testWidth / 2)
|
|
652
|
-
{
|
|
653
|
-
this.Canvas.textAlign = "left";
|
|
654
|
-
this.Canvas.textBaseline = this.XMessageAlign;
|
|
655
|
-
xTextRight = x + testWidth;
|
|
656
|
-
xTextLeft = x;
|
|
657
|
-
}
|
|
658
|
-
else if ((x + testWidth / 2) >= this.ChartBorder.GetChartWidth())
|
|
659
|
-
{
|
|
660
|
-
this.Canvas.textAlign = "right";
|
|
661
|
-
this.Canvas.textBaseline = this.XMessageAlign;
|
|
662
|
-
xTextRight = x + testWidth;
|
|
663
|
-
xTextLeft = x;
|
|
664
|
-
}
|
|
665
|
-
else
|
|
666
|
-
{
|
|
667
|
-
this.Canvas.textAlign = "center";
|
|
668
|
-
this.Canvas.textBaseline = this.XMessageAlign;
|
|
669
|
-
xTextRight = x + testWidth / 2;
|
|
670
|
-
xTextLeft = x - testWidth / 2;
|
|
671
|
-
}
|
|
672
|
-
|
|
673
|
-
if (xPrevTextRight != null && xPrevTextRight > xTextLeft) continue;
|
|
674
|
-
|
|
675
|
-
var yText=bottom;
|
|
676
|
-
if (item.LineType==3)
|
|
677
|
-
{
|
|
678
|
-
var lineLength=this.ShortXLineLength;
|
|
679
|
-
this.Canvas.beginPath();
|
|
680
|
-
this.Canvas.moveTo(xFixed,yText);
|
|
681
|
-
this.Canvas.lineTo(xFixed,yText+lineLength);
|
|
682
|
-
this.Canvas.stroke();
|
|
683
|
-
|
|
684
|
-
yText+=lineLength+2;
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
this.Canvas.fillText(this.VerticalInfo[i].Message[0], x, yText + this.XBottomOffset);
|
|
688
|
-
xPrevTextRight = xTextRight;
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
xPrev = x;
|
|
692
|
-
}
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
this.GetYData = function (y) //Y坐标转y轴数值
|
|
696
|
-
{
|
|
697
|
-
if (y < this.ChartBorder.GetTopEx()) return this.HorizontalMax;
|
|
698
|
-
if (y > this.ChartBorder.GetBottomEx()) return this.HorizontalMin;
|
|
699
|
-
|
|
700
|
-
return (this.ChartBorder.GetBottomEx() - y) / this.ChartBorder.GetHeightEx() * (this.HorizontalMax - this.HorizontalMin) + this.HorizontalMin;
|
|
701
|
-
}
|
|
702
|
-
|
|
703
|
-
this.GetXData = function (x) //X坐标转x轴数值
|
|
704
|
-
{
|
|
705
|
-
if (x <= this.ChartBorder.GetLeft()) return 0;
|
|
706
|
-
if (x >= this.ChartBorder.GetRight()) return this.XPointCount;
|
|
707
|
-
|
|
708
|
-
return (x - this.ChartBorder.GetLeft()) * (this.XPointCount * 1.0 / this.ChartBorder.GetWidth());
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
this.DrawCustomItem = function (item) //显示自定义刻度
|
|
712
|
-
{
|
|
713
|
-
//if (this.IsHScreen === true) return; //横屏不画
|
|
714
|
-
if (!item.Message[1] && !item.Message[0]) return;
|
|
715
|
-
if (item.Value > this.HorizontalMax || item.Value < this.HorizontalMin)
|
|
716
|
-
{
|
|
717
|
-
if (item.CountDown===true) this.SendDrawCountDownEvent( { IsShow:false } );
|
|
718
|
-
return;
|
|
719
|
-
}
|
|
720
|
-
|
|
721
|
-
var left = this.ChartBorder.GetLeft();
|
|
722
|
-
var right = this.ChartBorder.GetRight();
|
|
723
|
-
var bottom = this.ChartBorder.GetBottom();
|
|
724
|
-
var top = this.ChartBorder.GetTopTitle();
|
|
725
|
-
var borderRight = this.ChartBorder.Right;
|
|
726
|
-
var borderLeft = this.ChartBorder.Left;
|
|
727
|
-
var titleHeight = this.ChartBorder.TitleHeight;
|
|
728
|
-
|
|
729
|
-
if (this.IsHScreen)
|
|
730
|
-
{
|
|
731
|
-
borderLeft = this.ChartBorder.Top;
|
|
732
|
-
borderRight = this.ChartBorder.Bottom;
|
|
733
|
-
top = this.ChartBorder.GetTop();
|
|
734
|
-
bottom = this.ChartBorder.GetBottom();
|
|
735
|
-
}
|
|
736
|
-
|
|
737
|
-
var defaultTextHeight=16
|
|
738
|
-
var textHeight = defaultTextHeight;
|
|
739
|
-
var y = this.GetYFromData(item.Value);
|
|
740
|
-
var position=0;
|
|
741
|
-
|
|
742
|
-
if (item.ExtendData && item.ExtendData.Custom)
|
|
743
|
-
{
|
|
744
|
-
var customItem=item.ExtendData.Custom;
|
|
745
|
-
if (IFrameSplitOperator.IsNumber(customItem.Position)) position=customItem.Position;
|
|
746
|
-
}
|
|
747
|
-
|
|
748
|
-
if (item.Message[0])
|
|
749
|
-
{
|
|
750
|
-
if (borderLeft < 10 || position==1) //左边
|
|
751
|
-
{
|
|
752
|
-
if (item.Font != null) this.Canvas.font = item.Font;
|
|
753
|
-
this.Canvas.textAlign = "left";
|
|
754
|
-
this.Canvas.textBaseline = "middle";
|
|
755
|
-
var textInfo=this.GetCustomItemTextInfo(item,true);
|
|
756
|
-
var textWidth = textInfo.MaxWidth;
|
|
757
|
-
var fontHeight=this.GetFontHeight();
|
|
758
|
-
textHeight=fontHeight>defaultTextHeight? fontHeight:defaultTextHeight;
|
|
759
|
-
var bgColor = item.LineColor;
|
|
760
|
-
var rgb = this.RGBToStruct(item.LineColor);
|
|
761
|
-
if (rgb) bgColor = `rgba(${rgb.R}, ${rgb.G}, ${rgb.B}, ${g_JSChartResource.FrameLatestPrice.BGAlpha})`; //内部刻度 背景增加透明度
|
|
762
|
-
|
|
763
|
-
var yText=y;
|
|
764
|
-
for(var i=0;i<textInfo.Text.length;++i)
|
|
765
|
-
{
|
|
766
|
-
var itemText=textInfo.Text[i];
|
|
767
|
-
if (this.IsHScreen)
|
|
768
|
-
{
|
|
769
|
-
var bgTop = top;
|
|
770
|
-
var textLeft = yText - textHeight / 2 - 1;
|
|
771
|
-
this.Canvas.fillStyle = bgColor;
|
|
772
|
-
this.Canvas.fillRect(textLeft, bgTop, textHeight, textWidth);
|
|
773
|
-
this.DrawHScreenText({ X: yText, Y: bgTop }, { Text: itemText.Text, Color: item.TextColor, XOffset: 1, YOffset: 2 });
|
|
774
|
-
if (i==0) this.DrawLine(bgTop + itemText.Width, bottom, yText, item.LineColor,item.LineType);
|
|
775
|
-
|
|
776
|
-
yText-=textHeight+1;
|
|
777
|
-
}
|
|
778
|
-
else
|
|
779
|
-
{
|
|
780
|
-
var bgTop = yText - textHeight / 2 - 1;
|
|
781
|
-
var textLeft = left + 1;
|
|
782
|
-
this.Canvas.fillStyle = bgColor;
|
|
783
|
-
this.Canvas.fillRect(textLeft, bgTop, itemText.Width, textHeight);
|
|
784
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
785
|
-
this.Canvas.fillText(itemText.Text, textLeft + 1, yText);
|
|
786
|
-
if (i==0) this.DrawLine(textLeft + itemText.Width, right, yText, item.LineColor,item.LineType);
|
|
787
|
-
|
|
788
|
-
yText+=textHeight+1;
|
|
789
|
-
}
|
|
790
|
-
}
|
|
791
|
-
}
|
|
792
|
-
else
|
|
793
|
-
{
|
|
794
|
-
if (item.Font != null) this.Canvas.font = item.Font;
|
|
795
|
-
this.Canvas.textAlign = "right";
|
|
796
|
-
this.Canvas.textBaseline = "middle";
|
|
797
|
-
var textInfo=this.GetCustomItemTextInfo(item,true);
|
|
798
|
-
var textWidth=textInfo.MaxWidth;
|
|
799
|
-
var fontHeight=this.GetFontHeight();
|
|
800
|
-
textHeight=fontHeight>defaultTextHeight? fontHeight:defaultTextHeight;
|
|
801
|
-
|
|
802
|
-
var yText=y;
|
|
803
|
-
for(var i=0;i<textInfo.Text.length;++i)
|
|
804
|
-
{
|
|
805
|
-
var itemText=textInfo.Text[i];
|
|
806
|
-
if (this.IsHScreen)
|
|
807
|
-
{
|
|
808
|
-
if (i==0) var bgTop=top-itemText.Width;
|
|
809
|
-
else var bgTop=top-textWidth;
|
|
810
|
-
var textLeft=yText-textHeight/2-1;
|
|
811
|
-
this.Canvas.fillStyle=item.LineColor;
|
|
812
|
-
this.Canvas.fillRect(textLeft,bgTop,textHeight,itemText.Width);
|
|
813
|
-
this.DrawHScreenText({ X: yText, Y: bgTop }, { Text: itemText.Text, Color: item.TextColor, XOffset: 1, YOffset: 2 });
|
|
814
|
-
if (i==0) this.DrawLine(bgTop + itemText.Width, bottom, yText, item.LineColor,item.LineType);
|
|
815
|
-
|
|
816
|
-
yText-=textHeight+1;
|
|
817
|
-
}
|
|
818
|
-
else
|
|
819
|
-
{
|
|
820
|
-
var bgTop = yText - textHeight / 2 - 1;
|
|
821
|
-
if (i==0)
|
|
822
|
-
{
|
|
823
|
-
var rectLeft=left-itemText.Width;
|
|
824
|
-
var textLeft=left;
|
|
825
|
-
}
|
|
826
|
-
else
|
|
827
|
-
{
|
|
828
|
-
var rectLeft=left-textWidth;
|
|
829
|
-
var textLeft=left-(textWidth-itemText.Width);
|
|
830
|
-
}
|
|
831
|
-
|
|
832
|
-
this.Canvas.fillStyle = item.LineColor;
|
|
833
|
-
this.Canvas.fillRect(rectLeft,bgTop,itemText.Width,textHeight);
|
|
834
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
835
|
-
this.Canvas.fillText(itemText.Text, textLeft - 1, yText);
|
|
836
|
-
if (i==0) this.DrawLine(left, right, yText, item.LineColor,item.LineType);
|
|
837
|
-
|
|
838
|
-
yText+=textHeight+1;
|
|
839
|
-
}
|
|
840
|
-
}
|
|
841
|
-
}
|
|
842
|
-
}
|
|
843
|
-
else if (item.Message[1]) //右边
|
|
844
|
-
{
|
|
845
|
-
if (borderRight < 10 || position==1)
|
|
846
|
-
{
|
|
847
|
-
if (item.Font != null) this.Canvas.font = item.Font;
|
|
848
|
-
this.Canvas.textAlign = "left";
|
|
849
|
-
this.Canvas.textBaseline = "middle";
|
|
850
|
-
var textInfo=this.GetCustomItemTextInfo(item,false);
|
|
851
|
-
var textWidth=textInfo.MaxWidth;
|
|
852
|
-
var fontHeight=this.GetFontHeight();
|
|
853
|
-
textHeight=fontHeight>defaultTextHeight? fontHeight:defaultTextHeight;
|
|
854
|
-
var bgColor = item.LineColor;
|
|
855
|
-
var rgb = this.RGBToStruct(item.LineColor);
|
|
856
|
-
if (rgb) bgColor = `rgba(${rgb.R}, ${rgb.G}, ${rgb.B}, ${g_JSChartResource.FrameLatestPrice.BGAlpha})`; //内部刻度 背景增加透明度
|
|
857
|
-
|
|
858
|
-
var yText=y;
|
|
859
|
-
for(var i=0;i<textInfo.Text.length;++i)
|
|
860
|
-
{
|
|
861
|
-
var itemText=textInfo.Text[i];
|
|
862
|
-
if (this.IsHScreen)
|
|
863
|
-
{
|
|
864
|
-
var bgTop=bottom-itemText.Width;
|
|
865
|
-
var textLeft=yText-textHeight/2-1;
|
|
866
|
-
this.Canvas.fillStyle=bgColor;
|
|
867
|
-
this.Canvas.fillRect(textLeft,bgTop,textHeight,itemText.Width);
|
|
868
|
-
this.DrawHScreenText({X:yText, Y:bgTop}, {Text:itemText.Text, Color:item.TextColor, XOffset:1, YOffset:2});
|
|
869
|
-
if (i==0) this.DrawLine(top, bgTop, yText, item.LineColor,item.LineType);
|
|
870
|
-
|
|
871
|
-
yText-=textHeight+1;
|
|
872
|
-
}
|
|
873
|
-
else
|
|
874
|
-
{
|
|
875
|
-
var bgTop=yText-textHeight/2-1;
|
|
876
|
-
var textLeft=right-itemText.Width;
|
|
877
|
-
this.Canvas.fillStyle=bgColor;
|
|
878
|
-
this.Canvas.fillRect(textLeft, bgTop, itemText.Width, textHeight);
|
|
879
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
880
|
-
this.Canvas.fillText(itemText.Text, textLeft + 1, yText);
|
|
881
|
-
if (i==0) this.DrawLine(left, textLeft,yText , item.LineColor,item.LineType);
|
|
882
|
-
|
|
883
|
-
if (item.CountDown===true)
|
|
884
|
-
{
|
|
885
|
-
if (this.GetEventCallback)
|
|
886
|
-
{
|
|
887
|
-
var bgTop=yText + textHeight / 2 + 1;
|
|
888
|
-
var sendData=
|
|
889
|
-
{
|
|
890
|
-
Top:bgTop, Right:right, Height:null,
|
|
891
|
-
IsShow:true, BGColor:bgColor, TextColor:item.TextColor, Position:"Right", IsInside:true
|
|
892
|
-
};
|
|
893
|
-
this.SendDrawCountDownEvent(sendData);
|
|
894
|
-
}
|
|
895
|
-
}
|
|
896
|
-
|
|
897
|
-
yText+=textHeight+1;
|
|
898
|
-
}
|
|
899
|
-
}
|
|
900
|
-
|
|
901
|
-
if (item.Type==3 || item.Type==4)
|
|
902
|
-
{
|
|
903
|
-
if (item.Title)
|
|
904
|
-
{
|
|
905
|
-
var width=this.Canvas.measureText(item.Title).width+2;
|
|
906
|
-
if (this.IsHScreen)
|
|
907
|
-
{
|
|
908
|
-
var bgTop=bottom-itemText.Width-width;
|
|
909
|
-
var textLeft=y-textHeight/2-1;
|
|
910
|
-
this.Canvas.fillStyle=bgColor;
|
|
911
|
-
this.Canvas.fillRect(textLeft,bgTop,textHeight,width);
|
|
912
|
-
this.DrawHScreenText({X:y, Y:bgTop}, {Text:item.Title, Color:item.TextColor, XOffset:1, YOffset:2});
|
|
913
|
-
}
|
|
914
|
-
else
|
|
915
|
-
{
|
|
916
|
-
var bgTop=y-textHeight/2-1;
|
|
917
|
-
var textLeft=right-textWidth-width-1;
|
|
918
|
-
this.Canvas.fillStyle=bgColor;
|
|
919
|
-
this.Canvas.fillRect(textLeft,bgTop,width,textHeight);
|
|
920
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
921
|
-
this.Canvas.fillText(item.Title, textLeft + 1, y);
|
|
922
|
-
}
|
|
923
|
-
}
|
|
924
|
-
}
|
|
925
|
-
}
|
|
926
|
-
else
|
|
927
|
-
{
|
|
928
|
-
if (item.Font != null) this.Canvas.font = item.Font;
|
|
929
|
-
this.Canvas.textAlign = "left";
|
|
930
|
-
this.Canvas.textBaseline = "middle";
|
|
931
|
-
var textInfo=this.GetCustomItemTextInfo(item,false);
|
|
932
|
-
var textWidth=textInfo.MaxWidth;
|
|
933
|
-
var fontHeight=this.GetFontHeight();
|
|
934
|
-
textHeight=fontHeight>defaultTextHeight? fontHeight:defaultTextHeight;
|
|
935
|
-
|
|
936
|
-
var yText=y;
|
|
937
|
-
for(var i=0;i<textInfo.Text.length;++i)
|
|
938
|
-
{
|
|
939
|
-
var itemText=textInfo.Text[i];
|
|
940
|
-
|
|
941
|
-
if (this.IsHScreen)
|
|
942
|
-
{
|
|
943
|
-
var bgTop = bottom;
|
|
944
|
-
var textLeft=yText-textHeight/2-1;
|
|
945
|
-
this.Canvas.fillStyle=item.LineColor;
|
|
946
|
-
this.Canvas.fillRect(textLeft, bgTop, textHeight, itemText.Width);
|
|
947
|
-
this.DrawHScreenText({ X: yText, Y: bgTop }, { Text: itemText.Text, Color: item.TextColor, XOffset: 1 , YOffset: 2 });
|
|
948
|
-
if (i==0) this.DrawLine(top, bgTop, yText, item.LineColor,item.LineType);
|
|
949
|
-
|
|
950
|
-
yText-=textHeight+1;
|
|
951
|
-
}
|
|
952
|
-
else
|
|
953
|
-
{
|
|
954
|
-
var bgTop=yText-textHeight/2-1;
|
|
955
|
-
if (i==0)
|
|
956
|
-
{
|
|
957
|
-
var textLeft=right;
|
|
958
|
-
}
|
|
959
|
-
else
|
|
960
|
-
{
|
|
961
|
-
var textLeft=right+textWidth-itemText.Width;
|
|
962
|
-
}
|
|
963
|
-
|
|
964
|
-
this.Canvas.fillStyle = item.LineColor;
|
|
965
|
-
this.Canvas.fillRect(textLeft,bgTop,itemText.Width,textHeight);
|
|
966
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
967
|
-
this.Canvas.fillText(itemText.Text, textLeft+1, yText);
|
|
968
|
-
if (i==0) this.DrawLine(left, right, yText, item.LineColor,item.LineType);
|
|
969
|
-
|
|
970
|
-
if (item.CountDown===true)
|
|
971
|
-
{
|
|
972
|
-
if (this.GetEventCallback)
|
|
973
|
-
{
|
|
974
|
-
var bgTop=yText-textHeight/2-1;
|
|
975
|
-
var sendData=
|
|
976
|
-
{
|
|
977
|
-
Top:bgTop, Left:right, Right:this.ChartBorder.GetChartWidth(), Height:null,
|
|
978
|
-
IsShow:true, BGColor:item.LineColor, TextColor:item.TextColor, Position:"Right", IsInside:false
|
|
979
|
-
};
|
|
980
|
-
this.SendDrawCountDownEvent(sendData);
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
|
|
984
|
-
yText+=textHeight+1;
|
|
985
|
-
}
|
|
986
|
-
}
|
|
987
|
-
|
|
988
|
-
if (item.Type==3 || item.Type==4)
|
|
989
|
-
{
|
|
990
|
-
if (item.Title)
|
|
991
|
-
{
|
|
992
|
-
var bgColor=item.LineColor;
|
|
993
|
-
var rgb=this.RGBToStruct(item.LineColor);
|
|
994
|
-
if (rgb) bgColor=`rgba(${rgb.R}, ${rgb.G}, ${rgb.B}, ${g_JSChartResource.FrameLatestPrice.BGAlpha})`; //内部刻度 背景增加透明度
|
|
995
|
-
var width=this.Canvas.measureText(item.Title).width+2;
|
|
996
|
-
if (this.IsHScreen)
|
|
997
|
-
{
|
|
998
|
-
var bgTop=bottom-width;
|
|
999
|
-
var textLeft=y-textHeight/2-1;
|
|
1000
|
-
this.Canvas.fillStyle=bgColor;
|
|
1001
|
-
this.Canvas.fillRect(textLeft,bgTop,textHeight,width);
|
|
1002
|
-
this.DrawHScreenText({X:y, Y:bgTop}, {Text:item.Title, Color:item.TextColor, XOffset:1, YOffset:2});
|
|
1003
|
-
}
|
|
1004
|
-
else
|
|
1005
|
-
{
|
|
1006
|
-
var bgTop=y-textHeight/2-1;
|
|
1007
|
-
var textLeft=right-width-1;
|
|
1008
|
-
this.Canvas.fillStyle=bgColor;
|
|
1009
|
-
this.Canvas.fillRect(textLeft,bgTop,width,textHeight);
|
|
1010
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
1011
|
-
this.Canvas.fillText(item.Title, textLeft + 1, y);
|
|
1012
|
-
}
|
|
1013
|
-
}
|
|
1014
|
-
}
|
|
1015
|
-
}
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
|
|
1019
|
-
this.GetCustomItemTextInfo=function(item, bLeft)
|
|
1020
|
-
{
|
|
1021
|
-
var text=bLeft?item.Message[0]:item.Message[1];
|
|
1022
|
-
var aryText=[];
|
|
1023
|
-
var width=0;
|
|
1024
|
-
if (Array.isArray(text))
|
|
1025
|
-
{
|
|
1026
|
-
for(var i=0;i<text.length;++i)
|
|
1027
|
-
{
|
|
1028
|
-
var item=text[i];
|
|
1029
|
-
if (item.Type===1)
|
|
1030
|
-
{
|
|
1031
|
-
aryText.push({ Type: item.Type });
|
|
1032
|
-
}
|
|
1033
|
-
else
|
|
1034
|
-
{
|
|
1035
|
-
var value=this.Canvas.measureText(item.Text).width;
|
|
1036
|
-
if (value>width) width=value;
|
|
1037
|
-
aryText.push({Text:item.Text, Width:value+3});
|
|
1038
|
-
}
|
|
1039
|
-
}
|
|
1040
|
-
|
|
1041
|
-
if (width>0) width+=3;
|
|
1042
|
-
}
|
|
1043
|
-
else
|
|
1044
|
-
{
|
|
1045
|
-
width=this.Canvas.measureText(text).width+3;
|
|
1046
|
-
aryText.push( {Text:text, Width:width} );
|
|
1047
|
-
}
|
|
1048
|
-
|
|
1049
|
-
return { MaxWidth:width, Text:aryText };
|
|
1050
|
-
}
|
|
1051
|
-
|
|
1052
|
-
this.SendDrawCountDownEvent=function(sendData)
|
|
1053
|
-
{
|
|
1054
|
-
if (!this.GetEventCallback) return false;
|
|
1055
|
-
var event=this.GetEventCallback(JSCHART_EVENT_ID.ON_DRAW_COUNTDOWN);
|
|
1056
|
-
if (!event || !event.Callback) return false;
|
|
1057
|
-
|
|
1058
|
-
event.Callback(event,sendData,this);
|
|
1059
|
-
return true;
|
|
1060
|
-
}
|
|
1061
|
-
|
|
1062
|
-
this.DrawLine=function(left, right, y, color, lineType)
|
|
1063
|
-
{
|
|
1064
|
-
if (lineType==-1) return;
|
|
1065
|
-
|
|
1066
|
-
if (lineType==0)
|
|
1067
|
-
{
|
|
1068
|
-
this.Canvas.strokeStyle = color;
|
|
1069
|
-
this.Canvas.beginPath();
|
|
1070
|
-
if (this.IsHScreen)
|
|
1071
|
-
{
|
|
1072
|
-
this.Canvas.moveTo(ToFixedPoint(y), left);
|
|
1073
|
-
this.Canvas.lineTo(ToFixedPoint(y), right);
|
|
1074
|
-
}
|
|
1075
|
-
else
|
|
1076
|
-
{
|
|
1077
|
-
this.Canvas.moveTo(left, ToFixedPoint(y));
|
|
1078
|
-
this.Canvas.lineTo(right, ToFixedPoint(y));
|
|
1079
|
-
}
|
|
1080
|
-
this.Canvas.stroke();
|
|
1081
|
-
}
|
|
1082
|
-
else
|
|
1083
|
-
{
|
|
1084
|
-
this.DrawDotLine(left, right, y, color);
|
|
1085
|
-
}
|
|
1086
|
-
}
|
|
1087
|
-
|
|
1088
|
-
this.DrawDotLine = function (left, right, y, color)
|
|
1089
|
-
{
|
|
1090
|
-
this.Canvas.save();
|
|
1091
|
-
this.Canvas.strokeStyle = color;
|
|
1092
|
-
this.Canvas.setLineDash([5, 5]); //虚线
|
|
1093
|
-
this.Canvas.beginPath();
|
|
1094
|
-
if (this.IsHScreen)
|
|
1095
|
-
{
|
|
1096
|
-
this.Canvas.moveTo(ToFixedPoint(y), left);
|
|
1097
|
-
this.Canvas.lineTo(ToFixedPoint(y), right);
|
|
1098
|
-
}
|
|
1099
|
-
else
|
|
1100
|
-
{
|
|
1101
|
-
this.Canvas.moveTo(left, ToFixedPoint(y));
|
|
1102
|
-
this.Canvas.lineTo(right, ToFixedPoint(y));
|
|
1103
|
-
}
|
|
1104
|
-
this.Canvas.stroke();
|
|
1105
|
-
this.Canvas.restore();
|
|
1106
|
-
}
|
|
1107
|
-
|
|
1108
|
-
this.RGBToStruct = function (rgb)
|
|
1109
|
-
{
|
|
1110
|
-
if (/^(rgb|RGB)/.test(rgb))
|
|
1111
|
-
{
|
|
1112
|
-
var aColor = rgb.replace(/(?:\(|\)|rgb|RGB)*/g, "").split(",");
|
|
1113
|
-
var result = {};
|
|
1114
|
-
if (aColor.length != 3) return null;
|
|
1115
|
-
|
|
1116
|
-
result.R = Number(aColor[0]);
|
|
1117
|
-
result.G = Number(aColor[1]);
|
|
1118
|
-
result.B = Number(aColor[2]);
|
|
1119
|
-
return result;
|
|
1120
|
-
}
|
|
1121
|
-
return null;
|
|
1122
|
-
}
|
|
1123
|
-
|
|
1124
|
-
this.DrawHScreenText = function (center, data)
|
|
1125
|
-
{
|
|
1126
|
-
this.Canvas.textAlign = "left";
|
|
1127
|
-
this.Canvas.textBaseline = "middle";
|
|
1128
|
-
this.Canvas.fillStyle = data.Color;
|
|
1129
|
-
|
|
1130
|
-
this.Canvas.save();
|
|
1131
|
-
this.Canvas.translate(center.X, center.Y);
|
|
1132
|
-
this.Canvas.rotate(90 * Math.PI / 180);
|
|
1133
|
-
this.Canvas.fillText(data.Text, data.XOffset, data.YOffset);
|
|
1134
|
-
this.Canvas.restore();
|
|
1135
|
-
}
|
|
1136
|
-
|
|
1137
|
-
this.GetScaleTextWidth=function()
|
|
1138
|
-
{
|
|
1139
|
-
var border=this.ChartBorder.GetBorder();
|
|
1140
|
-
if (this.IsHScreen)
|
|
1141
|
-
{
|
|
1142
|
-
var borderTop = this.ChartBorder.Top;
|
|
1143
|
-
var borderBottom = this.ChartBorder.Bottom;
|
|
1144
|
-
var isDrawLeft=borderTop>10 && this.IsShowYText[0]===true;
|
|
1145
|
-
var isDrawRight=borderBottom>10 && this.IsShowYText[1]===true;
|
|
1146
|
-
}
|
|
1147
|
-
else
|
|
1148
|
-
{
|
|
1149
|
-
var borderRight=this.ChartBorder.Right;
|
|
1150
|
-
var borderLeft=this.ChartBorder.Left;
|
|
1151
|
-
var isDrawLeft=borderLeft>10 && this.IsShowYText[0]===true;
|
|
1152
|
-
var isDrawRight=borderRight>10 && this.IsShowYText[1]===true;
|
|
1153
|
-
}
|
|
1154
|
-
|
|
1155
|
-
var width={ Left:null, Right:null };
|
|
1156
|
-
if (!isDrawRight && !isDrawLeft) return width;
|
|
1157
|
-
|
|
1158
|
-
for(var i=0;i<this.HorizontalInfo.length;++i)
|
|
1159
|
-
{
|
|
1160
|
-
var textWidth=null;
|
|
1161
|
-
var item=this.HorizontalInfo[i];
|
|
1162
|
-
if (!item) continue;
|
|
1163
|
-
if (item.Font!=null) this.Canvas.font=item.Font;
|
|
1164
|
-
|
|
1165
|
-
if (item.Message[0]!=null && isDrawLeft)
|
|
1166
|
-
{
|
|
1167
|
-
textWidth=this.Canvas.measureText(item.Message[0]).width;
|
|
1168
|
-
if (width.Left==null || width.Left<textWidth)
|
|
1169
|
-
width.Left=textWidth;
|
|
1170
|
-
}
|
|
1171
|
-
|
|
1172
|
-
if (item.Message[1]!=null && isDrawRight)
|
|
1173
|
-
{
|
|
1174
|
-
textWidth=this.Canvas.measureText(item.Message[1]).width;
|
|
1175
|
-
if (width.Right==null || width.Right<textWidth)
|
|
1176
|
-
width.Right=textWidth;
|
|
1177
|
-
}
|
|
1178
|
-
}
|
|
1179
|
-
|
|
1180
|
-
if (IFrameSplitOperator.IsNumber(width.Left)) width.Left+=this.YTextPadding[0];
|
|
1181
|
-
if (IFrameSplitOperator.IsNumber(width.Right)) width.Right+=this.YTextPadding[1];
|
|
1182
|
-
|
|
1183
|
-
return { TextWidth:width };
|
|
1184
|
-
}
|
|
1185
|
-
}
|
|
1186
|
-
|
|
1187
|
-
function MinuteFrame()
|
|
1188
|
-
{
|
|
1189
|
-
this.newMethod = AverageWidthFrame; //派生
|
|
1190
|
-
this.newMethod();
|
|
1191
|
-
delete this.newMethod;
|
|
1192
|
-
this.ClassName='MinuteFrame';
|
|
1193
|
-
|
|
1194
|
-
this.DataWidth=1;
|
|
1195
|
-
this.DistanceWidth=1;
|
|
1196
|
-
this.MinXDistance = 10;
|
|
1197
|
-
this.CustomHorizontalInfo = [];
|
|
1198
|
-
|
|
1199
|
-
this.DrawFrame = function ()
|
|
1200
|
-
{
|
|
1201
|
-
if (this.IsMinSize) return;
|
|
1202
|
-
|
|
1203
|
-
this.SplitXYCoordinate();
|
|
1204
|
-
|
|
1205
|
-
this.DrawTitleBG();
|
|
1206
|
-
this.DrawHorizontal();
|
|
1207
|
-
this.DrawVertical();
|
|
1208
|
-
}
|
|
1209
|
-
|
|
1210
|
-
//分割x,y轴坐标信息
|
|
1211
|
-
this.SplitXYCoordinate = function ()
|
|
1212
|
-
{
|
|
1213
|
-
if (this.XYSplit == false) return;
|
|
1214
|
-
if (this.YSplitOperator != null) this.YSplitOperator.Operator();
|
|
1215
|
-
if (this.XSplitOperator != null) this.XSplitOperator.Operator();
|
|
1216
|
-
}
|
|
1217
|
-
|
|
1218
|
-
this.GetXFromIndex = function (index)
|
|
1219
|
-
{
|
|
1220
|
-
var count = this.XPointCount - 1;
|
|
1221
|
-
|
|
1222
|
-
if (count == 1)
|
|
1223
|
-
{
|
|
1224
|
-
if (index == 0) return this.ChartBorder.GetLeft();
|
|
1225
|
-
else return this.ChartBorder.GetRight();
|
|
1226
|
-
}
|
|
1227
|
-
else if (count <= 0)
|
|
1228
|
-
{
|
|
1229
|
-
return this.ChartBorder.GetLeft();
|
|
1230
|
-
}
|
|
1231
|
-
else if (index >= count)
|
|
1232
|
-
{
|
|
1233
|
-
return this.ChartBorder.GetRight();
|
|
1234
|
-
}
|
|
1235
|
-
else
|
|
1236
|
-
{
|
|
1237
|
-
var offset = this.ChartBorder.GetLeft() + this.ChartBorder.GetWidth() * index / count;
|
|
1238
|
-
return offset;
|
|
1239
|
-
}
|
|
1240
|
-
}
|
|
1241
|
-
|
|
1242
|
-
//X坐标转x轴数值
|
|
1243
|
-
this.GetXData = function (x)
|
|
1244
|
-
{
|
|
1245
|
-
if (x <= this.ChartBorder.GetLeft()) return 0;
|
|
1246
|
-
if (x >= this.ChartBorder.GetRight()) return this.XPointCount;
|
|
1247
|
-
|
|
1248
|
-
return (x - this.ChartBorder.GetLeft()) * (this.XPointCount * 1.0 / this.ChartBorder.GetWidth());
|
|
1249
|
-
}
|
|
1250
|
-
|
|
1251
|
-
this.DrawCustomHorizontal = function () //Y轴刻度定制显示
|
|
1252
|
-
{
|
|
1253
|
-
if (this.IsMinSize) return;
|
|
1254
|
-
for (var i in this.CustomHorizontalInfo)
|
|
1255
|
-
{
|
|
1256
|
-
var item = this.CustomHorizontalInfo[i];
|
|
1257
|
-
switch (item.Type)
|
|
1258
|
-
{
|
|
1259
|
-
case 0:
|
|
1260
|
-
case 1:
|
|
1261
|
-
this.DrawCustomItem(item); //自定义刻度
|
|
1262
|
-
break;
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
}
|
|
1266
|
-
}
|
|
1267
|
-
|
|
1268
|
-
function MinuteHScreenFrame()
|
|
1269
|
-
{
|
|
1270
|
-
this.newMethod = MinuteFrame; //派生
|
|
1271
|
-
this.newMethod();
|
|
1272
|
-
delete this.newMethod;
|
|
1273
|
-
|
|
1274
|
-
this.ClassName='MinuteHScreenFrame';
|
|
1275
|
-
this.IsHScreen = true; //是否是横屏
|
|
1276
|
-
|
|
1277
|
-
//画标题背景色
|
|
1278
|
-
this.DrawTitleBG = function ()
|
|
1279
|
-
{
|
|
1280
|
-
/*
|
|
1281
|
-
if (this.ChartBorder.TitleHeight <= 0) return;
|
|
1282
|
-
|
|
1283
|
-
var left = ToFixedPoint(this.ChartBorder.GetRightEx());
|
|
1284
|
-
var top = ToFixedPoint(this.ChartBorder.GetTop());
|
|
1285
|
-
var bottom = ToFixedPoint(this.ChartBorder.GetBottom());
|
|
1286
|
-
var width = this.ChartBorder.TitleHeight;
|
|
1287
|
-
var height = bottom - top;
|
|
1288
|
-
|
|
1289
|
-
this.Canvas.fillStyle = this.TitleBGColor;
|
|
1290
|
-
this.Canvas.fillRect(left, top, width, height);
|
|
1291
|
-
*/
|
|
1292
|
-
}
|
|
1293
|
-
|
|
1294
|
-
this.DrawInsideHorizontal = function ()
|
|
1295
|
-
{
|
|
1296
|
-
if (this.IsMinSize) return;
|
|
1297
|
-
if (this.IsShowYText[0] === false && this.IsShowYText[1] === false) return;
|
|
1298
|
-
|
|
1299
|
-
var left = this.ChartBorder.GetLeft();
|
|
1300
|
-
var right = this.ChartBorder.GetRightEx();
|
|
1301
|
-
var top = this.ChartBorder.GetTop();
|
|
1302
|
-
var bottom = this.ChartBorder.GetBottom();
|
|
1303
|
-
var borderTop = this.ChartBorder.Top;
|
|
1304
|
-
var borderBottom = this.ChartBorder.Bottom;
|
|
1305
|
-
var titleHeight = this.ChartBorder.TitleHeight;
|
|
1306
|
-
var pixelTatio = 1;
|
|
1307
|
-
|
|
1308
|
-
var isDrawLeft = (borderTop < 10 * pixelTatio || this.YTextPosition[0] == 2) && this.IsShowYText[0] === true;
|
|
1309
|
-
var isDrawRight = (borderBottom < 10 * pixelTatio || this.YTextPosition[1] == 2) && this.IsShowYText[1] === true;
|
|
1310
|
-
|
|
1311
|
-
if (isDrawLeft || isDrawRight)
|
|
1312
|
-
{
|
|
1313
|
-
var yPrev = null; //上一个坐标y的值
|
|
1314
|
-
for (var i = this.HorizontalInfo.length - 1; i >= 0; --i) //从上往下画分割线
|
|
1315
|
-
{
|
|
1316
|
-
var item = this.HorizontalInfo[i];
|
|
1317
|
-
var y = this.GetYFromData(item.Value);
|
|
1318
|
-
if (y != null && yPrev != null && Math.abs(y - yPrev) < this.MinYDistance) continue; //两个坐标在近了 就不画了
|
|
1319
|
-
|
|
1320
|
-
//坐标信息 左边 间距小于10 画在内部
|
|
1321
|
-
if (item.Message[0] != null && isDrawLeft)
|
|
1322
|
-
{
|
|
1323
|
-
if (item.Font != null) this.Canvas.font = item.Font;
|
|
1324
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
1325
|
-
this.Canvas.textAlign = "left";
|
|
1326
|
-
if (y >= right - 2) this.Canvas.textBaseline = 'top';
|
|
1327
|
-
else if (y <= left + 2) this.Canvas.textBaseline = 'bottom';
|
|
1328
|
-
else this.Canvas.textBaseline = "middle";
|
|
1329
|
-
|
|
1330
|
-
var textObj = { X: left, Y: y, Text: { BaseLine: this.Canvas.textBaseline, TextAlign: this.Canvas.textAlign, Font: this.Canvas.font, Value: item.Message[0] } };
|
|
1331
|
-
var xText = y, yText = top;
|
|
1332
|
-
this.Canvas.save();
|
|
1333
|
-
this.Canvas.translate(xText, yText);
|
|
1334
|
-
this.Canvas.rotate(90 * Math.PI / 180);
|
|
1335
|
-
this.Canvas.fillText(item.Message[0], 2, 0);
|
|
1336
|
-
this.Canvas.restore();
|
|
1337
|
-
}
|
|
1338
|
-
|
|
1339
|
-
if (item.Message[1] != null && isDrawRight)
|
|
1340
|
-
{
|
|
1341
|
-
if (item.Font != null) this.Canvas.font = item.Font;
|
|
1342
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
1343
|
-
this.Canvas.textAlign = "right";
|
|
1344
|
-
if (y >= right - 2) this.Canvas.textBaseline = 'top';
|
|
1345
|
-
else if (y <= left + 2) this.Canvas.textBaseline = 'bottom';
|
|
1346
|
-
else this.Canvas.textBaseline = "middle";
|
|
1347
|
-
var textWidth = this.Canvas.measureText(item.Message[1]).width;
|
|
1348
|
-
var textObj = { X: right - textWidth, Y: y, Text: { BaseLine: this.Canvas.textBaseline, TextAlign: this.Canvas.textAlign, Font: this.Canvas.font, Value: item.Message[1] } };
|
|
1349
|
-
|
|
1350
|
-
var xText = y, yText = bottom;
|
|
1351
|
-
this.Canvas.save();
|
|
1352
|
-
this.Canvas.translate(xText, yText);
|
|
1353
|
-
this.Canvas.rotate(90 * Math.PI / 180);
|
|
1354
|
-
this.Canvas.fillText(item.Message[1], -2, 0);
|
|
1355
|
-
this.Canvas.restore();
|
|
1356
|
-
}
|
|
1357
|
-
yPrev = y;
|
|
1358
|
-
}
|
|
1359
|
-
}
|
|
1360
|
-
}
|
|
1361
|
-
|
|
1362
|
-
//Y坐标转y轴数值
|
|
1363
|
-
this.GetYData = function (x)
|
|
1364
|
-
{
|
|
1365
|
-
if (x < this.ChartBorder.GetLeftEx()) return this.HorizontalMin;
|
|
1366
|
-
if (x > this.ChartBorder.GetRightEx()) return this.HorizontalMax;
|
|
1367
|
-
|
|
1368
|
-
return (x - this.ChartBorder.GetLeftEx()) / this.ChartBorder.GetWidthEx() * (this.HorizontalMax - this.HorizontalMin) + this.HorizontalMin;
|
|
1369
|
-
}
|
|
1370
|
-
|
|
1371
|
-
//X坐标转x轴数值
|
|
1372
|
-
this.GetXData = function (y)
|
|
1373
|
-
{
|
|
1374
|
-
if (y <= this.ChartBorder.GetTop()) return 0;
|
|
1375
|
-
if (y >= this.ChartBorder.GetBottom()) return this.XPointCount;
|
|
1376
|
-
|
|
1377
|
-
var count=this.XPointCount-1;
|
|
1378
|
-
return (y - this.ChartBorder.GetTop()) * (count * 1.0 / this.ChartBorder.GetHeight());
|
|
1379
|
-
}
|
|
1380
|
-
|
|
1381
|
-
this.GetXFromIndex = function (index)
|
|
1382
|
-
{
|
|
1383
|
-
var count = this.XPointCount - 1;
|
|
1384
|
-
|
|
1385
|
-
if (count == 1)
|
|
1386
|
-
{
|
|
1387
|
-
if (index == 0) return this.ChartBorder.GetTop();
|
|
1388
|
-
else return this.ChartBorder.GetBottom();
|
|
1389
|
-
}
|
|
1390
|
-
else if (count <= 0)
|
|
1391
|
-
{
|
|
1392
|
-
return this.ChartBorder.GetTop();
|
|
1393
|
-
}
|
|
1394
|
-
else if (index >= count)
|
|
1395
|
-
{
|
|
1396
|
-
return this.ChartBorder.GetBottom();
|
|
1397
|
-
}
|
|
1398
|
-
else
|
|
1399
|
-
{
|
|
1400
|
-
var offset = this.ChartBorder.GetTop() + this.ChartBorder.GetHeight() * index / count;
|
|
1401
|
-
return offset;
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
this.GetYFromData = function (value)
|
|
1407
|
-
{
|
|
1408
|
-
if (value <= this.HorizontalMin) return this.ChartBorder.GetLeft();
|
|
1409
|
-
if (value >= this.HorizontalMax) return this.ChartBorder.GetRightEx();
|
|
1410
|
-
|
|
1411
|
-
var width = this.ChartBorder.GetWidthEx() * (value - this.HorizontalMin) / (this.HorizontalMax - this.HorizontalMin);
|
|
1412
|
-
return this.ChartBorder.GetLeft() + width;
|
|
1413
|
-
}
|
|
1414
|
-
|
|
1415
|
-
//画Y轴
|
|
1416
|
-
this.DrawHorizontal = function ()
|
|
1417
|
-
{
|
|
1418
|
-
var top = this.ChartBorder.GetTop();
|
|
1419
|
-
var bottom = this.ChartBorder.GetBottom();
|
|
1420
|
-
var left=this.ChartBorder.GetLeft();
|
|
1421
|
-
var right=this.ChartBorder.GetRight();
|
|
1422
|
-
var borderTop = this.ChartBorder.Top;
|
|
1423
|
-
var borderBottom = this.ChartBorder.Bottom;
|
|
1424
|
-
|
|
1425
|
-
var yPrev = null; //上一个坐标y的值
|
|
1426
|
-
for (var i = this.HorizontalInfo.length - 1; i >= 0; --i) //从左往右画分割线
|
|
1427
|
-
{
|
|
1428
|
-
var item = this.HorizontalInfo[i];
|
|
1429
|
-
var y = this.GetYFromData(item.Value);
|
|
1430
|
-
if (y != null && Math.abs(y - yPrev) < this.MinYDistance) continue; //两个坐标在近了 就不画了
|
|
1431
|
-
|
|
1432
|
-
this.Canvas.strokeStyle = item.LineColor;
|
|
1433
|
-
this.Canvas.beginPath();
|
|
1434
|
-
this.Canvas.moveTo(ToFixedPoint(y), top);
|
|
1435
|
-
this.Canvas.lineTo(ToFixedPoint(y), bottom);
|
|
1436
|
-
this.Canvas.stroke();
|
|
1437
|
-
|
|
1438
|
-
if (y >= right - 2)
|
|
1439
|
-
{
|
|
1440
|
-
this.Canvas.textBaseline = 'top';
|
|
1441
|
-
y = right;
|
|
1442
|
-
}
|
|
1443
|
-
else if (y <= left + 2)
|
|
1444
|
-
{
|
|
1445
|
-
this.Canvas.textBaseline = 'bottom';
|
|
1446
|
-
y=left;
|
|
1447
|
-
if (y != null && Math.abs(y - yPrev) < 2*this.MinYDistance) continue; //两个坐标在近了 就不画了
|
|
1448
|
-
}
|
|
1449
|
-
else
|
|
1450
|
-
{
|
|
1451
|
-
this.Canvas.textBaseline = "middle";
|
|
1452
|
-
}
|
|
1453
|
-
|
|
1454
|
-
//坐标信息 左边 间距小于10 不画坐标
|
|
1455
|
-
if (item.Message[0] != null && borderTop > 10)
|
|
1456
|
-
{
|
|
1457
|
-
if (item.Font != null) this.Canvas.font = item.Font;
|
|
1458
|
-
|
|
1459
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
1460
|
-
this.Canvas.textAlign = "right";
|
|
1461
|
-
//this.Canvas.textBaseline = "middle";
|
|
1462
|
-
|
|
1463
|
-
var xText = y, yText = top;
|
|
1464
|
-
this.Canvas.save();
|
|
1465
|
-
this.Canvas.translate(xText, yText);
|
|
1466
|
-
this.Canvas.rotate(90 * Math.PI / 180);
|
|
1467
|
-
this.Canvas.fillText(item.Message[0], -2, 0);
|
|
1468
|
-
this.Canvas.restore();
|
|
1469
|
-
}
|
|
1470
|
-
|
|
1471
|
-
//坐标信息 右边 间距小于10 不画坐标
|
|
1472
|
-
if (item.Message[1] != null && borderBottom > 10)
|
|
1473
|
-
{
|
|
1474
|
-
if (item.Font != null) this.Canvas.font = item.Font;
|
|
1475
|
-
|
|
1476
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
1477
|
-
this.Canvas.textAlign = "left";
|
|
1478
|
-
//this.Canvas.textBaseline = "middle";
|
|
1479
|
-
var xText = y, yText = bottom;
|
|
1480
|
-
this.Canvas.save();
|
|
1481
|
-
this.Canvas.translate(xText, yText);
|
|
1482
|
-
this.Canvas.rotate(90 * Math.PI / 180);
|
|
1483
|
-
this.Canvas.fillText(item.Message[1], 2, 0);
|
|
1484
|
-
this.Canvas.restore();
|
|
1485
|
-
}
|
|
1486
|
-
|
|
1487
|
-
yPrev = y;
|
|
1488
|
-
}
|
|
1489
|
-
}
|
|
1490
|
-
|
|
1491
|
-
//画X轴
|
|
1492
|
-
this.DrawVertical = function () {
|
|
1493
|
-
var left = this.ChartBorder.GetLeft();
|
|
1494
|
-
var right = this.ChartBorder.GetRightEx();
|
|
1495
|
-
var bottom = this.ChartBorder.GetBottom();
|
|
1496
|
-
|
|
1497
|
-
var xPrev = null; //上一个坐标x的值
|
|
1498
|
-
for (var i in this.VerticalInfo) {
|
|
1499
|
-
var x = this.GetXFromIndex(this.VerticalInfo[i].Value);
|
|
1500
|
-
if (x > bottom) break;
|
|
1501
|
-
if (xPrev != null && Math.abs(x - xPrev) < this.MinXDistance) continue;
|
|
1502
|
-
|
|
1503
|
-
this.Canvas.strokeStyle = this.VerticalInfo[i].LineColor;
|
|
1504
|
-
this.Canvas.beginPath();
|
|
1505
|
-
this.Canvas.moveTo(left, ToFixedPoint(x));
|
|
1506
|
-
this.Canvas.lineTo(right, ToFixedPoint(x));
|
|
1507
|
-
this.Canvas.stroke();
|
|
1508
|
-
|
|
1509
|
-
if (this.VerticalInfo[i].Message[0] != null) {
|
|
1510
|
-
if (this.VerticalInfo[i].Font != null)
|
|
1511
|
-
this.Canvas.font = this.VerticalInfo[i].Font;
|
|
1512
|
-
|
|
1513
|
-
this.Canvas.fillStyle = this.VerticalInfo[i].TextColor;
|
|
1514
|
-
var testWidth = this.Canvas.measureText(this.VerticalInfo[i].Message[0]).width;
|
|
1515
|
-
if (x < testWidth / 2) {
|
|
1516
|
-
this.Canvas.textAlign = "left";
|
|
1517
|
-
this.Canvas.textBaseline = "top";
|
|
1518
|
-
}
|
|
1519
|
-
else if ((x + testWidth / 2) >= this.ChartBorder.GetChartHeight()) {
|
|
1520
|
-
this.Canvas.textAlign = "right";
|
|
1521
|
-
this.Canvas.textBaseline = "top";
|
|
1522
|
-
}
|
|
1523
|
-
else {
|
|
1524
|
-
this.Canvas.textAlign = "center";
|
|
1525
|
-
this.Canvas.textBaseline = "top";
|
|
1526
|
-
}
|
|
1527
|
-
|
|
1528
|
-
var xText = left, yText = x;
|
|
1529
|
-
this.Canvas.save();
|
|
1530
|
-
this.Canvas.translate(xText, yText);
|
|
1531
|
-
this.Canvas.rotate(90 * Math.PI / 180);
|
|
1532
|
-
this.Canvas.fillText(this.VerticalInfo[i].Message[0], 0, 0);
|
|
1533
|
-
this.Canvas.restore();
|
|
1534
|
-
}
|
|
1535
|
-
|
|
1536
|
-
xPrev = x;
|
|
1537
|
-
}
|
|
1538
|
-
}
|
|
1539
|
-
}
|
|
1540
|
-
|
|
1541
|
-
function OverlayMinuteFrame()
|
|
1542
|
-
{
|
|
1543
|
-
this.newMethod=MinuteFrame; //派生
|
|
1544
|
-
this.newMethod();
|
|
1545
|
-
delete this.newMethod;
|
|
1546
|
-
|
|
1547
|
-
this.ClassName="OverlayMinuteFrame";
|
|
1548
|
-
this.IsShow=true; //坐标是否显示
|
|
1549
|
-
this.IsShareY=false; //使用和主框架公用Y轴
|
|
1550
|
-
this.IsCalculateYMaxMin=true; //是否计算Y最大最小值
|
|
1551
|
-
|
|
1552
|
-
this.Draw=function()
|
|
1553
|
-
{
|
|
1554
|
-
this.SplitXYCoordinate();
|
|
1555
|
-
if (this.IsShow)
|
|
1556
|
-
{
|
|
1557
|
-
|
|
1558
|
-
}
|
|
1559
|
-
|
|
1560
|
-
this.SizeChange=false;
|
|
1561
|
-
this.XYSplit=false;
|
|
1562
|
-
this.XSplit=false;
|
|
1563
|
-
}
|
|
1564
|
-
|
|
1565
|
-
this.GetScaleTextWidth=function()
|
|
1566
|
-
{
|
|
1567
|
-
return { TextWidth:0 };
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
|
-
//分割x,y轴坐标信息
|
|
1571
|
-
this.SplitXYCoordinate=function()
|
|
1572
|
-
{
|
|
1573
|
-
if (this.XYSplit==false) return;
|
|
1574
|
-
|
|
1575
|
-
if (this.IsShareY) //和主图指标共享Y轴坐标
|
|
1576
|
-
{
|
|
1577
|
-
this.HorizontalMax=this.MainFrame.HorizontalMax;
|
|
1578
|
-
this.HorizontalMin=this.MainFrame.HorizontalMin;
|
|
1579
|
-
this.HorizontalInfo=[];
|
|
1580
|
-
for(var i=0; i<this.MainFrame.HorizontalInfo.length; ++i)
|
|
1581
|
-
{
|
|
1582
|
-
var item=this.MainFrame.HorizontalInfo[i];
|
|
1583
|
-
this.HorizontalInfo.push(item);
|
|
1584
|
-
}
|
|
1585
|
-
}
|
|
1586
|
-
else //独立Y轴坐标
|
|
1587
|
-
{
|
|
1588
|
-
if (this.YSplitOperator!=null) this.YSplitOperator.Operator();
|
|
1589
|
-
}
|
|
1590
|
-
}
|
|
1591
|
-
}
|
|
1592
|
-
|
|
1593
|
-
function OverlayMinuteHScreenFrame()
|
|
1594
|
-
{
|
|
1595
|
-
this.newMethod=MinuteHScreenFrame; //派生
|
|
1596
|
-
this.newMethod();
|
|
1597
|
-
delete this.newMethod;
|
|
1598
|
-
|
|
1599
|
-
this.ClassName="OverlayMinuteHScreenFrame";
|
|
1600
|
-
this.IsShow=true; //坐标是否显示
|
|
1601
|
-
|
|
1602
|
-
this.Draw=function()
|
|
1603
|
-
{
|
|
1604
|
-
this.SplitXYCoordinate();
|
|
1605
|
-
if (this.IsShow)
|
|
1606
|
-
{
|
|
1607
|
-
|
|
1608
|
-
}
|
|
1609
|
-
|
|
1610
|
-
this.SizeChange=false;
|
|
1611
|
-
this.XYSplit=false;
|
|
1612
|
-
}
|
|
1613
|
-
|
|
1614
|
-
//分割x,y轴坐标信息
|
|
1615
|
-
this.SplitXYCoordinate=function()
|
|
1616
|
-
{
|
|
1617
|
-
if (this.XYSplit==false) return;
|
|
1618
|
-
|
|
1619
|
-
if (this.IsShareY) //和主图指标共享Y轴坐标
|
|
1620
|
-
{
|
|
1621
|
-
this.HorizontalMax=this.MainFrame.HorizontalMax;
|
|
1622
|
-
this.HorizontalMin=this.MainFrame.HorizontalMin;
|
|
1623
|
-
this.HorizontalInfo=[];
|
|
1624
|
-
for(var i=0; i<this.MainFrame.HorizontalInfo.length; ++i)
|
|
1625
|
-
{
|
|
1626
|
-
var item=this.MainFrame.HorizontalInfo[i];
|
|
1627
|
-
this.HorizontalInfo.push(item);
|
|
1628
|
-
}
|
|
1629
|
-
}
|
|
1630
|
-
else //独立Y轴坐标
|
|
1631
|
-
{
|
|
1632
|
-
if (this.YSplitOperator!=null) this.YSplitOperator.Operator();
|
|
1633
|
-
}
|
|
1634
|
-
}
|
|
1635
|
-
}
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
//缩放因子
|
|
1639
|
-
var ZOOM_SEED = //0=柱子宽度 1=间距
|
|
1640
|
-
[
|
|
1641
|
-
[48, 10], [44, 10],
|
|
1642
|
-
[40, 9], [36, 9],
|
|
1643
|
-
[32, 8], [28, 8],
|
|
1644
|
-
[24, 7], [20, 7],
|
|
1645
|
-
[18, 6], [17, 6],
|
|
1646
|
-
[15, 5], [13, 5],
|
|
1647
|
-
[9, 4], [5, 4], [3, 3],
|
|
1648
|
-
[3, 1], [2,1], [1,1], [1,0]
|
|
1649
|
-
/*
|
|
1650
|
-
[49, 10], [46, 9], [43, 8],
|
|
1651
|
-
[41, 7.5], [39, 7], [37, 6],
|
|
1652
|
-
[31, 5.5], [27, 5], [23, 4.5],
|
|
1653
|
-
[21, 4], [18, 3.5], [16, 3],
|
|
1654
|
-
[13, 2.5], [11, 2], [8, 1.5],
|
|
1655
|
-
[6, 1], [3, 0.6], [2.2, 0.5],
|
|
1656
|
-
*/
|
|
1657
|
-
//太多了卡,
|
|
1658
|
-
//[1.1,0.3],
|
|
1659
|
-
//[0.9,0.2], [0.7,0.15],
|
|
1660
|
-
//[0.6,0.12], [0.5,0.1], [0.4,0.08],
|
|
1661
|
-
//[0.3,0.06], [0.2,0.04], [0.1,0.02]
|
|
1662
|
-
];
|
|
1663
|
-
|
|
1664
|
-
//K线框架
|
|
1665
|
-
function KLineFrame()
|
|
1666
|
-
{
|
|
1667
|
-
this.newMethod = AverageWidthFrame; //派生
|
|
1668
|
-
this.newMethod();
|
|
1669
|
-
delete this.newMethod;
|
|
1670
|
-
|
|
1671
|
-
this.ClassName='KLineFrame';
|
|
1672
|
-
this.ToolbarID = Guid(); //工具条Div id
|
|
1673
|
-
this.ModifyIndex = true; //是否显示'改参数'菜单
|
|
1674
|
-
this.ChangeIndex = true; //是否显示'换指标'菜单
|
|
1675
|
-
this.CustomHorizontalInfo = [];
|
|
1676
|
-
|
|
1677
|
-
this.LastCalculateStatus = { Width: 0, XPointCount: 0 }; //最后一次计算宽度的状态
|
|
1678
|
-
|
|
1679
|
-
//定制X轴刻度
|
|
1680
|
-
//Type:0, Date:, Time: , Name:名字, Line:{ Color:线段颜色, Type:线段类型 0 直线 1 虚线 }
|
|
1681
|
-
//Type: 1, Space: 第几个空白间距, Name:名字, Line: { Color: 线段颜色, Type: 线段类型 0 直线 1 虚线 }
|
|
1682
|
-
this.CustomVerticalInfo = [];
|
|
1683
|
-
this.DrawCustomVerticalEvent;
|
|
1684
|
-
this.RightSpaceCount = 0;
|
|
1685
|
-
|
|
1686
|
-
this.DrawFrame = function ()
|
|
1687
|
-
{
|
|
1688
|
-
if (this.IsMinSize) return;
|
|
1689
|
-
|
|
1690
|
-
this.SplitXYCoordinate();
|
|
1691
|
-
if (this.SizeChange == true) this.CalculateDataWidth();
|
|
1692
|
-
if (this.DrawOtherChart) this.DrawOtherChart();
|
|
1693
|
-
|
|
1694
|
-
this.DrawTitleBG();
|
|
1695
|
-
this.DrawHorizontal();
|
|
1696
|
-
this.DrawVertical();
|
|
1697
|
-
}
|
|
1698
|
-
|
|
1699
|
-
this.GetXFromIndex = function (index)
|
|
1700
|
-
{
|
|
1701
|
-
if (index < 0) index = 0;
|
|
1702
|
-
if (index > this.xPointCount - 1) index = this.xPointCount - 1;
|
|
1703
|
-
|
|
1704
|
-
var offset = this.ChartBorder.GetLeft() + g_JSChartResource.FrameLeftMargin + this.DistanceWidth / 2 + this.DataWidth / 2;
|
|
1705
|
-
for (var i = 1; i <= index; ++i) { offset += this.DistanceWidth + this.DataWidth; }
|
|
1706
|
-
return offset;
|
|
1707
|
-
}
|
|
1708
|
-
|
|
1709
|
-
//X坐标转x轴数值
|
|
1710
|
-
this.GetXData = function (x)
|
|
1711
|
-
{
|
|
1712
|
-
if (x <= this.ChartBorder.GetLeft()) return 0;
|
|
1713
|
-
if (x >= this.ChartBorder.GetRight()) return this.XPointCount-1;
|
|
1714
|
-
|
|
1715
|
-
var left=this.ChartBorder.GetLeft()+g_JSChartResource.FrameLeftMargin;
|
|
1716
|
-
var right=this.ChartBorder.GetRight()-g_JSChartResource.FrameRightMargin;
|
|
1717
|
-
var distanceWidth = this.DistanceWidth;
|
|
1718
|
-
var dataWidth = this.DataWidth;
|
|
1719
|
-
|
|
1720
|
-
var index = 0;
|
|
1721
|
-
var xPoint = left + distanceWidth/2 + dataWidth + distanceWidth;
|
|
1722
|
-
while (xPoint < right && index < 10000 && index+1<this.XPointCount ) //自己算x的数值
|
|
1723
|
-
{
|
|
1724
|
-
if (xPoint > x) break;
|
|
1725
|
-
xPoint += (dataWidth + distanceWidth);
|
|
1726
|
-
++index;
|
|
1727
|
-
}
|
|
1728
|
-
|
|
1729
|
-
//var test=(x-this.ChartBorder.GetLeft())*(this.XPointCount*1.0/this.ChartBorder.GetWidth());
|
|
1730
|
-
return index;
|
|
1731
|
-
}
|
|
1732
|
-
|
|
1733
|
-
this.DrawCustomHorizontal = function () //Y轴刻度定制显示
|
|
1734
|
-
{
|
|
1735
|
-
if (this.IsMinSize) return;
|
|
1736
|
-
for (var i=0; i<this.CustomHorizontalInfo.length; ++i)
|
|
1737
|
-
{
|
|
1738
|
-
var item = this.CustomHorizontalInfo[i];
|
|
1739
|
-
switch (item.Type)
|
|
1740
|
-
{
|
|
1741
|
-
case 0: //最新价格刻度
|
|
1742
|
-
case 1: //固定价格刻度
|
|
1743
|
-
this.DrawCustomItem(item);
|
|
1744
|
-
break;
|
|
1745
|
-
case 2: //当前屏最后一个K线价格刻度
|
|
1746
|
-
case 3: //主图K线涨幅刻度
|
|
1747
|
-
case 4: //叠加K线涨幅刻度
|
|
1748
|
-
this.DrawCustomItem(item);
|
|
1749
|
-
}
|
|
1750
|
-
}
|
|
1751
|
-
}
|
|
1752
|
-
|
|
1753
|
-
this.DrawCustomVerticalItem = function (item) {
|
|
1754
|
-
this.Canvas.save();
|
|
1755
|
-
if (item.Data.Line.Type == 1) this.Canvas.setLineDash([5, 5]); //虚线
|
|
1756
|
-
this.Canvas.strokeStyle = item.Data.Line.Color;
|
|
1757
|
-
this.Canvas.beginPath();
|
|
1758
|
-
if (item.IsHScreen) {
|
|
1759
|
-
this.Canvas.moveTo(item.Top, ToFixedPoint(item.X));
|
|
1760
|
-
this.Canvas.lineTo(item.Bottom, ToFixedPoint(item.X));
|
|
1761
|
-
}
|
|
1762
|
-
else {
|
|
1763
|
-
this.Canvas.moveTo(ToFixedPoint(item.X), item.Top);
|
|
1764
|
-
this.Canvas.lineTo(ToFixedPoint(item.X), item.Bottom);
|
|
1765
|
-
}
|
|
1766
|
-
this.Canvas.stroke();
|
|
1767
|
-
this.Canvas.restore();
|
|
1768
|
-
}
|
|
1769
|
-
|
|
1770
|
-
this.DrawCustomVertical = function () //X轴定制刻度显示
|
|
1771
|
-
{
|
|
1772
|
-
if (!this.CustomVerticalInfo) return;
|
|
1773
|
-
if (this.CustomVerticalInfo.length <= 0) return;
|
|
1774
|
-
if (!this.Data) return;
|
|
1775
|
-
|
|
1776
|
-
var isHScreen = this.IsHScreen;
|
|
1777
|
-
var top = this.ChartBorder.GetTopEx();
|
|
1778
|
-
var bottom = this.ChartBorder.GetBottomEx();
|
|
1779
|
-
|
|
1780
|
-
var dataWidth = this.DataWidth;
|
|
1781
|
-
var distanceWidth = this.DistanceWidth;
|
|
1782
|
-
var xOffset = this.ChartBorder.GetLeft() + distanceWidth / 2.0 + 2.0;
|
|
1783
|
-
|
|
1784
|
-
if (isHScreen)
|
|
1785
|
-
{
|
|
1786
|
-
xOffset = this.ChartBorder.GetTop() + distanceWidth / 2.0 + 2.0;
|
|
1787
|
-
top = this.ChartBorder.GetLeftEx();
|
|
1788
|
-
bottom = this.ChartBorder.GetRightEx();
|
|
1789
|
-
}
|
|
1790
|
-
|
|
1791
|
-
var j = 0;
|
|
1792
|
-
for (var i = this.Data.DataOffset; i < this.Data.Data.length && j < this.XPointCount; ++i, ++j, xOffset += (dataWidth + distanceWidth))
|
|
1793
|
-
{
|
|
1794
|
-
var kItem = this.Data.Data[i];
|
|
1795
|
-
for (var k in this.CustomVerticalInfo)
|
|
1796
|
-
{
|
|
1797
|
-
var item = this.CustomVerticalInfo[k];
|
|
1798
|
-
if (item.Type != 0) continue;
|
|
1799
|
-
|
|
1800
|
-
if (IFrameSplitOperator.IsNumber(item.Time))
|
|
1801
|
-
{
|
|
1802
|
-
if (kItem.Date != item.Date || kItem.Time != item.Time) continue;
|
|
1803
|
-
}
|
|
1804
|
-
else
|
|
1805
|
-
{
|
|
1806
|
-
if (kItem.Date != item.Date) continue;
|
|
1807
|
-
}
|
|
1808
|
-
|
|
1809
|
-
var left = xOffset;
|
|
1810
|
-
var right = xOffset + dataWidth;
|
|
1811
|
-
var x = left + (right - left) / 2;
|
|
1812
|
-
|
|
1813
|
-
var DrawData = { X: x, Top: top, Bottom: bottom, Data: item, IsHScreen: isHScreen };
|
|
1814
|
-
this.DrawCustomVerticalItem(DrawData);
|
|
1815
|
-
if (this.DrawCustomVerticalEvent)
|
|
1816
|
-
this.DrawCustomVerticalEvent.Callback(this.DrawCustomVerticalEvent, DrawData, this);
|
|
1817
|
-
|
|
1818
|
-
break;
|
|
1819
|
-
}
|
|
1820
|
-
}
|
|
1821
|
-
|
|
1822
|
-
for (var i = 1; j < this.XPointCount; ++i, ++j, xOffset += (dataWidth + distanceWidth))
|
|
1823
|
-
{
|
|
1824
|
-
for (var k in this.CustomVerticalInfo)
|
|
1825
|
-
{
|
|
1826
|
-
var item = this.CustomVerticalInfo[k];
|
|
1827
|
-
if (item.Type != 1) continue;
|
|
1828
|
-
if (item.Space != i) continue;
|
|
1829
|
-
|
|
1830
|
-
var left = xOffset;
|
|
1831
|
-
var right = xOffset + dataWidth;
|
|
1832
|
-
var x = left + (right - left) / 2;
|
|
1833
|
-
|
|
1834
|
-
var DrawData = { X: x, Top: top, Bottom: bottom, Data: item, IsHScreen: isHScreen };
|
|
1835
|
-
this.DrawCustomVerticalItem(DrawData);
|
|
1836
|
-
if (this.DrawCustomVerticalEvent)
|
|
1837
|
-
this.DrawCustomVerticalEvent.Callback(this.DrawCustomVerticalEvent, DrawData, this);
|
|
1838
|
-
|
|
1839
|
-
break;
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
|
-
}
|
|
1843
|
-
|
|
1844
|
-
this.CalculateDataWidth = function () //计算数据宽度
|
|
1845
|
-
{
|
|
1846
|
-
if (this.XPointCount < 2) return;
|
|
1847
|
-
var width = this.GetFrameWidth() - g_JSChartResource.FrameMargin; //预留4个像素 防止最后1个柱子不够画
|
|
1848
|
-
|
|
1849
|
-
if (this.ZoomIndex>=0 && this.LastCalculateStatus.Width==width && this.LastCalculateStatus.XPointCount==this.XPointCount) //宽度没变 尝试使用原来的柱子宽度
|
|
1850
|
-
{
|
|
1851
|
-
var caclWidth=(this.DistanceWidth/2+g_JSChartResource.FrameLeftMargin)+(this.DataWidth + this.DistanceWidth)*(this.XPointCount-1);
|
|
1852
|
-
var caclWidth2=(this.DataWidth + this.DistanceWidth) * this.XPointCount;
|
|
1853
|
-
if (caclWidth<= width) //当前的柱子宽度够用 就不调整了
|
|
1854
|
-
return;
|
|
1855
|
-
}
|
|
1856
|
-
|
|
1857
|
-
this.LastCalculateStatus.Width=width;
|
|
1858
|
-
this.LastCalculateStatus.XPointCount=this.XPointCount;
|
|
1859
|
-
|
|
1860
|
-
for (var i = 0; i < ZOOM_SEED.length; ++i)
|
|
1861
|
-
{
|
|
1862
|
-
let barWidth = ZOOM_SEED[i][0]; //数据宽度
|
|
1863
|
-
let distanceWidth = ZOOM_SEED[i][1]; //间距宽度
|
|
1864
|
-
if ((ZOOM_SEED[i][0] + ZOOM_SEED[i][1]) * this.XPointCount < width)
|
|
1865
|
-
{
|
|
1866
|
-
this.ZoomIndex = i;
|
|
1867
|
-
this.DataWidth = ZOOM_SEED[i][0];
|
|
1868
|
-
this.DistanceWidth = ZOOM_SEED[i][1];
|
|
1869
|
-
this.TrimKLineDataWidth(width);
|
|
1870
|
-
|
|
1871
|
-
JSConsole.Chart.Log(`[KLineFrame::CalculateDataWidth] ZoomIndex=${this.ZoomIndex} DataWidth=${this.DataWidth} DistanceWidth=${this.DistanceWidth}` );
|
|
1872
|
-
return;
|
|
1873
|
-
}
|
|
1874
|
-
}
|
|
1875
|
-
|
|
1876
|
-
//太多了 就平均分了
|
|
1877
|
-
this.ZoomIndex = ZOOM_SEED.length - 1;
|
|
1878
|
-
this.DataWidth = width / this.XPointCount;
|
|
1879
|
-
this.DistanceWidth = 0;
|
|
1880
|
-
}
|
|
1881
|
-
|
|
1882
|
-
this.OnSize=function(obj)
|
|
1883
|
-
{
|
|
1884
|
-
var width=this.GetFrameWidth()-g_JSChartResource.FrameMargin;
|
|
1885
|
-
var xPointCount=0;
|
|
1886
|
-
var y=this.DistanceWidth/2+g_JSChartResource.FrameLeftMargin+(this.DataWidth+this.DistanceWidth);
|
|
1887
|
-
for(;y<width; y+=(this.DataWidth+this.DistanceWidth), ++xPointCount) { }
|
|
1888
|
-
|
|
1889
|
-
obj.CurCount=this.XPointCount;
|
|
1890
|
-
obj.CalcCount=xPointCount;
|
|
1891
|
-
obj.DataWidth=this.DataWidth;
|
|
1892
|
-
obj.DistanceWidth=this.DistanceWidth;
|
|
1893
|
-
obj.Changed=false;
|
|
1894
|
-
|
|
1895
|
-
this.LastCalculateStatus.Width=width;
|
|
1896
|
-
if (obj.CurCount==obj.CalcCount) return obj;
|
|
1897
|
-
|
|
1898
|
-
this.XPointCount=xPointCount;
|
|
1899
|
-
this.LastCalculateStatus.XPointCount=this.XPointCount;
|
|
1900
|
-
if (this.Data)
|
|
1901
|
-
{
|
|
1902
|
-
this.Data.DataOffset+=(obj.CurCount-obj.CalcCount);
|
|
1903
|
-
if (this.Data.DataOffset<0) this.Data.DataOffset=0;
|
|
1904
|
-
obj.Changed=true;
|
|
1905
|
-
}
|
|
1906
|
-
return obj;
|
|
1907
|
-
}
|
|
1908
|
-
|
|
1909
|
-
this.SetDataWidth=function(dataWidth)
|
|
1910
|
-
{
|
|
1911
|
-
var zoomIndex=ZOOM_SEED.length-1;
|
|
1912
|
-
for(var i in ZOOM_SEED)
|
|
1913
|
-
{
|
|
1914
|
-
var item=ZOOM_SEED[i];
|
|
1915
|
-
if (item[0]<=dataWidth)
|
|
1916
|
-
{
|
|
1917
|
-
zoomIndex=parseInt(i)-1;
|
|
1918
|
-
break;
|
|
1919
|
-
}
|
|
1920
|
-
}
|
|
1921
|
-
|
|
1922
|
-
this.ZoomIndex=zoomIndex;
|
|
1923
|
-
this.DataWidth=ZOOM_SEED[this.ZoomIndex][0];
|
|
1924
|
-
this.DistanceWidth=ZOOM_SEED[this.ZoomIndex][1];
|
|
1925
|
-
var width=this.GetFrameWidth()-g_JSChartResource.FrameMargin;
|
|
1926
|
-
var xPointCount=0;
|
|
1927
|
-
var y=this.DistanceWidth/2+g_JSChartResource.FrameLeftMargin+(this.DataWidth+this.DistanceWidth);
|
|
1928
|
-
for(;y<=width; y+=(this.DataWidth+this.DistanceWidth), ++xPointCount) { }
|
|
1929
|
-
|
|
1930
|
-
this.XPointCount=xPointCount;
|
|
1931
|
-
this.LastCalculateStatus.XPointCount=this.XPointCount;
|
|
1932
|
-
this.LastCalculateStatus.Width=width;
|
|
1933
|
-
|
|
1934
|
-
var obj={ XPointCount:this.XPointCount, DataWidth:this.DataWidth, DistanceWidth:this.DistanceWidth };
|
|
1935
|
-
return obj;
|
|
1936
|
-
}
|
|
1937
|
-
|
|
1938
|
-
this.TrimKLineDataWidth = function (width)
|
|
1939
|
-
{
|
|
1940
|
-
var zoom = ZOOM_SEED[this.ZoomIndex];
|
|
1941
|
-
var dataWidth = ZOOM_SEED[this.ZoomIndex][0];
|
|
1942
|
-
var distanceWidth = ZOOM_SEED[this.ZoomIndex][1];
|
|
1943
|
-
if (dataWidth == 1 && distanceWidth == 0)
|
|
1944
|
-
{
|
|
1945
|
-
this.DataWidth = width / this.XPointCount;
|
|
1946
|
-
return;
|
|
1947
|
-
}
|
|
1948
|
-
|
|
1949
|
-
while(true)
|
|
1950
|
-
{
|
|
1951
|
-
if((this.DistanceWidth + this.DataWidth) * this.XPointCount + this.DistanceWidth > width)
|
|
1952
|
-
{
|
|
1953
|
-
this.DistanceWidth -= 0.01;
|
|
1954
|
-
break;
|
|
1955
|
-
}
|
|
1956
|
-
this.DistanceWidth += 0.01;
|
|
1957
|
-
}
|
|
1958
|
-
/*
|
|
1959
|
-
if (zoom[0]<4) //最后2个缩放,调整间距不调整数据宽度, 数据都是画竖线的
|
|
1960
|
-
{
|
|
1961
|
-
while (true)
|
|
1962
|
-
{
|
|
1963
|
-
if ((this.DistanceWidth + this.DataWidth) * this.XPointCount + this.DistanceWidth > width)
|
|
1964
|
-
{
|
|
1965
|
-
this.DistanceWidth -= 0.01;
|
|
1966
|
-
break;
|
|
1967
|
-
}
|
|
1968
|
-
this.DistanceWidth += 0.01;
|
|
1969
|
-
}
|
|
1970
|
-
}
|
|
1971
|
-
else
|
|
1972
|
-
{
|
|
1973
|
-
while (true)
|
|
1974
|
-
{
|
|
1975
|
-
if ((this.DistanceWidth + this.DataWidth) * this.XPointCount + this.DistanceWidth > width)
|
|
1976
|
-
{
|
|
1977
|
-
this.DataWidth -= 0.01;
|
|
1978
|
-
break;
|
|
1979
|
-
}
|
|
1980
|
-
this.DataWidth += 0.01;
|
|
1981
|
-
}
|
|
1982
|
-
}
|
|
1983
|
-
*/
|
|
1984
|
-
}
|
|
1985
|
-
|
|
1986
|
-
this.IsOverlayMaxMin = function (obj) //当前坐标信息 是否覆盖最大 最小值输出
|
|
1987
|
-
{
|
|
1988
|
-
if (!this.ChartKLine) return false;
|
|
1989
|
-
if (!this.ChartKLine.Max || !this.ChartKLine.Min) return false;
|
|
1990
|
-
|
|
1991
|
-
var textWidth = this.Canvas.measureText(obj.Text.Value).width + 4; //刻度文字宽度
|
|
1992
|
-
var max = this.ChartKLine.Max, min = this.ChartKLine.Min;
|
|
1993
|
-
var isOverlayMax = false, isOverlayMin = false;
|
|
1994
|
-
const textHeight = 20; //字体高度
|
|
1995
|
-
if (max.X >= obj.X && max.X <= obj.X + textWidth)
|
|
1996
|
-
{
|
|
1997
|
-
var y1 = max.Y + textHeight, y2 = max.Y - textHeight;
|
|
1998
|
-
if ((y1 >= obj.Y - textHeight && y1 <= obj.Y + textHeight) || (y2 >= obj.Y - textHeight && y2 <= obj.Y + textHeight))
|
|
1999
|
-
isOverlayMax = true;
|
|
2000
|
-
}
|
|
2001
|
-
|
|
2002
|
-
if (isOverlayMax == true) return true;
|
|
2003
|
-
|
|
2004
|
-
if (min.X >= obj.X && min.X <= obj.X + textWidth) //最小值X 坐标不在 刻度文字范围内
|
|
2005
|
-
{
|
|
2006
|
-
var y1 = min.Y + textHeight, y2 = min.Y - textHeight;
|
|
2007
|
-
if ((y1 >= obj.Y - textHeight && y1 <= obj.Y + textHeight) || (y2 >= obj.Y - textHeight && y2 <= obj.Y + textHeight))
|
|
2008
|
-
isOverlayMin = true;
|
|
2009
|
-
}
|
|
2010
|
-
|
|
2011
|
-
return isOverlayMax || isOverlayMin;
|
|
2012
|
-
}
|
|
2013
|
-
|
|
2014
|
-
//分割x,y轴坐标信息
|
|
2015
|
-
this.SplitXYCoordinate = function ()
|
|
2016
|
-
{
|
|
2017
|
-
if (this.XYSplit == false)
|
|
2018
|
-
{
|
|
2019
|
-
if (this.XSplit)
|
|
2020
|
-
{
|
|
2021
|
-
if (this.XSplitOperator!=null) this.XSplitOperator.Operator();
|
|
2022
|
-
}
|
|
2023
|
-
return;
|
|
2024
|
-
}
|
|
2025
|
-
|
|
2026
|
-
if (this.YSplitOperator != null) this.YSplitOperator.Operator();
|
|
2027
|
-
if (this.XSplitOperator != null) this.XSplitOperator.Operator();
|
|
2028
|
-
}
|
|
2029
|
-
|
|
2030
|
-
this.CalculateCount = function (zoomIndex)
|
|
2031
|
-
{
|
|
2032
|
-
var width = this.GetFrameWidth() - g_JSChartResource.FrameMargin;
|
|
2033
|
-
return parseInt(width / (ZOOM_SEED[zoomIndex][0] + ZOOM_SEED[zoomIndex][1]));
|
|
2034
|
-
}
|
|
2035
|
-
|
|
2036
|
-
this.ZoomUp = function (cursorIndex)
|
|
2037
|
-
{
|
|
2038
|
-
if (this.ZoomIndex <= 0) return false;
|
|
2039
|
-
if (this.Data.DataOffset < 0) return false;
|
|
2040
|
-
var dataCount = this.Data.Data.length;
|
|
2041
|
-
var maxDataCount = dataCount + this.RightSpaceCount;
|
|
2042
|
-
|
|
2043
|
-
var rightSpaceCount = 0;
|
|
2044
|
-
var lastDataIndex = this.Data.DataOffset + this.XPointCount - 1; //最右边的数据索引
|
|
2045
|
-
var lastCursorIndex = this.Data.DataOffset + cursorIndex.Index;
|
|
2046
|
-
|
|
2047
|
-
if (lastDataIndex >= dataCount)
|
|
2048
|
-
{
|
|
2049
|
-
rightSpaceCount = lastDataIndex - (this.Data.Data.length - 1); //计算右边预留空间
|
|
2050
|
-
lastDataIndex = this.Data.Data.length - 1;
|
|
2051
|
-
if (rightSpaceCount > this.RightSpaceCount) rightSpaceCount = this.RightSpaceCount;
|
|
2052
|
-
}
|
|
2053
|
-
|
|
2054
|
-
var xPointCount = this.CalculateCount(this.ZoomIndex-1);
|
|
2055
|
-
|
|
2056
|
-
--this.ZoomIndex;
|
|
2057
|
-
this.XPointCount = xPointCount;
|
|
2058
|
-
if (cursorIndex.IsLockRight==true) //固定右边
|
|
2059
|
-
{
|
|
2060
|
-
var rightDataIndex=this.Data.DataOffset + this.XPointCount; //最右边的数据索引
|
|
2061
|
-
if (xPointCount>rightDataIndex)
|
|
2062
|
-
{
|
|
2063
|
-
xPointCount=rightDataIndex;
|
|
2064
|
-
this.XPointCount=xPointCount;
|
|
2065
|
-
this.Data.DataOffset=0;
|
|
2066
|
-
}
|
|
2067
|
-
else
|
|
2068
|
-
{
|
|
2069
|
-
var dataOffset=lastDataIndex - (xPointCount-rightSpaceCount)+1;
|
|
2070
|
-
this.XPointCount=xPointCount;
|
|
2071
|
-
this.Data.DataOffset=dataOffset;
|
|
2072
|
-
if (this.Data.DataOffset<0) this.Data.DataOffset=0;
|
|
2073
|
-
}
|
|
2074
|
-
}
|
|
2075
|
-
else if (xPointCount >= maxDataCount)
|
|
2076
|
-
{
|
|
2077
|
-
xPointCount = maxDataCount;
|
|
2078
|
-
this.XPointCount = xPointCount;
|
|
2079
|
-
this.Data.DataOffset = 0;
|
|
2080
|
-
}
|
|
2081
|
-
else
|
|
2082
|
-
{
|
|
2083
|
-
this.XPointCount = xPointCount;
|
|
2084
|
-
this.Data.DataOffset = lastDataIndex - (this.XPointCount - rightSpaceCount) + 1;
|
|
2085
|
-
if (this.Data.DataOffset<0)
|
|
2086
|
-
{
|
|
2087
|
-
JSConsole.Chart.Log(`[KLineFrame::ZoomDown] this.Data.DataOffset=${this.Data.DataOffset}, reset this.Data.DataOffset=0`);
|
|
2088
|
-
this.Data.DataOffset=0;
|
|
2089
|
-
}
|
|
2090
|
-
}
|
|
2091
|
-
|
|
2092
|
-
this.DataWidth = ZOOM_SEED[this.ZoomIndex][0];
|
|
2093
|
-
this.DistanceWidth = ZOOM_SEED[this.ZoomIndex][1];
|
|
2094
|
-
var width = this.GetFrameWidth() - g_JSChartResource.FrameMargin;
|
|
2095
|
-
this.TrimKLineDataWidth(width);
|
|
2096
|
-
|
|
2097
|
-
this.LastCalculateStatus.XPointCount = this.XPointCount;
|
|
2098
|
-
cursorIndex.Index = lastCursorIndex - this.Data.DataOffset;
|
|
2099
|
-
|
|
2100
|
-
return true;
|
|
2101
|
-
}
|
|
2102
|
-
|
|
2103
|
-
this.ZoomDown = function (cursorIndex)
|
|
2104
|
-
{
|
|
2105
|
-
if (this.ZoomIndex + 1 >= ZOOM_SEED.length) return false;
|
|
2106
|
-
if (this.Data.DataOffset < 0) return false;
|
|
2107
|
-
if (this.Data.DataOffset<=0 && cursorIndex.IsLockRight==true) return false;
|
|
2108
|
-
var dataCount = this.Data.Data.length;
|
|
2109
|
-
var maxDataCount = dataCount + this.RightSpaceCount;
|
|
2110
|
-
//if (this.XPointCount >= dataCount) return false;
|
|
2111
|
-
|
|
2112
|
-
var rightSpaceCount = 0;
|
|
2113
|
-
var lastDataIndex = this.Data.DataOffset + this.XPointCount - 1; //最右边的数据索引
|
|
2114
|
-
if (lastDataIndex >= this.Data.Data.length)
|
|
2115
|
-
{
|
|
2116
|
-
rightSpaceCount = lastDataIndex - (this.Data.Data.length - 1); //计算右边预留空间
|
|
2117
|
-
lastDataIndex = this.Data.Data.length - 1;
|
|
2118
|
-
if (rightSpaceCount > this.RightSpaceCount) rightSpaceCount = this.RightSpaceCount;
|
|
2119
|
-
}
|
|
2120
|
-
|
|
2121
|
-
var xPointCount = this.CalculateCount(this.ZoomIndex + 1);
|
|
2122
|
-
var lastCursorIndex = this.Data.DataOffset + cursorIndex.Index;
|
|
2123
|
-
|
|
2124
|
-
++this.ZoomIndex;
|
|
2125
|
-
if (cursorIndex.IsLockRight==true) //固定右边
|
|
2126
|
-
{
|
|
2127
|
-
var rightDataIndex=this.Data.DataOffset + this.XPointCount; //最右边的数据索引
|
|
2128
|
-
if (xPointCount>rightDataIndex)
|
|
2129
|
-
{
|
|
2130
|
-
xPointCount=rightDataIndex;
|
|
2131
|
-
this.XPointCount=xPointCount;
|
|
2132
|
-
this.Data.DataOffset=0;
|
|
2133
|
-
}
|
|
2134
|
-
else
|
|
2135
|
-
{
|
|
2136
|
-
var dataOffset=lastDataIndex - (xPointCount-rightSpaceCount)+1;
|
|
2137
|
-
this.XPointCount=xPointCount;
|
|
2138
|
-
this.Data.DataOffset=dataOffset;
|
|
2139
|
-
if (this.Data.DataOffset<0) this.Data.DataOffset=0;
|
|
2140
|
-
}
|
|
2141
|
-
}
|
|
2142
|
-
else if (xPointCount >= maxDataCount)
|
|
2143
|
-
{
|
|
2144
|
-
//xPointCount = maxDataCount;
|
|
2145
|
-
this.XPointCount = xPointCount;
|
|
2146
|
-
this.Data.DataOffset = 0;
|
|
2147
|
-
}
|
|
2148
|
-
else
|
|
2149
|
-
{
|
|
2150
|
-
this.XPointCount = xPointCount;
|
|
2151
|
-
this.Data.DataOffset = lastDataIndex - (this.XPointCount - rightSpaceCount) + 1;
|
|
2152
|
-
if (this.Data.DataOffset<0)
|
|
2153
|
-
{
|
|
2154
|
-
JSConsole.Chart.Log(`[KLineFrame::ZoomDown] this.Data.DataOffset=${this.Data.DataOffset}, reset this.Data.DataOffset=0`);
|
|
2155
|
-
this.Data.DataOffset=0;
|
|
2156
|
-
}
|
|
2157
|
-
|
|
2158
|
-
}
|
|
2159
|
-
|
|
2160
|
-
this.DataWidth = ZOOM_SEED[this.ZoomIndex][0];
|
|
2161
|
-
this.DistanceWidth = ZOOM_SEED[this.ZoomIndex][1];
|
|
2162
|
-
var width = this.GetFrameWidth() - g_JSChartResource.FrameMargin;
|
|
2163
|
-
this.TrimKLineDataWidth(width);
|
|
2164
|
-
|
|
2165
|
-
this.LastCalculateStatus.XPointCount = this.XPointCount;
|
|
2166
|
-
cursorIndex.Index = lastCursorIndex - this.Data.DataOffset;
|
|
2167
|
-
|
|
2168
|
-
return true;
|
|
2169
|
-
}
|
|
2170
|
-
|
|
2171
|
-
this.GetFrameWidth = function ()
|
|
2172
|
-
{
|
|
2173
|
-
if (this.IsHScreen) return this.ChartBorder.GetHeight();
|
|
2174
|
-
return this.ChartBorder.GetWidth();
|
|
2175
|
-
}
|
|
2176
|
-
|
|
2177
|
-
this.SetXShowCount=function(showCount)
|
|
2178
|
-
{
|
|
2179
|
-
var index=-1;
|
|
2180
|
-
var width=this.GetFrameWidth()-g_JSChartResource.FrameMargin;
|
|
2181
|
-
for(var i=0; i<ZOOM_SEED.length; ++i)
|
|
2182
|
-
{
|
|
2183
|
-
var item=ZOOM_SEED[i];
|
|
2184
|
-
var dataWidth=item[0];
|
|
2185
|
-
var distanceWidth=item[1];
|
|
2186
|
-
var width=this.GetFrameWidth()-g_JSChartResource.FrameMargin-distanceWidth/2;
|
|
2187
|
-
|
|
2188
|
-
var value=parseInt((width-distanceWidth/2)/(dataWidth + distanceWidth));
|
|
2189
|
-
if (value>=showCount)
|
|
2190
|
-
{
|
|
2191
|
-
index=i;
|
|
2192
|
-
this.XPointCount=showCount;
|
|
2193
|
-
this.ZoomIndex=index;
|
|
2194
|
-
this.DataWidth=dataWidth;
|
|
2195
|
-
this.DistanceWidth=distanceWidth;
|
|
2196
|
-
if (dataWidth==1 && distanceWidth==0)
|
|
2197
|
-
this.DataWidth=width/this.XPointCount;
|
|
2198
|
-
this.LastCalculateStatus.XPointCount=this.XPointCount;
|
|
2199
|
-
this.LastCalculateStatus.Width=width;
|
|
2200
|
-
|
|
2201
|
-
return;
|
|
2202
|
-
}
|
|
2203
|
-
}
|
|
2204
|
-
|
|
2205
|
-
//太多了 就平均分了
|
|
2206
|
-
this.XPointCount=showCount;
|
|
2207
|
-
this.ZoomIndex=ZOOM_SEED.length-1;
|
|
2208
|
-
this.DataWidth=width/this.XPointCount;
|
|
2209
|
-
this.DistanceWidth=0;
|
|
2210
|
-
this.LastCalculateStatus.XPointCount=this.XPointCount;
|
|
2211
|
-
this.LastCalculateStatus.Width=width;
|
|
2212
|
-
}
|
|
2213
|
-
}
|
|
2214
|
-
|
|
2215
|
-
//K线横屏框架
|
|
2216
|
-
function KLineHScreenFrame()
|
|
2217
|
-
{
|
|
2218
|
-
this.newMethod = KLineFrame; //派生
|
|
2219
|
-
this.newMethod();
|
|
2220
|
-
delete this.newMethod;
|
|
2221
|
-
|
|
2222
|
-
this.ClassName='KLineHScreenFrame';
|
|
2223
|
-
this.IsHScreen = true; //是否是横屏
|
|
2224
|
-
|
|
2225
|
-
this.DrawInsideHorizontal = function ()
|
|
2226
|
-
{
|
|
2227
|
-
if (this.IsMinSize) return;
|
|
2228
|
-
if (this.IsShowYText[0] === false && this.IsShowYText[1] === false) return;
|
|
2229
|
-
|
|
2230
|
-
var left = this.ChartBorder.GetLeft();
|
|
2231
|
-
var right = this.ChartBorder.GetRightEx();
|
|
2232
|
-
var top = this.ChartBorder.GetTop();
|
|
2233
|
-
var bottom = this.ChartBorder.GetBottom();
|
|
2234
|
-
var borderTop = this.ChartBorder.Top;
|
|
2235
|
-
var borderBottom = this.ChartBorder.Bottom;
|
|
2236
|
-
var titleHeight = this.ChartBorder.TitleHeight;
|
|
2237
|
-
var pixelTatio = 1;
|
|
2238
|
-
|
|
2239
|
-
var isDrawLeft = (borderTop < 10 * pixelTatio || this.YTextPosition[0] == 2) && this.IsShowYText[0] === true;
|
|
2240
|
-
var isDrawRight = (borderBottom < 10 * pixelTatio || this.YTextPosition[1] == 2) && this.IsShowYText[1] === true;
|
|
2241
|
-
|
|
2242
|
-
if (isDrawLeft || isDrawRight)
|
|
2243
|
-
{
|
|
2244
|
-
var yPrev = null; //上一个坐标y的值
|
|
2245
|
-
for (var i = this.HorizontalInfo.length - 1; i >= 0; --i) //从上往下画分割线
|
|
2246
|
-
{
|
|
2247
|
-
var item = this.HorizontalInfo[i];
|
|
2248
|
-
var y = this.GetYFromData(item.Value);
|
|
2249
|
-
if (y != null && yPrev != null && Math.abs(y - yPrev) < this.MinYDistance) continue; //两个坐标在近了 就不画了
|
|
2250
|
-
|
|
2251
|
-
//坐标信息 左边 间距小于10 画在内部
|
|
2252
|
-
if (item.Message[0] != null && isDrawLeft)
|
|
2253
|
-
{
|
|
2254
|
-
if (item.Font != null) this.Canvas.font = item.Font;
|
|
2255
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
2256
|
-
this.Canvas.textAlign = "left";
|
|
2257
|
-
if (y >= right - 2) this.Canvas.textBaseline = 'top';
|
|
2258
|
-
else if (y <= left + 2) this.Canvas.textBaseline = 'bottom';
|
|
2259
|
-
else this.Canvas.textBaseline = "middle";
|
|
2260
|
-
|
|
2261
|
-
var textObj = { X: left, Y: y, Text: { BaseLine: this.Canvas.textBaseline, TextAlign: this.Canvas.textAlign, Font: this.Canvas.font, Value: item.Message[0] } };
|
|
2262
|
-
var xText = y, yText = top;
|
|
2263
|
-
this.Canvas.save();
|
|
2264
|
-
this.Canvas.translate(xText, yText);
|
|
2265
|
-
this.Canvas.rotate(90 * Math.PI / 180);
|
|
2266
|
-
this.Canvas.fillText(item.Message[0], 2, 0);
|
|
2267
|
-
this.Canvas.restore();
|
|
2268
|
-
}
|
|
2269
|
-
|
|
2270
|
-
if (item.Message[1] != null && isDrawRight)
|
|
2271
|
-
{
|
|
2272
|
-
if (item.Font != null) this.Canvas.font = item.Font;
|
|
2273
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
2274
|
-
this.Canvas.textAlign = "right";
|
|
2275
|
-
if (y >= right - 2) this.Canvas.textBaseline = 'top';
|
|
2276
|
-
else if (y <= left + 2) this.Canvas.textBaseline = 'bottom';
|
|
2277
|
-
else this.Canvas.textBaseline = "middle";
|
|
2278
|
-
var textWidth = this.Canvas.measureText(item.Message[1]).width;
|
|
2279
|
-
var textObj = { X: right - textWidth, Y: y, Text: { BaseLine: this.Canvas.textBaseline, TextAlign: this.Canvas.textAlign, Font: this.Canvas.font, Value: item.Message[1] } };
|
|
2280
|
-
|
|
2281
|
-
var xText = y, yText = bottom;
|
|
2282
|
-
this.Canvas.save();
|
|
2283
|
-
this.Canvas.translate(xText, yText);
|
|
2284
|
-
this.Canvas.rotate(90 * Math.PI / 180);
|
|
2285
|
-
this.Canvas.fillText(item.Message[1], -2, 0);
|
|
2286
|
-
this.Canvas.restore();
|
|
2287
|
-
}
|
|
2288
|
-
yPrev = y;
|
|
2289
|
-
}
|
|
2290
|
-
}
|
|
2291
|
-
}
|
|
2292
|
-
|
|
2293
|
-
//画标题背景色
|
|
2294
|
-
this.DrawTitleBG = function ()
|
|
2295
|
-
{
|
|
2296
|
-
/*
|
|
2297
|
-
if (this.ChartBorder.TitleHeight <= 0) return;
|
|
2298
|
-
|
|
2299
|
-
var left = ToFixedPoint(this.ChartBorder.GetRightEx());
|
|
2300
|
-
var top = ToFixedPoint(this.ChartBorder.GetTop());
|
|
2301
|
-
var bottom = ToFixedPoint(this.ChartBorder.GetBottom());
|
|
2302
|
-
var width = this.ChartBorder.TitleHeight;
|
|
2303
|
-
var height = bottom - top;
|
|
2304
|
-
|
|
2305
|
-
this.Canvas.fillStyle = this.TitleBGColor;
|
|
2306
|
-
this.Canvas.fillRect(left, top, width, height);
|
|
2307
|
-
*/
|
|
2308
|
-
}
|
|
2309
|
-
|
|
2310
|
-
this.GetYFromData = function (value)
|
|
2311
|
-
{
|
|
2312
|
-
if (value <= this.HorizontalMin) return this.ChartBorder.GetLeftEx();
|
|
2313
|
-
if (value >= this.HorizontalMax) return this.ChartBorder.GetRightEx();
|
|
2314
|
-
|
|
2315
|
-
var width = this.ChartBorder.GetWidthEx() * (value - this.HorizontalMin) / (this.HorizontalMax - this.HorizontalMin);
|
|
2316
|
-
return this.ChartBorder.GetLeftEx() + width;
|
|
2317
|
-
}
|
|
2318
|
-
|
|
2319
|
-
//画Y轴
|
|
2320
|
-
this.DrawHorizontal = function ()
|
|
2321
|
-
{
|
|
2322
|
-
var top = this.ChartBorder.GetTop();
|
|
2323
|
-
var bottom = this.ChartBorder.GetBottom();
|
|
2324
|
-
var borderTop = this.ChartBorder.Top;
|
|
2325
|
-
var borderBottom = this.ChartBorder.Bottom;
|
|
2326
|
-
var left=this.ChartBorder.GetLeft();
|
|
2327
|
-
|
|
2328
|
-
var yPrev = null; //上一个坐标y的值
|
|
2329
|
-
for (var i = this.HorizontalInfo.length - 1; i >= 0; --i) //从左往右画分割线
|
|
2330
|
-
{
|
|
2331
|
-
var item = this.HorizontalInfo[i];
|
|
2332
|
-
var y = this.GetYFromData(item.Value);
|
|
2333
|
-
if (y != null && Math.abs(y - yPrev) < 15) continue; //两个坐标在近了 就不画了
|
|
2334
|
-
|
|
2335
|
-
if (y!=left)
|
|
2336
|
-
{
|
|
2337
|
-
if (item.LineType==2)
|
|
2338
|
-
{
|
|
2339
|
-
this.Canvas.strokeStyle = item.LineColor;
|
|
2340
|
-
this.Canvas.setLineDash([5,5]); //虚线
|
|
2341
|
-
this.Canvas.beginPath();
|
|
2342
|
-
this.Canvas.moveTo(ToFixedPoint(y),top);
|
|
2343
|
-
this.Canvas.lineTo(ToFixedPoint(y),bottom);
|
|
2344
|
-
this.Canvas.stroke();
|
|
2345
|
-
this.Canvas.setLineDash([]);
|
|
2346
|
-
}
|
|
2347
|
-
else if (item.LineType>0)
|
|
2348
|
-
{
|
|
2349
|
-
this.Canvas.strokeStyle = item.LineColor;
|
|
2350
|
-
if (g_JSChartResource.FrameYLineDash)
|
|
2351
|
-
{
|
|
2352
|
-
this.Canvas.setLineDash(g_JSChartResource.FrameYLineDash); //虚线
|
|
2353
|
-
this.Canvas.beginPath();
|
|
2354
|
-
this.Canvas.moveTo(ToFixedPoint(y),top);
|
|
2355
|
-
this.Canvas.lineTo(ToFixedPoint(y),bottom);
|
|
2356
|
-
this.Canvas.stroke();
|
|
2357
|
-
this.Canvas.setLineDash([]);
|
|
2358
|
-
}
|
|
2359
|
-
else
|
|
2360
|
-
{
|
|
2361
|
-
this.Canvas.beginPath();
|
|
2362
|
-
this.Canvas.moveTo(ToFixedPoint(y), top);
|
|
2363
|
-
this.Canvas.lineTo(ToFixedPoint(y), bottom);
|
|
2364
|
-
this.Canvas.stroke();
|
|
2365
|
-
}
|
|
2366
|
-
}
|
|
2367
|
-
}
|
|
2368
|
-
|
|
2369
|
-
//坐标信息 左边 间距小于10 不画坐标
|
|
2370
|
-
if (item.Message[0] != null && borderTop > 10 && this.IsShowYText[0] === true)
|
|
2371
|
-
{
|
|
2372
|
-
if (item.Font != null) this.Canvas.font = item.Font;
|
|
2373
|
-
|
|
2374
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
2375
|
-
this.Canvas.textAlign = "right";
|
|
2376
|
-
this.Canvas.textBaseline = "middle";
|
|
2377
|
-
|
|
2378
|
-
var xText = y, yText = top;
|
|
2379
|
-
this.Canvas.save();
|
|
2380
|
-
this.Canvas.translate(xText, yText);
|
|
2381
|
-
this.Canvas.rotate(90 * Math.PI / 180);
|
|
2382
|
-
this.Canvas.fillText(item.Message[0], -2, 0);
|
|
2383
|
-
this.Canvas.restore();
|
|
2384
|
-
}
|
|
2385
|
-
|
|
2386
|
-
//坐标信息 右边 间距小于10 不画坐标
|
|
2387
|
-
if (item.Message[1] != null && borderBottom > 10 && this.IsShowYText[1] === true)
|
|
2388
|
-
{
|
|
2389
|
-
if (item.Font != null) this.Canvas.font = item.Font;
|
|
2390
|
-
|
|
2391
|
-
this.Canvas.fillStyle = item.TextColor;
|
|
2392
|
-
this.Canvas.textAlign = "left";
|
|
2393
|
-
this.Canvas.textBaseline = "middle";
|
|
2394
|
-
var xText = y, yText = bottom;
|
|
2395
|
-
this.Canvas.save();
|
|
2396
|
-
this.Canvas.translate(xText, yText);
|
|
2397
|
-
this.Canvas.rotate(90 * Math.PI / 180);
|
|
2398
|
-
this.Canvas.fillText(item.Message[1], 2, 0);
|
|
2399
|
-
this.Canvas.restore();
|
|
2400
|
-
}
|
|
2401
|
-
|
|
2402
|
-
yPrev = y;
|
|
2403
|
-
}
|
|
2404
|
-
}
|
|
2405
|
-
|
|
2406
|
-
this.GetXFromIndex = function (index)
|
|
2407
|
-
{
|
|
2408
|
-
if (index < 0) index = 0;
|
|
2409
|
-
if (index > this.xPointCount - 1) index = this.xPointCount - 1;
|
|
2410
|
-
|
|
2411
|
-
var offset = this.ChartBorder.GetTop() + g_JSChartResource.FrameLeftMargin + this.DistanceWidth / 2 + this.DataWidth / 2;
|
|
2412
|
-
for (var i = 1; i <= index; ++i)
|
|
2413
|
-
{
|
|
2414
|
-
offset += this.DistanceWidth + this.DataWidth;
|
|
2415
|
-
}
|
|
2416
|
-
|
|
2417
|
-
return offset;
|
|
2418
|
-
}
|
|
2419
|
-
|
|
2420
|
-
//画X轴
|
|
2421
|
-
this.DrawVertical = function ()
|
|
2422
|
-
{
|
|
2423
|
-
var left = this.ChartBorder.GetLeft();
|
|
2424
|
-
var right = this.ChartBorder.GetRightTitle();
|
|
2425
|
-
var bottom = this.ChartBorder.GetBottom();
|
|
2426
|
-
|
|
2427
|
-
var xPrev = null; //上一个坐标x的值
|
|
2428
|
-
for (var i in this.VerticalInfo)
|
|
2429
|
-
{
|
|
2430
|
-
var x = this.GetXFromIndex(this.VerticalInfo[i].Value);
|
|
2431
|
-
if (x >= bottom) break;
|
|
2432
|
-
if (xPrev != null && Math.abs(x - xPrev) < 80) continue;
|
|
2433
|
-
var item=this.VerticalInfo[i];
|
|
2434
|
-
if (item.LineType==2)
|
|
2435
|
-
{
|
|
2436
|
-
this.Canvas.setLineDash([5,5]);
|
|
2437
|
-
this.Canvas.beginPath();
|
|
2438
|
-
this.Canvas.moveTo(left, ToFixedPoint(x));
|
|
2439
|
-
this.Canvas.lineTo(right, ToFixedPoint(x));
|
|
2440
|
-
this.Canvas.stroke();
|
|
2441
|
-
this.Canvas.setLineDash([]);
|
|
2442
|
-
}
|
|
2443
|
-
else if (item.LineType>0)
|
|
2444
|
-
{
|
|
2445
|
-
this.Canvas.strokeStyle = item.LineColor;
|
|
2446
|
-
if (g_JSChartResource.FrameXLineDash)
|
|
2447
|
-
{
|
|
2448
|
-
this.Canvas.setLineDash(g_JSChartResource.FrameXLineDash);
|
|
2449
|
-
this.Canvas.beginPath();
|
|
2450
|
-
this.Canvas.moveTo(left, ToFixedPoint(x));
|
|
2451
|
-
this.Canvas.lineTo(right, ToFixedPoint(x));
|
|
2452
|
-
this.Canvas.stroke();
|
|
2453
|
-
this.Canvas.setLineDash([]);
|
|
2454
|
-
}
|
|
2455
|
-
else
|
|
2456
|
-
{
|
|
2457
|
-
this.Canvas.beginPath();
|
|
2458
|
-
this.Canvas.moveTo(left, ToFixedPoint(x));
|
|
2459
|
-
this.Canvas.lineTo(right, ToFixedPoint(x));
|
|
2460
|
-
this.Canvas.stroke();
|
|
2461
|
-
}
|
|
2462
|
-
}
|
|
2463
|
-
|
|
2464
|
-
if (this.VerticalInfo[i].Message[0] != null)
|
|
2465
|
-
{
|
|
2466
|
-
if (this.VerticalInfo[i].Font != null)
|
|
2467
|
-
this.Canvas.font = this.VerticalInfo[i].Font;
|
|
2468
|
-
|
|
2469
|
-
this.Canvas.fillStyle = this.VerticalInfo[i].TextColor;
|
|
2470
|
-
var testWidth = this.Canvas.measureText(this.VerticalInfo[i].Message[0]).width;
|
|
2471
|
-
if (x < testWidth / 2)
|
|
2472
|
-
{
|
|
2473
|
-
this.Canvas.textAlign = "left";
|
|
2474
|
-
this.Canvas.textBaseline = "top";
|
|
2475
|
-
}
|
|
2476
|
-
else
|
|
2477
|
-
{
|
|
2478
|
-
this.Canvas.textAlign = "center";
|
|
2479
|
-
this.Canvas.textBaseline = "top";
|
|
2480
|
-
}
|
|
2481
|
-
|
|
2482
|
-
var xText = left, yText = x;
|
|
2483
|
-
this.Canvas.save();
|
|
2484
|
-
this.Canvas.translate(xText, yText);
|
|
2485
|
-
this.Canvas.rotate(90 * Math.PI / 180);
|
|
2486
|
-
this.Canvas.fillText(this.VerticalInfo[i].Message[0], 0, this.XBottomOffset);
|
|
2487
|
-
this.Canvas.restore();
|
|
2488
|
-
}
|
|
2489
|
-
|
|
2490
|
-
xPrev = x;
|
|
2491
|
-
}
|
|
2492
|
-
}
|
|
2493
|
-
|
|
2494
|
-
//Y坐标转y轴数值
|
|
2495
|
-
this.GetYData = function (x)
|
|
2496
|
-
{
|
|
2497
|
-
if (x < this.ChartBorder.GetLeftEx()) return this.HorizontalMin;
|
|
2498
|
-
if (x > this.ChartBorder.GetRightEx()) return this.HorizontalMax;
|
|
2499
|
-
|
|
2500
|
-
return (x - this.ChartBorder.GetLeftEx()) / this.ChartBorder.GetWidthEx() * (this.HorizontalMax - this.HorizontalMin) + this.HorizontalMin;
|
|
2501
|
-
}
|
|
2502
|
-
|
|
2503
|
-
//X坐标转x轴数值
|
|
2504
|
-
this.GetXData = function (y)
|
|
2505
|
-
{
|
|
2506
|
-
if (y <= this.ChartBorder.GetTop()) return 0;
|
|
2507
|
-
if (y >= this.ChartBorder.GetBottom()) return this.XPointCount-1;
|
|
2508
|
-
|
|
2509
|
-
var distanceWidth=this.DistanceWidth;
|
|
2510
|
-
var dataWidth=this.DataWidth;
|
|
2511
|
-
var left=this.ChartBorder.GetTop()+g_JSChartResource.FrameLeftMargin;
|
|
2512
|
-
var right=this.ChartBorder.GetBottom()-g_JSChartResource.FrameRightMargin;
|
|
2513
|
-
|
|
2514
|
-
var index=0;
|
|
2515
|
-
var xPoint=left+distanceWidth/2+dataWidth+distanceWidth;
|
|
2516
|
-
while(xPoint<right && index<10000 && index+1<this.XPointCount) //自己算x的数值
|
|
2517
|
-
{
|
|
2518
|
-
if (xPoint>=y) break;
|
|
2519
|
-
xPoint+=(dataWidth+distanceWidth);
|
|
2520
|
-
++index;
|
|
2521
|
-
}
|
|
2522
|
-
|
|
2523
|
-
return index;
|
|
2524
|
-
}
|
|
2525
|
-
|
|
2526
|
-
}
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
function OverlayKLineFrame()
|
|
2530
|
-
{
|
|
2531
|
-
this.newMethod=KLineFrame; //派生
|
|
2532
|
-
this.newMethod();
|
|
2533
|
-
delete this.newMethod;
|
|
2534
|
-
|
|
2535
|
-
this.ClassName='OverlayKLineFrame';
|
|
2536
|
-
|
|
2537
|
-
this.MainFrame=null; //主框架
|
|
2538
|
-
this.IsShareY=false; //使用和主框架公用Y轴
|
|
2539
|
-
this.IsCalculateYMaxMin=true; //是否计算Y最大最小值
|
|
2540
|
-
this.RightOffset=50;
|
|
2541
|
-
this.PenBorder=g_JSChartResource.OverlayFrame.BolderPen; //'rgb(0,0,0)'
|
|
2542
|
-
this.IsShow=false; //坐标是否显示
|
|
2543
|
-
this.IsShowToolbar=true; //是否显示工具条
|
|
2544
|
-
this.Title=null;
|
|
2545
|
-
this.TitleColor=g_JSChartResource.OverlayFrame.TitleColor;
|
|
2546
|
-
this.TitleFont=g_JSChartResource.OverlayFrame.TitleFont;
|
|
2547
|
-
|
|
2548
|
-
this.KLineFrame_ReloadResource=this.ReloadResource;
|
|
2549
|
-
this.ReloadResource=function(resource)
|
|
2550
|
-
{
|
|
2551
|
-
this.KLineFrame_ReloadResource(resource);
|
|
2552
|
-
|
|
2553
|
-
if (!resource)
|
|
2554
|
-
{
|
|
2555
|
-
this.PenBorder=g_JSChartResource.OverlayFrame.BolderPen; //'rgb(0,0,0)'
|
|
2556
|
-
this.TitleColor=g_JSChartResource.OverlayFrame.TitleColor;
|
|
2557
|
-
this.TitleFont=g_JSChartResource.OverlayFrame.TitleFont;
|
|
2558
|
-
}
|
|
2559
|
-
}
|
|
2560
|
-
|
|
2561
|
-
this.Draw=function()
|
|
2562
|
-
{
|
|
2563
|
-
this.Buttons=[];
|
|
2564
|
-
if (this.ChartBorder.IsShowTitleOnly) return;
|
|
2565
|
-
this.SplitXYCoordinate();
|
|
2566
|
-
|
|
2567
|
-
if (this.IsShow)
|
|
2568
|
-
{
|
|
2569
|
-
this.DrawVertical();
|
|
2570
|
-
this.DrawHorizontal();
|
|
2571
|
-
}
|
|
2572
|
-
|
|
2573
|
-
this.SizeChange=false;
|
|
2574
|
-
this.XYSplit=false;
|
|
2575
|
-
}
|
|
2576
|
-
|
|
2577
|
-
this.GetScaleTextWidth=function()
|
|
2578
|
-
{
|
|
2579
|
-
return { TextWidth:0 };
|
|
2580
|
-
}
|
|
2581
|
-
|
|
2582
|
-
//分割x,y轴坐标信息
|
|
2583
|
-
this.SplitXYCoordinate=function()
|
|
2584
|
-
{
|
|
2585
|
-
if (this.XYSplit==false) return;
|
|
2586
|
-
|
|
2587
|
-
if (this.IsShareY) //和主图指标共享Y轴坐标
|
|
2588
|
-
{
|
|
2589
|
-
this.HorizontalMax=this.MainFrame.HorizontalMax;
|
|
2590
|
-
this.HorizontalMin=this.MainFrame.HorizontalMin;
|
|
2591
|
-
this.HorizontalInfo=[];
|
|
2592
|
-
for(var i in this.MainFrame.HorizontalInfo)
|
|
2593
|
-
{
|
|
2594
|
-
var item=this.MainFrame.HorizontalInfo[i];
|
|
2595
|
-
this.HorizontalInfo.push(item);
|
|
2596
|
-
}
|
|
2597
|
-
|
|
2598
|
-
this.CoordinateType=this.MainFrame.CoordinateType;
|
|
2599
|
-
}
|
|
2600
|
-
else //独立Y轴坐标
|
|
2601
|
-
{
|
|
2602
|
-
if (this.YSplitOperator!=null) this.YSplitOperator.Operator();
|
|
2603
|
-
}
|
|
2604
|
-
}
|
|
2605
|
-
|
|
2606
|
-
//画Y轴
|
|
2607
|
-
this.DrawHorizontal=function()
|
|
2608
|
-
{
|
|
2609
|
-
var border=this.ChartBorder.GetBorder();
|
|
2610
|
-
var left=border.Left;
|
|
2611
|
-
var right=border.Right;
|
|
2612
|
-
var bottom = border.Bottom;
|
|
2613
|
-
var top = this.ChartBorder.GetTopTitle();
|
|
2614
|
-
var borderRight=this.ChartBorder.Right;
|
|
2615
|
-
right+=this.RightOffset;
|
|
2616
|
-
|
|
2617
|
-
var yPrev=null; //上一个坐标y的值
|
|
2618
|
-
for(var i=this.HorizontalInfo.length-1; i>=0; --i) //从上往下画分割线
|
|
2619
|
-
{
|
|
2620
|
-
var item=this.HorizontalInfo[i];
|
|
2621
|
-
var y=this.GetYFromData(item.Value);
|
|
2622
|
-
if (y!=null && Math.abs(y-yPrev)<this.MinYDistance) continue; //两个坐标在近了 就不画了
|
|
2623
|
-
|
|
2624
|
-
if (y >= bottom - 2) this.Canvas.textBaseline = 'bottom';
|
|
2625
|
-
else if (y <= top + 2) this.Canvas.textBaseline = 'top';
|
|
2626
|
-
else this.Canvas.textBaseline = "middle";
|
|
2627
|
-
|
|
2628
|
-
this.Canvas.strokeStyle=this.PenBorder;
|
|
2629
|
-
this.Canvas.beginPath();
|
|
2630
|
-
this.Canvas.moveTo(right-2,ToFixedPoint(y));
|
|
2631
|
-
this.Canvas.lineTo(right,ToFixedPoint(y));
|
|
2632
|
-
this.Canvas.stroke();
|
|
2633
|
-
|
|
2634
|
-
//坐标信息 右边 间距小于10 不画坐标
|
|
2635
|
-
if (item.Message[1]!=null && borderRight>10)
|
|
2636
|
-
{
|
|
2637
|
-
if (item.Font!=null) this.Canvas.font=item.Font;
|
|
2638
|
-
|
|
2639
|
-
var text=item.Message[1];
|
|
2640
|
-
if (Array.isArray(item.Message[1])) text=item.Message[1][0];
|
|
2641
|
-
|
|
2642
|
-
this.Canvas.fillStyle=item.TextColor;
|
|
2643
|
-
this.Canvas.textAlign="left";
|
|
2644
|
-
this.Canvas.fillText(text,right+2,y);
|
|
2645
|
-
}
|
|
2646
|
-
|
|
2647
|
-
yPrev=y;
|
|
2648
|
-
}
|
|
2649
|
-
}
|
|
2650
|
-
|
|
2651
|
-
//画X轴
|
|
2652
|
-
this.DrawVertical=function()
|
|
2653
|
-
{
|
|
2654
|
-
var border=this.ChartBorder.GetBorder();
|
|
2655
|
-
var top=border.TopEx;
|
|
2656
|
-
//var left=this.ChartBorder.GetLeft();
|
|
2657
|
-
var right=border.Right;
|
|
2658
|
-
var bottom=border.BottomEx;
|
|
2659
|
-
right+=this.RightOffset;
|
|
2660
|
-
|
|
2661
|
-
this.Canvas.strokeStyle=this.PenBorder;
|
|
2662
|
-
this.Canvas.beginPath();
|
|
2663
|
-
this.Canvas.moveTo(ToFixedPoint(right),ToFixedPoint(top));
|
|
2664
|
-
this.Canvas.lineTo(ToFixedPoint(right),ToFixedPoint(bottom));
|
|
2665
|
-
this.Canvas.stroke();
|
|
2666
|
-
}
|
|
2667
|
-
}
|
|
2668
|
-
|
|
2669
|
-
|
|
2670
|
-
function OverlayKLineHScreenFrame()
|
|
2671
|
-
{
|
|
2672
|
-
this.newMethod=KLineHScreenFrame; //派生
|
|
2673
|
-
this.newMethod();
|
|
2674
|
-
delete this.newMethod;
|
|
2675
|
-
|
|
2676
|
-
this.ClassName='OverlayKLineHScreenFrame';
|
|
2677
|
-
this.MainFrame=null; //主框架
|
|
2678
|
-
this.IsShareY=false; //使用和主框架公用Y轴
|
|
2679
|
-
this.IsCalculateYMaxMin=true; //是否计算Y最大最小值
|
|
2680
|
-
this.RightOffset=50;
|
|
2681
|
-
this.PenBorder=g_JSChartResource.OverlayFrame.BolderPen; //'rgb(0,0,0)'
|
|
2682
|
-
this.IsShow=true; //坐标是否显示
|
|
2683
|
-
this.Title=null;
|
|
2684
|
-
this.TitleColor=g_JSChartResource.OverlayFrame.TitleColor;
|
|
2685
|
-
this.TitleFont=g_JSChartResource.OverlayFrame.TitleFont;
|
|
2686
|
-
|
|
2687
|
-
this.Draw=function()
|
|
2688
|
-
{
|
|
2689
|
-
this.SplitXYCoordinate();
|
|
2690
|
-
|
|
2691
|
-
if (this.IsShow)
|
|
2692
|
-
{
|
|
2693
|
-
this.DrawVertical();
|
|
2694
|
-
this.DrawHorizontal();
|
|
2695
|
-
}
|
|
2696
|
-
|
|
2697
|
-
this.SizeChange=false;
|
|
2698
|
-
this.XYSplit=false;
|
|
2699
|
-
}
|
|
2700
|
-
|
|
2701
|
-
//分割x,y轴坐标信息
|
|
2702
|
-
this.SplitXYCoordinate=function()
|
|
2703
|
-
{
|
|
2704
|
-
if (this.XYSplit==false) return;
|
|
2705
|
-
if (this.IsShareY) //和主图指标共享Y轴坐标
|
|
2706
|
-
{
|
|
2707
|
-
this.HorizontalMax=this.MainFrame.HorizontalMax;
|
|
2708
|
-
this.HorizontalMin=this.MainFrame.HorizontalMin;
|
|
2709
|
-
this.HorizontalInfo=[];
|
|
2710
|
-
for(var i=0; i<this.MainFrame.HorizontalInfo.length; ++i)
|
|
2711
|
-
{
|
|
2712
|
-
var item=this.MainFrame.HorizontalInfo[i];
|
|
2713
|
-
this.HorizontalInfo.push(item);
|
|
2714
|
-
}
|
|
2715
|
-
}
|
|
2716
|
-
else
|
|
2717
|
-
{
|
|
2718
|
-
if (this.YSplitOperator!=null) this.YSplitOperator.Operator();
|
|
2719
|
-
}
|
|
2720
|
-
}
|
|
2721
|
-
|
|
2722
|
-
//画Y轴
|
|
2723
|
-
this.DrawHorizontal=function()
|
|
2724
|
-
{
|
|
2725
|
-
|
|
2726
|
-
}
|
|
2727
|
-
|
|
2728
|
-
//画X轴
|
|
2729
|
-
this.DrawVertical=function()
|
|
2730
|
-
{
|
|
2731
|
-
|
|
2732
|
-
}
|
|
2733
|
-
|
|
2734
|
-
this.GetScaleTextWidth=function()
|
|
2735
|
-
{
|
|
2736
|
-
return { TextWidth:0 };
|
|
2737
|
-
}
|
|
2738
|
-
}
|
|
2739
|
-
|
|
2740
|
-
|
|
2741
|
-
|
|
2742
|
-
//深度图框架
|
|
2743
|
-
function DepthChartFrame()
|
|
2744
|
-
{
|
|
2745
|
-
this.newMethod=AverageWidthFrame; //派生
|
|
2746
|
-
this.newMethod();
|
|
2747
|
-
delete this.newMethod;
|
|
2748
|
-
|
|
2749
|
-
this.ScreenImageData; //截图
|
|
2750
|
-
this.Position; //画布的位置
|
|
2751
|
-
this.ClassName="DepthChartFrame";
|
|
2752
|
-
|
|
2753
|
-
//X轴价格 最大,最小
|
|
2754
|
-
this.VerticalRange={ Max:null, Min:null, Center:null, MaxDiffer:null, Differ:null, Step:0.05 };
|
|
2755
|
-
this.AskPrice;
|
|
2756
|
-
this.BidPrice;
|
|
2757
|
-
this.MinZoom=0.05; //最小缩放
|
|
2758
|
-
|
|
2759
|
-
this.SetPriceList=function(aryAskPrice, aryBidPrice)
|
|
2760
|
-
{
|
|
2761
|
-
this.AskPrice=aryAskPrice;
|
|
2762
|
-
this.BidPrice=aryBidPrice;
|
|
2763
|
-
}
|
|
2764
|
-
|
|
2765
|
-
this.SetDrawOtherChart = function (callback) //在画完框架以后调用的扩展画法
|
|
2766
|
-
{
|
|
2767
|
-
|
|
2768
|
-
}
|
|
2769
|
-
|
|
2770
|
-
this.DrawFrame=function()
|
|
2771
|
-
{
|
|
2772
|
-
this.SplitXYCoordinate();
|
|
2773
|
-
this.DrawHorizontal();
|
|
2774
|
-
this.DrawVertical();
|
|
2775
|
-
}
|
|
2776
|
-
|
|
2777
|
-
this.GetXFromIndex=function(value)
|
|
2778
|
-
{
|
|
2779
|
-
var left=this.ChartBorder.GetLeft();
|
|
2780
|
-
var right=this.ChartBorder.GetRight();
|
|
2781
|
-
var width=this.ChartBorder.GetWidth();
|
|
2782
|
-
var offset=width*(value-this.VerticalRange.Min)/(this.VerticalRange.Max-this.VerticalRange.Min);
|
|
2783
|
-
return left+offset;
|
|
2784
|
-
}
|
|
2785
|
-
|
|
2786
|
-
this.GetXData=function(x)
|
|
2787
|
-
{
|
|
2788
|
-
var left=this.ChartBorder.GetLeft();
|
|
2789
|
-
var right=this.ChartBorder.GetRight();
|
|
2790
|
-
var width=this.ChartBorder.GetWidth();
|
|
2791
|
-
|
|
2792
|
-
return (x-left)/width*(this.VerticalRange.Max-this.VerticalRange.Min)+this.VerticalRange.Min;
|
|
2793
|
-
}
|
|
2794
|
-
|
|
2795
|
-
this.GetXFromPrice=function(price)
|
|
2796
|
-
{
|
|
2797
|
-
var isAskPrice=false;
|
|
2798
|
-
var find=this.GetPrice(this.BidPrice, price);
|
|
2799
|
-
if (find==null)
|
|
2800
|
-
{
|
|
2801
|
-
find=this.GetPrice(this.AskPrice, price);
|
|
2802
|
-
isAskPrice=true;
|
|
2803
|
-
}
|
|
2804
|
-
|
|
2805
|
-
if (find==null)
|
|
2806
|
-
{
|
|
2807
|
-
if (this.BidPrice && Array.isArray(this.BidPrice) && this.BidPrice.length>0)
|
|
2808
|
-
{
|
|
2809
|
-
var minPrice=this.BidPrice[0];
|
|
2810
|
-
if (price<minPrice)
|
|
2811
|
-
{
|
|
2812
|
-
isAskPrice=false;
|
|
2813
|
-
find= minPrice;
|
|
2814
|
-
}
|
|
2815
|
-
}
|
|
2816
|
-
}
|
|
2817
|
-
|
|
2818
|
-
if (find==null)
|
|
2819
|
-
{
|
|
2820
|
-
if (this.AskPrice && Array.isArray(this.AskPrice) && this.AskPrice.length>0)
|
|
2821
|
-
{
|
|
2822
|
-
var maxPrice=this.AskPrice[this.AskPrice.length-1];
|
|
2823
|
-
if (price>maxPrice)
|
|
2824
|
-
{
|
|
2825
|
-
isAskPrice=true;
|
|
2826
|
-
find=maxPrice;
|
|
2827
|
-
}
|
|
2828
|
-
}
|
|
2829
|
-
}
|
|
2830
|
-
|
|
2831
|
-
if (find==null) return null;
|
|
2832
|
-
|
|
2833
|
-
var x=this.GetXFromIndex(find);
|
|
2834
|
-
|
|
2835
|
-
return { X:x, Price:find, IsAsk:isAskPrice };
|
|
2836
|
-
}
|
|
2837
|
-
|
|
2838
|
-
this.GetPrice=function(aryPrice, price)
|
|
2839
|
-
{
|
|
2840
|
-
if (!aryPrice || !Array.isArray(aryPrice) || aryPrice.length<=0) return null;
|
|
2841
|
-
|
|
2842
|
-
if (price<aryPrice[0] || price>aryPrice[aryPrice.length-1]) return null;
|
|
2843
|
-
|
|
2844
|
-
var lastPrice=null;
|
|
2845
|
-
for(var i in aryPrice)
|
|
2846
|
-
{
|
|
2847
|
-
var item=aryPrice[i];
|
|
2848
|
-
if (price==item)
|
|
2849
|
-
{
|
|
2850
|
-
return item;
|
|
2851
|
-
}
|
|
2852
|
-
|
|
2853
|
-
if (price<item)
|
|
2854
|
-
return lastPrice;
|
|
2855
|
-
|
|
2856
|
-
lastPrice=item;
|
|
2857
|
-
}
|
|
2858
|
-
}
|
|
2859
|
-
|
|
2860
|
-
//分割x,y轴坐标信息
|
|
2861
|
-
this.SplitXYCoordinate=function()
|
|
2862
|
-
{
|
|
2863
|
-
if (this.XYSplit==false) return;
|
|
2864
|
-
if (this.YSplitOperator!=null) this.YSplitOperator.Operator();
|
|
2865
|
-
if (this.XSplitOperator!=null) this.XSplitOperator.Operator();
|
|
2866
|
-
}
|
|
2867
|
-
|
|
2868
|
-
//图形快照
|
|
2869
|
-
this.Snapshot=function()
|
|
2870
|
-
{
|
|
2871
|
-
this.ScreenImageData=this.Canvas.getImageData(0,0,this.ChartBorder.GetChartWidth(),this.ChartBorder.GetChartHeight());
|
|
2872
|
-
}
|
|
2873
|
-
|
|
2874
|
-
this.SetSizeChage=function(sizeChange)
|
|
2875
|
-
{
|
|
2876
|
-
this.SizeChange=sizeChange;
|
|
2877
|
-
|
|
2878
|
-
//画布的位置
|
|
2879
|
-
this.Position={
|
|
2880
|
-
X:this.ChartBorder.UIElement.offsetLeft,
|
|
2881
|
-
Y:this.ChartBorder.UIElement.offsetTop,
|
|
2882
|
-
W:this.ChartBorder.UIElement.clientWidth,
|
|
2883
|
-
H:this.ChartBorder.UIElement.clientHeight
|
|
2884
|
-
};
|
|
2885
|
-
}
|
|
2886
|
-
|
|
2887
|
-
this.ZoomUp=function() //放大
|
|
2888
|
-
{
|
|
2889
|
-
var xRange=this.VerticalRange;
|
|
2890
|
-
var differ=xRange.Differ;
|
|
2891
|
-
var minDiffer=xRange.MaxDiffer*this.MinZoom;
|
|
2892
|
-
if (differ<minDiffer) return false;
|
|
2893
|
-
|
|
2894
|
-
var offsetDiffer=xRange.Differ*xRange.Step;
|
|
2895
|
-
differ-=offsetDiffer;
|
|
2896
|
-
xRange.Differ=differ;
|
|
2897
|
-
xRange.Min=xRange.Center-xRange.Differ;
|
|
2898
|
-
xRange.Max=xRange.Center+xRange.Differ;
|
|
2899
|
-
|
|
2900
|
-
return true;
|
|
2901
|
-
}
|
|
2902
|
-
|
|
2903
|
-
this.ZoomDown=function() //缩小
|
|
2904
|
-
{
|
|
2905
|
-
var xRange=this.VerticalRange;
|
|
2906
|
-
var differ=xRange.Differ;
|
|
2907
|
-
if (differ==xRange.MaxDiffer) return false;
|
|
2908
|
-
|
|
2909
|
-
var offsetDiffer=xRange.Differ*xRange.Step;
|
|
2910
|
-
differ+=offsetDiffer;
|
|
2911
|
-
if (differ>xRange.MaxDiffer) differ=xRange.MaxDiffer;
|
|
2912
|
-
|
|
2913
|
-
xRange.Differ=differ;
|
|
2914
|
-
xRange.Min=xRange.Center-xRange.Differ;
|
|
2915
|
-
xRange.Max=xRange.Center+xRange.Differ;
|
|
2916
|
-
|
|
2917
|
-
return true;
|
|
2918
|
-
}
|
|
2919
|
-
}
|
|
2920
|
-
|
|
2921
|
-
|
|
2922
|
-
//导出统一使用JSCommon命名空间名
|
|
2923
|
-
export
|
|
2924
|
-
{
|
|
2925
|
-
IChartFramePainting,
|
|
2926
|
-
AverageWidthFrame,
|
|
2927
|
-
|
|
2928
|
-
MinuteFrame,
|
|
2929
|
-
MinuteHScreenFrame,
|
|
2930
|
-
|
|
2931
|
-
OverlayMinuteFrame,
|
|
2932
|
-
OverlayMinuteHScreenFrame,
|
|
2933
|
-
|
|
2934
|
-
OverlayKLineFrame,
|
|
2935
|
-
OverlayKLineHScreenFrame,
|
|
2936
|
-
|
|
2937
|
-
ZOOM_SEED,
|
|
2938
|
-
KLineFrame,
|
|
2939
|
-
KLineHScreenFrame,
|
|
2940
|
-
|
|
2941
|
-
DepthChartFrame,
|
|
2942
|
-
};
|