sbd-npm 1.1.45 → 1.1.49
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 +1 -1
- package/summary_daily.js +2 -3
- package/util.js +137 -21
package/package.json
CHANGED
package/summary_daily.js
CHANGED
@@ -31,8 +31,7 @@ $(document).ready(function () {
|
|
31
31
|
},
|
32
32
|
|
33
33
|
load_cache: function () {
|
34
|
-
DailySummary["hsgt_money_flow_chart"] = Util.
|
35
|
-
DailySummary["hsgt_money_flow_chart"].showLoading();
|
34
|
+
DailySummary["hsgt_money_flow_chart"] = Util.show_chart_loading(DailySummary["hsgt_money_flow_chart"], "hsgt_money_flow_line");
|
36
35
|
try {
|
37
36
|
let cache = DailySummary.get_cache();
|
38
37
|
if (cache.hasOwnProperty("market_overview")) {
|
@@ -404,7 +403,7 @@ $(document).ready(function () {
|
|
404
403
|
return d1["value"] > d2["value"] ? -1 : 1;
|
405
404
|
});
|
406
405
|
new_data.forEach(function (item) {
|
407
|
-
let stock_url = "<td title='" + item['code'] + "'><a href='#' data-code='" + item["code"] + "' data-toggle='modal' data-target='.hsgt_stock_detail_modal'>" + item["name"] + "</a></td>"
|
406
|
+
let stock_url = "<td title='" + item['code'] + "'><a href='#' data-code='" + item["code"] + "' data-toggle='modal' data-target='.hsgt_stock_detail_modal'>" + item["name"] + "</a></td>";
|
408
407
|
let buy = "<td title='买入金额-" + item["buy"] + "'>" + Util.to_hundred_million(item["buy"]) + "亿</td>";
|
409
408
|
let sell = "<td title='卖出金额-" + item["sell"] + "'>" + Util.to_hundred_million(item["sell"]) + "亿</td>";
|
410
409
|
let value = "<td>" + Util.to_hundred_million(item["value"]) + "亿</td>";
|
package/util.js
CHANGED
@@ -215,7 +215,7 @@ const Util = {
|
|
215
215
|
* @returns {string}
|
216
216
|
*/
|
217
217
|
industry_url: function (code, industry) {
|
218
|
-
if (industry === "undefined") {
|
218
|
+
if (industry === "undefined" || industry === "None") {
|
219
219
|
return "--";
|
220
220
|
}
|
221
221
|
if (industry) {
|
@@ -752,6 +752,74 @@ const Util = {
|
|
752
752
|
});
|
753
753
|
},
|
754
754
|
|
755
|
+
/**
|
756
|
+
* 初始分类股票的显示表格
|
757
|
+
* @param stock_category
|
758
|
+
* @param table_id
|
759
|
+
*/
|
760
|
+
init_stock_category_data: function (stock_category, table_id) {
|
761
|
+
Util.show_tips("Loading...");
|
762
|
+
let head_cols = [
|
763
|
+
{"name": "代码"},
|
764
|
+
{"name": "名称"},
|
765
|
+
{"name": "PE", "title": "市盈率(Price Earnings Ratio)", "table_sort": 1},
|
766
|
+
{"name": "总市值", "table_sort": 1},
|
767
|
+
{"name": "行业"},
|
768
|
+
{"name": "地区"},
|
769
|
+
{"name": "当前价", "table_sort": 1},
|
770
|
+
{"name": "最高价"},
|
771
|
+
{"name": "最低价"},
|
772
|
+
{"name": "年初至今", "table_sort": 1},
|
773
|
+
{"name": "52周最高", "table_sort": 1}
|
774
|
+
];
|
775
|
+
if (stock_category !== "us") {
|
776
|
+
head_cols.push({"name": "成交金额", "table_sort": 1});
|
777
|
+
head_cols.push({"name": "成交均价"});
|
778
|
+
head_cols.push({"name": "股东数", "table_sort": 1});
|
779
|
+
head_cols.push({"name": "备注", "id": "remark_title"});
|
780
|
+
}
|
781
|
+
Util.init_table_skeleton({
|
782
|
+
"element_id": table_id,
|
783
|
+
"caption": '<caption><span id="index_data"></span><div class="pull-right" id="' + table_id + '_body_tips"></div></caption>',
|
784
|
+
"head_cols": head_cols
|
785
|
+
});
|
786
|
+
Util.post(location.pathname, {active_div: stock_category}, function (j) {
|
787
|
+
let _html = [];
|
788
|
+
let total_num = 0;
|
789
|
+
j["data"].forEach(function (item) {
|
790
|
+
total_num++;
|
791
|
+
_html.push("<tr>");
|
792
|
+
item["code"] = item["code"].toLowerCase();
|
793
|
+
_html = Util.stock_basics_html(_html, item);
|
794
|
+
_html.push("<td id='high_", item["code"], "'>0</td>");
|
795
|
+
_html.push("<td id='low_", item["code"], "'>0</td>");
|
796
|
+
_html.push("<td data-val='", item["year_price"], "' class='year_price_", item["code"], "'>--</td>");
|
797
|
+
_html.push("<td class='high_52week_", item["code"], "'>--</td>");
|
798
|
+
if (stock_category !== "us") {
|
799
|
+
_html.push("<td id='amount_", item["code"], "'>--</td>");
|
800
|
+
_html.push("<td id='average_", item["code"], "'>--</td>");
|
801
|
+
let holder_num = "--";
|
802
|
+
if (item["holder_num"] && item["holder_num"] > 0) {
|
803
|
+
let url = Util.get_url("holder_num") + "?code=" + item["code"];
|
804
|
+
holder_num = Util.pack_html_link(url, Util.digit_compare_trend(item["holder_num"], item["pre_holder_num"]));
|
805
|
+
}
|
806
|
+
_html.push("<td id='holder_", item["code"], "'>", holder_num, "</td>");
|
807
|
+
_html.push("<td id='remark_", item["code"], "'></td>");
|
808
|
+
}
|
809
|
+
_html.push("</tr>");
|
810
|
+
});
|
811
|
+
Util.render_table_html(table_id + "_body", _html);
|
812
|
+
$("#" + table_id + "_body_tips").html('共 <span class="label label-info">' + total_num + '</span> 家');
|
813
|
+
if (j["concept_url"]) {
|
814
|
+
$("#remark_title").html(Util.pack_html_link(j["concept_url"], "备注<i class='glyphicon glyphicon-link'></i>"));
|
815
|
+
}
|
816
|
+
Util.hide_tips();
|
817
|
+
let index_list = j["index_list"] ? j["index_list"] : [];
|
818
|
+
let is_us = stock_category === "us" ? 1 : 0;
|
819
|
+
Util.init_stock_stuff(table_id + "_body", index_list, is_us);
|
820
|
+
});
|
821
|
+
},
|
822
|
+
|
755
823
|
/**
|
756
824
|
* 初始公募基金组件
|
757
825
|
* @param component_id
|
@@ -1026,7 +1094,7 @@ const Util = {
|
|
1026
1094
|
_html.push("</tr>");
|
1027
1095
|
});
|
1028
1096
|
Util.render_table_html(component_id + "_body_body", _html);
|
1029
|
-
$("#" + component_id + "_title").html("[" + Util.stock_url(code, j["stock_name"]) + "]资金流向明细(<span>净买入:<b title='" + summary_inflow + "' class='" + Util.text_color(summary_inflow) + "'>" + Util.to_unit(summary_inflow) + "</b>,
|
1097
|
+
$("#" + component_id + "_title").html("[" + Util.stock_url(code, j["stock_name"]) + "]资金流向明细(<span>净买入:<b title='" + summary_inflow + "' class='" + Util.text_color(summary_inflow) + "'>" + Util.to_unit(summary_inflow) + "</b>, 上榜次数:<b class='text-info'>" + total_times + "</b>, 买入次数:<b class='text-danger'>" + buy_times + "</b>, 卖出次数:<b class='text-success'>" + sell_times + "</b></span>)");
|
1030
1098
|
});
|
1031
1099
|
}
|
1032
1100
|
});
|
@@ -1307,7 +1375,11 @@ const Util = {
|
|
1307
1375
|
return default_val;
|
1308
1376
|
},
|
1309
1377
|
|
1310
|
-
|
1378
|
+
/**
|
1379
|
+
* [为什么要用 setTimeout 模拟 setInterval ?](https://segmentfault.com/a/1190000038829248)
|
1380
|
+
* @param func
|
1381
|
+
* @param timeout
|
1382
|
+
*/
|
1311
1383
|
set_interval: function (func, timeout) {
|
1312
1384
|
let handler = function () {
|
1313
1385
|
func.call(null);
|
@@ -1321,11 +1393,22 @@ const Util = {
|
|
1321
1393
|
// }
|
1322
1394
|
},
|
1323
1395
|
|
1324
|
-
|
1396
|
+
/**
|
1397
|
+
* Base64 编码
|
1398
|
+
* https://baike.baidu.com/item/base64
|
1399
|
+
* @param encode_string
|
1400
|
+
* @returns {string}
|
1401
|
+
*/
|
1402
|
+
base64_encode: function (encode_string) {
|
1325
1403
|
return btoa(encodeURI(encode_string));
|
1326
1404
|
},
|
1327
1405
|
|
1328
|
-
|
1406
|
+
/**
|
1407
|
+
* Base64 解码
|
1408
|
+
* @param base64
|
1409
|
+
* @returns {string}
|
1410
|
+
*/
|
1411
|
+
base64_decode: function (base64) {
|
1329
1412
|
return decodeURI(atob(base64));
|
1330
1413
|
},
|
1331
1414
|
|
@@ -1507,6 +1590,10 @@ const Util = {
|
|
1507
1590
|
});
|
1508
1591
|
},
|
1509
1592
|
|
1593
|
+
/**
|
1594
|
+
* 表格排序
|
1595
|
+
* @param element_id
|
1596
|
+
*/
|
1510
1597
|
table_sort: function (element_id = "") {
|
1511
1598
|
let selector = element_id === "" ? ".table_sort" : ("#" + element_id + " .table_sort");
|
1512
1599
|
$(selector).each(function () {
|
@@ -2347,7 +2434,7 @@ const Util = {
|
|
2347
2434
|
* @param date_type
|
2348
2435
|
*/
|
2349
2436
|
startup_metrics_statistics: function (chart_instance, metrics, date_type) {
|
2350
|
-
chart_instance = Util.
|
2437
|
+
chart_instance = Util.show_chart_loading(chart_instance, metrics + "_bar_canvas");
|
2351
2438
|
$("." + metrics + "_bar_btn").each(function () {
|
2352
2439
|
let d_type = $(this).attr("data-val");
|
2353
2440
|
$(this).removeClass("btn-default");
|
@@ -2407,7 +2494,12 @@ const Util = {
|
|
2407
2494
|
return 0;
|
2408
2495
|
},
|
2409
2496
|
|
2410
|
-
|
2497
|
+
/**
|
2498
|
+
* 初始一个图表实例
|
2499
|
+
* @param element_id
|
2500
|
+
* @returns {*|jQuery|void}
|
2501
|
+
*/
|
2502
|
+
init_chart_instance: function (element_id) {
|
2411
2503
|
let element = document.getElementById(element_id);
|
2412
2504
|
element.style.width = "width:100%";
|
2413
2505
|
if (!element.style.height) {
|
@@ -2424,16 +2516,25 @@ const Util = {
|
|
2424
2516
|
return echarts.init(element);
|
2425
2517
|
},
|
2426
2518
|
|
2427
|
-
|
2519
|
+
/**
|
2520
|
+
* 初始图表加载状态
|
2521
|
+
* @param chart_instance
|
2522
|
+
* @param element_id
|
2523
|
+
* @returns {*|jQuery|void}
|
2524
|
+
*/
|
2525
|
+
show_chart_loading: function (chart_instance, element_id) {
|
2428
2526
|
Util.show_tips("Loading...");
|
2429
2527
|
if (!chart_instance) {
|
2430
|
-
chart_instance = Util.
|
2528
|
+
chart_instance = Util.init_chart_instance(element_id);
|
2431
2529
|
}
|
2432
2530
|
chart_instance.showLoading();
|
2433
2531
|
return chart_instance;
|
2434
2532
|
},
|
2435
2533
|
|
2436
|
-
|
2534
|
+
/**
|
2535
|
+
* 图表描点配置
|
2536
|
+
*/
|
2537
|
+
chart_mark_point: {
|
2437
2538
|
"symbol": "circle",
|
2438
2539
|
"symbolSize": 8,
|
2439
2540
|
"label": {
|
@@ -2445,7 +2546,14 @@ const Util = {
|
|
2445
2546
|
]
|
2446
2547
|
},
|
2447
2548
|
|
2448
|
-
|
2549
|
+
/**
|
2550
|
+
* 在图表上标线
|
2551
|
+
* @param chart_instance
|
2552
|
+
* @param y_val
|
2553
|
+
* @param color
|
2554
|
+
* @returns {*}
|
2555
|
+
*/
|
2556
|
+
chart_mark_line: function (chart_instance, y_val, color = "") {
|
2449
2557
|
color = color === "" ? "#E74C3C" : color;
|
2450
2558
|
chart_instance.setOption({
|
2451
2559
|
series: [{
|
@@ -2462,10 +2570,18 @@ const Util = {
|
|
2462
2570
|
return chart_instance;
|
2463
2571
|
},
|
2464
2572
|
|
2465
|
-
|
2573
|
+
/**
|
2574
|
+
* https://www.chartjs.org/samples/latest/charts/line/basic.html
|
2575
|
+
* @param chart_instance
|
2576
|
+
* @param element_id
|
2577
|
+
* @param x_data
|
2578
|
+
* @param line_data
|
2579
|
+
* @param fill
|
2580
|
+
* @returns {*|jQuery|void}
|
2581
|
+
*/
|
2466
2582
|
chart_basic_line: function (chart_instance, element_id, x_data, line_data, fill = false) {
|
2467
2583
|
if (!chart_instance) {
|
2468
|
-
chart_instance = Util.
|
2584
|
+
chart_instance = Util.init_chart_instance(element_id);
|
2469
2585
|
}
|
2470
2586
|
chart_instance.clear();
|
2471
2587
|
let series_data = [];
|
@@ -2482,7 +2598,7 @@ const Util = {
|
|
2482
2598
|
"itemStyle": {
|
2483
2599
|
"color": color
|
2484
2600
|
},
|
2485
|
-
"markPoint": Util.
|
2601
|
+
"markPoint": Util.chart_mark_point,
|
2486
2602
|
"data": line["data"]
|
2487
2603
|
};
|
2488
2604
|
if (line["label"]) {
|
@@ -2531,7 +2647,7 @@ const Util = {
|
|
2531
2647
|
// https://www.chartjs.org/samples/latest/charts/bar/vertical.html
|
2532
2648
|
chart_basic_bar: function (chart_instance, element_id, x_data, bar_data, bar_title, bar_color_data) {
|
2533
2649
|
if (!chart_instance) {
|
2534
|
-
chart_instance = Util.
|
2650
|
+
chart_instance = Util.init_chart_instance(element_id);
|
2535
2651
|
}
|
2536
2652
|
chart_instance.clear();
|
2537
2653
|
chart_instance.setOption({
|
@@ -2593,7 +2709,7 @@ const Util = {
|
|
2593
2709
|
// https://www.chartjs.org/samples/latest/charts/line/multi-axis.html
|
2594
2710
|
multi_axis_line: function (chart_instance, element_id, x_data, y1_title, y1_data, y2_title, y2_data) {
|
2595
2711
|
if (!chart_instance) {
|
2596
|
-
chart_instance = Util.
|
2712
|
+
chart_instance = Util.init_chart_instance(element_id);
|
2597
2713
|
}
|
2598
2714
|
chart_instance.clear();
|
2599
2715
|
chart_instance.setOption({
|
@@ -2618,7 +2734,7 @@ const Util = {
|
|
2618
2734
|
"itemStyle": {
|
2619
2735
|
"color": "#36A2EB"
|
2620
2736
|
},
|
2621
|
-
"markPoint": Util.
|
2737
|
+
"markPoint": Util.chart_mark_point,
|
2622
2738
|
"data": y1_data
|
2623
2739
|
},
|
2624
2740
|
{
|
@@ -2633,7 +2749,7 @@ const Util = {
|
|
2633
2749
|
"itemStyle": {
|
2634
2750
|
"color": "#FF6384"
|
2635
2751
|
},
|
2636
|
-
"markPoint": Util.
|
2752
|
+
"markPoint": Util.chart_mark_point,
|
2637
2753
|
"data": y2_data,
|
2638
2754
|
"yAxisIndex": 1
|
2639
2755
|
}
|
@@ -2677,7 +2793,7 @@ const Util = {
|
|
2677
2793
|
// https://www.chartjs.org/samples/latest/charts/combo-bar-line.html
|
2678
2794
|
chart_bar_line: function (chart_instance, element_id, x_data, bar_data, bar_title, bar_color_data, line_data, line_title, zoom_start = 0) {
|
2679
2795
|
if (!chart_instance) {
|
2680
|
-
chart_instance = Util.
|
2796
|
+
chart_instance = Util.init_chart_instance(element_id);
|
2681
2797
|
}
|
2682
2798
|
chart_instance.clear();
|
2683
2799
|
let low_bar_index = 0;
|
@@ -2727,7 +2843,7 @@ const Util = {
|
|
2727
2843
|
"itemStyle": {
|
2728
2844
|
"color": "#4DC9F6"
|
2729
2845
|
},
|
2730
|
-
"markPoint": Util.
|
2846
|
+
"markPoint": Util.chart_mark_point,
|
2731
2847
|
"data": line_data
|
2732
2848
|
},
|
2733
2849
|
{
|
@@ -2829,7 +2945,7 @@ const Util = {
|
|
2829
2945
|
|
2830
2946
|
bias_bar_line: function (chart_instance, element_id, x_data, bias120_data, color_data, bias20_data, bias60_data, price_data) {
|
2831
2947
|
if (!chart_instance) {
|
2832
|
-
chart_instance = Util.
|
2948
|
+
chart_instance = Util.init_chart_instance(element_id);
|
2833
2949
|
}
|
2834
2950
|
chart_instance.clear();
|
2835
2951
|
chart_instance.setOption({
|