kLine

来自于:simpleway立即使用

概述

kLine简介

kLine 是一个用于显示股票K线的组件,可以自定义k线颜色,支持动态添加K线数据源。

模块接口

open

显示K线模块

open({params})

params

x:

  • 类型:整形
  • 描述:(可选项)数字类型;模块左上角的 x 坐标(相对于所属的 Window 或 Frame);默认:0。

y:

  • 类型:整形
  • 描述:(可选项)数字类型;模块左上角的 y 坐标(相对于所属的 Window 或 Frame);默认:0。

w:

  • 类型:整形
  • 描述:(可选项)数字类型;模块的宽度;默认:所属的 Window 或 Frame 的宽度。

h:

  • 类型:整形
  • 描述:(可选项)数字类型;模块的高度;默认:所属的 Window 或 Frame 的高度。

option:

  • 类型:JSON 对象
  • 内部字段:
{
    decimalplace: 2,   //(可选项)数字保留几位小数
    borderColor: "#c0c0c0",   //(可选项)边框颜色
    bgColor : "#ffffff",   //(可选项)底色
    rangeColor : "#888888",   //(可选项)量程刻度颜色
    timeRangeColor : "#010101",   //(可选项)时间刻度颜色
    volAreaWeight : 0.15,   //(可选项)vol区域占比重,如果为0,则不显示vol区域
    macdAreaWeight : 0,   //(可选项)macd区域占比重,如果为0,则不显示macd区域
    colorForKlineUp : "#ee524e",   //(可选项)k线涨的颜色
    colorForKlineDown : "#49bd7d",   //(可选项)k线跌的颜色
    selectedItemBgColor : "#1a000000",   //(可选项)选中k线的底色,la是透明度
    isMinute : false,   //(可选项)当前是否是分时的模式
    minuteLineColor : "#35c8b1",   //(可选项)分时线的颜色
    minuteFillColor : "#dfefed",   //(可选项)分时线的填充色
    tipText : ["时间","开","高","低","收","涨跌额","涨跌幅","成交量"],   //选中k线时,对应的标签框的文字
    tipBgColor : "#cb000000",   //(可选项)选中k线时,对应的标签框的底色,cb是透明度
    tipBorderColor : "#bcdef1",   //(可选项)选中k线时,对应的标签框的边框色
    tipTextColor : "#bcdef1",   //(可选项)选中k线时,对应的标签框的文字颜色
    tipTextColorForUp : "#fd8366", //选中k线时,对应的标签框的涨幅颜色
    tipTextColorForDown : "#47f03f", //选中k线时,对应的标签框的跌幅颜色
    macdValueColor : "#0f8988",   //(可选项)显示当前macd值的文字颜色
    difColor : "#49bd7d",   //(可选项)显示当前dif值的文字颜色
    deaColor : "#cf16d2",   //(可选项)显示当前dea值的文字颜色
    macdUpColor : "#ee524e",   //(可选项)macd柱子大于0时的颜色
    macdDownColor : "#49bd7d",   //(可选项)macd柱子小于0时的颜色
    drawDynamicValue : false,   //(可选项)是否显示currentPrice  stopProfit  stopLoss等标签
    stopProfitLossOnTopDown : false,   //(可选项)stopProfit  stopLoss分别分布上下两边,只在drawDynamicValue、isMintue同时为true时起作用
    timeDifference : 0,   //(可选项)时差,时间值要加几分钟显示
    maItems :[5 ,10 ,30],   //(可选项)ma的定义项
    maColors :["#35c8b1", "#e7b574", "#cf16d2"],   //(可选项)ma的定义项对应的颜色
    volMaItems :[5 ,10],   //(可选项)vol ma的定义项
    volMaColors :["#35c8b1", "#e7b574"],   //(可选项)vol ma的定义项对应的颜色
    ma60Color :"#cf16d2",   //(可选项)ma60的颜色
    volTextColor :"#3283c5",   //(可选项)显示当前vol值的文字颜色
    macdConfig :[12,26,9],   //(可选项)macd的定义项
    timeFormat : "MM-dd hh:mm",   //(可选项)时间格式化方式
    currentPriceDescText : "现价",   //(可选项)currentPrice的文字表述,如:现价
    currentPrice : "",   //(可选项)currentPrice的值,如"418.35"
    currentPriceBgColor : "#4186c9",   //(可选项)currentPrice的底色
    currentPriceTextColor : "#ffffff",   //(可选项)currentPrice的文字颜色
    stopProfitDescText : "止盈",   //(可选项)stopProfit的文字表述,如:止盈
    stopProfit : "",   //(可选项)stopProfit的值
    stopProfitTextColor : "#ffffff",   //(可选项)stopProfit的文字颜色
    stopLossDescText : "止损",   //(可选项)stopLoss的文字表述,如:止损
    stopLoss : "",   //(可选项)stopLoss的值
    stopLossTextColor : "#ffffff",   //(可选项)stopLoss的文字颜色
}

示例代码

           var myTipText = [];
           myTipText[0] = "时间";
           myTipText[1] = "开";
           myTipText[2] = "高";
           myTipText[3] = "低";
           myTipText[4] = "收";
           myTipText[5] = "涨跌额";
           myTipText[6] = "涨跌幅";
           myTipText[7] = "成交量";

           var module = api.require('kLine');
           module.open({
               x:0,
               y:0,
               option: {
                   tipText: myTipText,
                   isMinute: false,
                   macdAreaWeight:0.15,
                   volAreaWeight:0.15,
                   drawDynamicValue: true,
                   stopProfitLossOnTopDown:false,
                   currentPriceDescText: "现价",
                   currentPrice: "419.57",
                   stopProfitDescText: "止盈价",
                   stopProfit: "455.23",

                   stopLoss: "430.23",
                   stopLossDescText: "止损价",
               },
           });

           var datas = [{ "open": 418.51, "close": 419.57, "high": 419.57, "low": 418.46, "vol": 8369.2090534990839, "val": 3505077.2667275481, "times": 1533103200000 }, { "open": 416.87, "close": 418.52, "high": 418.9, "low": 415.54, "vol": 58606.517458060189, "val": 24460795.947411776, "times": 1533099600000 }, { "open": 417.92, "close": 416.87, "high": 419.63, "low": 416.01, "vol": 28638.619129601662, "val": 11969192.380628875, "times": 1533096000000 }, { "open": 417.08, "close": 417.94, "high": 418.98, "low": 416.07, "vol": 49071.472226410639, "val": 20492807.97780646, "times": 1533092400000 }, { "open": 415.49, "close": 417.06, "high": 418.11, "low": 411.71, "vol": 37971.236675530774, "val": 15753530.308866542, "times": 1533088800000 }, { "open": 432.11, "close": 415.5, "high": 432.74, "low": 415.5, "vol": 47364.944760170765, "val": 20211243.170410253, "times": 1533085200000 }, { "open": 432.37, "close": 432.11, "high": 434.67, "low": 431.41, "vol": 30516.030626665786, "val": 13212509.957335684, "times": 1533081600000 }, { "open": 430.64, "close": 432.34, "high": 434.55, "low": 427.68, "vol": 38298.416868867607, "val": 16515359.073141795, "times": 1533078000000 }, { "open": 431.77, "close": 430.64, "high": 432.68, "low": 430.36, "vol": 24403.443760044229, "val": 10529032.738700558, "times": 1533074400000 }, { "open": 432.45, "close": 431.77, "high": 433.24, "low": 431.46, "vol": 15248.067522504174, "val": 6589229.3092181645, "times": 1533070800000 }, { "open": 435.07, "close": 432.45, "high": 435.07, "low": 431.23, "vol": 23983.131679237722, "val": 10403873.036601951, "times": 1533067200000 }, { "open": 433.16, "close": 435.07, "high": 435.56, "low": 432.58, "vol": 14797.690592114377, "val": 6423218.2168586841, "times": 1533063600000 }, { "open": 433.25, "close": 433.16, "high": 434.89, "low": 431.43, "vol": 23177.17913893245, "val": 10026261.252959363, "times": 1533060000000 }, { "open": 432.91, "close": 433.25, "high": 436.31, "low": 431.99, "vol": 30780.580509948959, "val": 13347273.393087452, "times": 1533056400000 }, { "open": 430.37, "close": 432.99, "high": 433.0, "low": 429.36, "vol": 32554.903228018506, "val": 14049846.419836465, "times": 1533052800000 }, { "open": 430.87, "close": 430.38, "high": 431.5, "low": 429.24, "vol": 63663.512395347272, "val": 27411646.872351795, "times": 1533049200000 }, { "open": 430.95, "close": 430.84, "high": 433.51, "low": 428.01, "vol": 44289.493008131445, "val": 19100007.28782386, "times": 1533045600000 }, { "open": 433.52, "close": 431.04, "high": 436.57, "low": 430.01, "vol": 157759.05577655043, "val": 68348166.82858406, "times": 1533042000000 }, { "open": 438.38, "close": 433.52, "high": 438.53, "low": 431.11, "vol": 43330.283962554269, "val": 18836177.484242987, "times": 1533038400000 }, { "open": 433.22, "close": 438.38, "high": 440.67, "low": 432.0, "vol": 55502.695174822788, "val": 24226653.027984004, "times": 1533034800000 }, { "open": 445.0, "close": 433.38, "high": 445.81, "low": 433.38, "vol": 53852.045523693683, "val": 23719584.793154437, "times": 1533031200000 }, { "open": 446.24, "close": 444.99, "high": 448.0, "low": 444.0, "vol": 64226.772845435604, "val": 28632969.183816157, "times": 1533027600000 }, { "open": 449.72, "close": 446.18, "high": 449.86, "low": 443.99, "vol": 71595.373710214772, "val": 32011958.885036223, "times": 1533024000000 }, { "open": 450.61, "close": 449.73, "high": 451.53, "low": 449.36, "vol": 41143.472358278479, "val": 18525134.630177241, "times": 1533020400000 }, { "open": 451.69, "close": 450.61, "high": 452.23, "low": 450.61, "vol": 35689.405449624479, "val": 16113228.747842813, "times": 1533016800000 }, { "open": 451.21, "close": 451.68, "high": 451.97, "low": 450.35, "vol": 25138.588395738527, "val": 11343233.022908762, "times": 1533013200000 }, { "open": 451.0, "close": 451.21, "high": 451.43, "low": 448.97, "vol": 70314.246526368472, "val": 31690548.288920116, "times": 1533009600000 }, { "open": 452.49, "close": 451.0, "high": 452.81, "low": 450.85, "vol": 57801.147713315841, "val": 26108639.667460531, "times": 1533006000000 }, { "open": 453.87, "close": 452.49, "high": 454.26, "low": 452.49, "vol": 27152.059147980963, "val": 12314875.411255697, "times": 1533002400000 }, { "open": 455.16, "close": 453.87, "high": 456.0, "low": 453.19, "vol": 28604.751122114514, "val": 12993130.881691054, "times": 1532998800000 }, { "open": 456.67, "close": 455.35, "high": 457.38, "low": 454.59, "vol": 17688.548554756911, "val": 8069648.4585829619, "times": 1532995200000 }, { "open": 455.6, "close": 456.67, "high": 458.32, "low": 455.36, "vol": 20653.736237949714, "val": 9424182.5451025534, "times": 1532991600000 }, { "open": 453.71, "close": 455.54, "high": 456.7, "low": 453.65, "vol": 20498.061656176735, "val": 9328729.6023509949, "times": 1532988000000 }, { "open": 454.44, "close": 453.71, "high": 455.0, "low": 452.27, "vol": 15257.691667009552, "val": 6919597.5557784075, "times": 1532984400000 }, { "open": 454.2, "close": 454.44, "high": 456.3, "low": 451.86, "vol": 20756.924363822745, "val": 9418066.4409540836, "times": 1532980800000 }, { "open": 450.72, "close": 454.05, "high": 455.45, "low": 449.87, "vol": 39068.677011023341, "val": 17704809.713415381, "times": 1532977200000 }, { "open": 448.17, "close": 450.72, "high": 450.73, "low": 446.45, "vol": 60687.053112435715, "val": 27214075.678581025, "times": 1532973600000 }, { "open": 454.85, "close": 448.27, "high": 454.92, "low": 446.92, "vol": 59157.849638092412, "val": 26721976.491319615, "times": 1532970000000 }, { "open": 456.2, "close": 454.85, "high": 456.6, "low": 453.46, "vol": 251242.908688366, "val": 114501441.07504322, "times": 1532966400000 }, { "open": 462.3, "close": 456.2, "high": 462.71, "low": 455.7, "vol": 86268.721887207255, "val": 39675864.926614158, "times": 1532962800000 }, { "open": 459.1, "close": 462.35, "high": 463.0, "low": 459.01, "vol": 34522.141021797455, "val": 15864628.238890046, "times": 1532959200000 }, { "open": 460.33, "close": 459.1, "high": 460.42, "low": 459.01, "vol": 108958.61335868391, "val": 50115633.658789709, "times": 1532955600000 }, { "open": 461.59, "close": 460.33, "high": 461.99, "low": 460.01, "vol": 163721.00861040174, "val": 75392231.945309475, "times": 1532952000000 }, { "open": 461.33, "close": 461.6, "high": 461.78, "low": 460.31, "vol": 57430.886869876886, "val": 26471578.637738917, "times": 1532948400000 }, { "open": 461.14, "close": 461.33, "high": 462.0, "low": 460.77, "vol": 128269.37783068801, "val": 59174013.454519048, "times": 1532944800000 }, { "open": 463.18, "close": 461.03, "high": 463.44, "low": 460.66, "vol": 70512.135589768819, "val": 32590303.430512439, "times": 1532941200000 }, { "open": 464.29, "close": 463.16, "high": 465.03, "low": 462.51, "vol": 52897.579218822611, "val": 24500948.820440523, "times": 1532937600000 }, { "open": 463.12, "close": 464.29, "high": 464.98, "low": 462.26, "vol": 69216.056987725053, "val": 32053983.549501557, "times": 1532934000000 }, { "open": 464.26, "close": 463.13, "high": 464.68, "low": 462.48, "vol": 36997.967351975145, "val": 17154279.656634998, "times": 1532930400000 }, { "open": 464.83, "close": 464.26, "high": 464.91, "low": 463.76, "vol": 106385.67335424892, "val": 49437973.426057816, "times": 1532926800000 }, { "open": 464.67, "close": 464.83, "high": 465.54, "low": 463.45, "vol": 22295.082141287341, "val": 10353131.653767942, "times": 1532923200000 }, { "open": 466.16, "close": 464.67, "high": 467.43, "low": 463.89, "vol": 24992.644101650712, "val": 11637021.987253927, "times": 1532919600000 }, { "open": 466.98, "close": 466.15, "high": 467.13, "low": 465.41, "vol": 23112.374540443765, "val": 10774086.110104084, "times": 1532916000000 }, { "open": 463.28, "close": 466.98, "high": 469.32, "low": 462.0, "vol": 33418.618350238357, "val": 15563596.946475502, "times": 1532912400000 }, { "open": 466.43, "close": 463.28, "high": 467.07, "low": 460.11, "vol": 25623.766025925936, "val": 11854469.912825583, "times": 1532908800000 }, { "open": 465.79, "close": 466.46, "high": 469.79, "low": 465.54, "vol": 20995.324744131241, "val": 9813877.0682090782, "times": 1532905200000 }, { "open": 465.38, "close": 465.79, "high": 465.79, "low": 464.36, "vol": 11105.765640793283, "val": 5165078.8843826354, "times": 1532901600000 }, { "open": 465.51, "close": 465.38, "high": 466.41, "low": 465.01, "vol": 16522.134358846273, "val": 7691858.4033725578, "times": 1532898000000 }, { "open": 466.67, "close": 465.51, "high": 467.54, "low": 465.11, "vol": 17434.111007173655, "val": 8126607.7335544433, "times": 1532894400000 }, { "open": 466.08, "close": 466.67, "high": 468.0, "low": 465.37, "vol": 35587.578546595054, "val": 16590808.649344122, "times": 1532890800000 }, { "open": 465.38, "close": 466.08, "high": 466.5, "low": 465.33, "vol": 90027.745648300581, "val": 41952856.949864037, "times": 1532887200000 }, { "open": 464.21, "close": 465.38, "high": 465.56, "low": 464.12, "vol": 27068.568615116255, "val": 12588873.51512645, "times": 1532883600000 }, { "open": 467.44, "close": 464.21, "high": 467.53, "low": 464.14, "vol": 28954.559292184389, "val": 13470726.215575434, "times": 1532880000000 }, { "open": 466.45, "close": 467.44, "high": 467.79, "low": 465.91, "vol": 27645.048402627941, "val": 12907215.406883696, "times": 1532876400000 }, { "open": 464.06, "close": 466.45, "high": 467.62, "low": 464.05, "vol": 38868.753354565735, "val": 18102044.615925141, "times": 1532872800000 }, { "open": 465.35, "close": 464.06, "high": 466.55, "low": 463.86, "vol": 86810.4927528525, "val": 40330235.93070361, "times": 1532869200000 }, { "open": 464.84, "close": 465.35, "high": 467.33, "low": 463.28, "vol": 85051.6938059519, "val": 39540694.573700123, "times": 1532865600000 }, { "open": 464.25, "close": 464.81, "high": 465.15, "low": 461.66, "vol": 57407.323743908739, "val": 26585407.718235124, "times": 1532862000000 }, { "open": 464.55, "close": 464.25, "high": 465.29, "low": 463.44, "vol": 26414.530597024535, "val": 12268964.569267372, "times": 1532858400000 }, { "open": 464.0, "close": 464.57, "high": 465.57, "low": 463.78, "vol": 38449.566063409075, "val": 17863362.134199124, "times": 1532854800000 }, { "ope