PageSourceSearch

https://www.sellersprite.com/assets-v2/js/keepa-history-trends.js?v202609241633

js sellersprite.com collected 2026-09-24 09:26:33 UTC 125,626 bytes, 2,894 lines download raw bytes

1$(function () {
2    var FlagPro=window.location.pathname.indexOf("product-research")//选产品
3    var FlagCop=window.location.pathname.indexOf("competitor-lookup")//查竞品
4    var langguage = 'CN';
5    var excelKeepaData = {};
6    var Fn = {
7        node: {
8            charts: [],
9            $body: $("body"),
10            $asinInfo: $("#container-asin-info-other"),
11            modalId: "modal-trend-history-trends",
12            $modalId: $("#modal-trend-history-trends"),
13            trend_sync_loading: 'keepa-sync-loading',
14            xData:[],
15            unitsData:[],
16            pop_tab_info: {
17                bsrRank: '',
18                price: 0,
19                reviews: '',
20                reviewsRating: '',
21                questions: '',
22                availableDate: '',
23            },
24            pop_asinObj:{
25                imageUrl:'',
26                asin:'',
27                brand:'',
28            },
29            popItemData: {
30                asin: '',
31                marketId: '',
32                countryCode: '',
33                marketLabel: '',
34                website: '',
35            },
36            selectedType: '',
37            REVIEW_RATE_UNITS: null,
38            reivewTrendChart: null,
39            commentTrendChart: null,
40            levelCode: '',
41            hide_sales_and_profit: false,
42            salesChart: null, //销量趋势
43            dailyChart: null, //日销量趋势
44            keepaChart: null, //历史趋势
45            keywordCharts: null, //核心关键词
46            qaTrendChart: null, //qa
47            text: {},
48            commentpopNum: '',
49            paramsStart: '',
50            wait_times: 0,
51            wait_time_out: '',
52            is_reversing_page:false,
53            SellerSprite_reverse_chart: 'N',//bsr反向操作
54        },
55        init: function (lang) {
56            let that = this;
57            langguage = lang ? lang : "CN";
58            that.node.SellerSprite_reverse_chart = that.getLocalStorageItem("SellerSprite.ReverseChart") || 'N';
59            //弹窗tab点击
60            $.extend(true, that.node.text, _Text[langguage]);
61            that.node.$modalId.on('click', '.nav-link', function () {
62                that.changeActiveItem($(this).parent().attr('pop-type'));
63                return
64            });
65            // 按年展示
66            $('#container-trend-table').on("click", ".checkbox-switch__input", function () {
67                let isChecked = $('#container-trend-table .checkbox-switch__input').prop('checked');
68                if (isChecked) {
69                    that.parseYearData();
70                } else {
71                    that.loadSalesData();
72                }
73            })
74            //显示弹窗
75            that.node.$body.on("click", ".pop-ele", function () {
76                let $this = $(this),
77                    popType = $(this).attr('pop-type');
78                that.node.popItemData.asin = $(this).attr('data-asin');
79                that.node.popItemData.marketId = $(this).attr('data-marketId');
80                that.node.popItemData.countryCode = $(this).attr('data-publicCode');
81                that.node.popItemData.marketLabel = $(this).attr('data-label');
82                that.node.popItemData.website = $(this).attr('data-website');
83                that.node.is_reversing_page = $(this).attr('data-reversing') == "reversing" ? 'isReversing' : $(this).attr('data-reversing') == "is-weekly" ? 'isWeekly' : false;
84
85                $('#modal-asin').val(that.node.popItemData.asin);
86                $('#modal-marketId').val(that.node.popItemData.marketId);
87                $('#modal-marketLabel').val(that.node.popItemData.marketLabel);
88                GLOBAL_MARKET_ID = that.node.popItemData.marketId;
89                //获取asin
90                let a = $this.attr(`data-available`);
91                let f = $this.attr('data-firstReviewDate');
92                // 优先使用上架时间,其次第一次评论时间
93                let shelfDate = a || f || '--';
94                that.node.pop_tab_info = {
95                    price: $this.attr('data-price'),
96                    reviews: $this.attr('data-reviews'),
97                    reviewsRating: $this.attr('data-reviewsRate'),
98                    questions: $this.attr('data-questions'),
99                    bsrRank: $this.attr('data-bsrRank'),
100                    availableDate: shelfDate === '--' ? shelfDate : moment(shelfDate).format('YYYY-MM-DD'),
101                }
102                that.node.pop_asinObj = {
103                    imageUrl: $this.attr('data-imgUrl'),
104                    asin:$this.attr('data-asin'),
105                    title:$this.attr('data-title')
106                }
107                $this.tooltip("hide");
108                Customer.showSelfModal(that.node.modalId, '95%');
109                that.node.commentpopNum = popType == "comment" ? parseInt($this.attr('pop-num')) : 0;
110                setTimeout(function () {
111                    let clientAdmin = $(".current_client_admin").val();
112                    that.node.levelCode = clientAdmin == "Y" ? ''
112: clientAdmin === "tourists"? 'Ts': $(".current_client_level_code").val();
113                    that.node.hide_sales_and_profit = $(".hide_sales_and_profit").val();
114                    that.changeActiveItem(popType);
115                    that.loadinAsinInfor();
116                }, 0);
117                return
118            });
119            //-------------------keepa 评论趋势图表类型切换---------------------
120            $('#' + this.node.modalId).on('click', '.container-trend-qa-switch>button[data]', function () {
121                $('#container-trend-bsr-subtractMonth').val($(this).attr('data'));
122                $(this).addClass('active').siblings().removeClass('active');
123                //加载BSR趋势数据
124                that.loadqaTrendData();
125            });
126            //-------------------核心关键词趋势 复制关键词---------------------
127            let clipboard = new ClipboardJS('.container-trend-keyword-search-switch>button', {
128                text: function (trigger) {
129                    let v = ''
130                    let option = that.node.keywordCharts.getOption()
131                    if (option && option['legend'] && option['legend'][0] && option['legend'][0]['data']) {
132                        v = option['legend'][0]['data'].join('\r\n')
133                    }
134                    return v;
135                }
136            });
137            clipboard.on('success', function(e) {
138                let $sms = $(e.trigger);
139                $sms.attr('title', that.node.text.tips_copy_success).attr('data-content', that.node.text.tips_copy_success).popover('show');
140                setTimeout(function(){$sms.attr('data-content', '')}, 1000);
141            });
142        },
143        getLocalStorageItem(key){
144           return localStorage.getItem(key);
145        },
146        setLocalStorageItem(key,ReverseChart){
147            localStorage.setItem(key, ReverseChart ? 'Y' : 'N')
148         },
149        changeActiveItem: function (pop_type) {
150            let $modal = $('#' + this.node.modalId),
151                that = this;
152            pop_type = pop_type ? pop_type : 'sales';
153            $modal.find('.nav-item[pop-type=' + pop_type + ']').find(".nav-link").addClass("active").end().siblings().find(".nav-link").removeClass("active");
154            $modal.find('.chart-trends-box .modal-chart').hide().end().find('.' + pop_type + '-trend-chart').show(); //显示图表加载
155            $modal.find('.trend-bsr-tabbtn').removeClass("isActive").end().find('.container-trend-' + pop_type + '-switch').addClass('isActive'); //显示按钮
156            that.node.selectedType = pop_type;
157            that.updateChartSeries();
158        },
159        updateChartSeries: function () {
160            let that = this;
161            switch (that.node.selectedType) {
162                case 'sales':
163                    if (that.node.hide_sales_and_profit != true) {
164                        that.loadSalesData();
165                    }
166                    break;
167                case 'comment':
168                    that.loadCommentTrendData();
169                    break;
170                case 'keyword-search':
171                    that.loadKeyWordSearch();
172                    break;
173                case 'qa':
174                    that.loadqaTrendData();
175                    break;
176                case 'history':
177                    that.initkeepaEchart();
178                    break;
179                default:
180                    that.initkeepaEchart();
181                    break;
182            }
183
184        },
185        //--------------加载keepa 评论趋势数据 start-------------------------
186        loadCommentTrendData: function (asin, marketId, marketLabel) {
187            let chartId = 'container-trend-comment-chart',
188                that = this;
189                var data=''
190                if(FlagCop!=-1){
191                   data={
192                    parentModule:'CL'
193                   }
194                }else if(FlagPro!=-1){
195                    data={
196                        parentModule:'PR'
197                       }
198                }else{
199
200                }
201            //展示加载中
202            that.initReviewRateTrendChart(chartId);
203            $.ajax({
204                type: 'post',
205                url: '/v2/competitor-lookup/' + that.node.popItemData.marketId + "/" + that.node.popItemData.asin,
206                data: data,
207                dataType: 'json',
208                success: function (result) {
209                    that.ReviewRateTrendChartData(result, chartId);
210                },
211                error: function () {
212                }
213            });
214        },
215        initReviewRateTrendChart: function (chartId) {
216            let that = this;
217            Customer.showChartLoading(that.node.reivewTrendChart, chartId);
218            if (that.node.reivewTrendChart) that.node.reivewTrendChart.dis
218pose();
219            that.node.reivewTrendChart = echarts.init(document.getElementById(chartId), 'light');
220            let legend = [that.node.text.comment_legend, that.node.text.comment_rate];
221            let colors = ['#2391FF', '#FF962E'];
222            // 指定图表的配置项和数据
223            let option = {
224                color: colors,
225                tooltip: {
226                    axisPointer: {
227                        type: 'cross',
228                        label: {
229                            backgroundColor: 'rgba(0, 0, 0, .7)',
230                            precision: 0,
231                        }
232                    },
233                    trigger: 'axis',
234                    formatter: that.reviewRateChartToolTip
235                },
236                grid: {
237                    top: 80,
238                    left: '1%',
239                    right: '1%',
240                    bottom: 50,
241                    containLabel: !0
242                },
243                legend: {
244                    data: legend
245                },
246
247                xAxis: {
248                    type: 'category',
249                    axisPointer: {
250                        type: 'shadow'
251                    },
252                    data: [],
253                    axisLabel: {
254                        color: "#8b93a6",
255                        margin: 15,
256                        rotate: 60
257                    },
258                    axisLine: {
259                        lineStyle: {
260                            color: '#eee'
261                        }
262                    },
263                    splitLine: {
264                        show: true,
265                        lineStyle: {
266                            color: ['#eee'],
267                            width: 1,
268                            type: 'dotted'
269                        }
270                    },
271                },
272                yAxis: [{
273                    type: 'value',
274                    name: legend[0],
275                    axisTick: {
276                        alignWithLabel: true
277                    },
278                    axisLine: {
279                        onZero: false,
280                        lineStyle: {
281                            color: colors[0]
282                        }
283                    },
284                    axisLabel: {
285                        formatter: '{value}'
286                    },
287                    splitLine: {
288                        show: true,
289                        lineStyle: {
290                            color: ['#eee'],
291                            width: 1,
292                            type: 'dotted'
293                        }
294                    },
295                },
296                    {
297                        type: 'value',
298                        name: legend[1],
299                        axisTick: {
300                            alignWithLabel: true
301                        },
302                        axisLine: {
303                            onZero: false,
304                            lineStyle: {
305                                color: colors[1]
306                            }
307                        },
308                        axisLabel: {
309                            formatter: '{value}%'
310                        },
311                        splitLine: {
312                            show: true,
313                            lineStyle: {
314                                color: ['#eee'],
315                                width: 1,
316                                type: 'dotted'
317                            }
318                        },
319                    }
320                ],
321                series: [{
322                    name: legend[0],
323                    color: colors[0],
324                    type: 'bar',
325                    smooth: true,
326                    data: [],
327                    yAxisIndex: 0,
328                    barWidth: '30%'
329                },
330                    {
331                        name: legend[1],
332                        color: colors[1],
333                        type: 'line',
334                        data: [],
335                        yAxisIndex: 1
336                    }
337                ]
338            };
339            // 使用刚指定的配置项和数据显示图表。
340            that.node.reivewTrendChart.setOption(option);
341            that.node.reivewTrendChart.resize();
342            that.addChartInstance(that.node.reivewTrendChart);
343        },
344        replaceBlockPointVal: function (arrs) {
345            if (!arrs) return arrs;
346            let vals = [];
347            for (let i in arrs) {
348                if (arrs[i] && -1 !== arrs[i]) {
349                    vals.push(arrs[i]);
350                } else {
351                    vals.push(null);
352                }
353            }
354            return vals;
355        },
356        //留评率数据加载
357        ReviewRateTrendChartData: function (result, chartId, asin, marketLabel) {
358            let that = this;
359            that.node.REVIEW_RATE_UNITS = result.units;
360            let AreaColor = that.getBackGroundColorPrivate(result.daltaMonth, 'Month');
361            Customer.closeChartLoading(that.node.reivewTrendChart)
362            // 指定图表的配置项和数据
363            that.node.reivewTrendChart.setOption({
364                xAxis: {
365                    data: result.daltaMonth,
366                    splitArea: { // 分隔区域
367                        interval: function (index) {
368                            if (index) {
369                                return true;
370                            }
371                        },
372                        show: true,
373                        areaStyle: { // 属性areaStyle(详见areaStyle)控制区域样式
374                            color: AreaColor
375                        }
376                    }
377                },
378                series: [{
379                    data: result.dalta,
380                },
381                    {
382                        data: result.rate
383                    }
384                ]
385            });
386            setTimeout(function () {
387                that.node.reivewTrendChart.setOption({
388                    dataZoom: [{
389                        show: true,
390                        start: result.range.half,
391                        end: 100
392                    }],
393                })
394            }, 0);
395            ($('#' + chartId).find(".prompt-empty").length == 0 && (result.dalta.length <= 0 && result.rate.length <= 0)) ? $('#' + chartId).append('<div class="prompt-empty">' + that.node.text.no_data_msg + '</div>') : "";
396            //关闭加载中
397        },
398        reviewRateChartToolTip: function (value) {
399            let temp = '',
400                that = this,
401                name = Fn.node.text.tips_monthly_sales;
402            if (value) {
403                if (value[0]) {
404                    temp = temp + '<div class="my-tooltip">' +
405                        '<div>' + value[0].axisValue + '</div>' +
406                        '<div>' + '<div class="my-tooltip-mark1" style="background-color: ' + value[0].color + ';"></div>' +
407                        '<span>' + value[0].seriesName + '</span>' +
408                        '<span class="my-tooltip-value">' + Customer.getToolTipValue(value[0].value) + '</span>' +
409                        '</div>';
410                }
411                //单月销量
412                let salesV = '-';
413                if (Fn.node.REVIEW_RATE_UNITS && value[0] && Fn.node.REVIEW_RATE_UNITS[value[0].dataIndex]) salesV = Fn.node.REVIEW_RATE_UNITS[value[0].dataIndex] >=5 ? Customer.getToolTipValue(Fn.node.REVIEW_RATE_UNITS[value[0].dataIndex]):'< 5';
414                temp = temp + '<div>' + '<div class="my-tooltip-mark1" style="background-color: ' + Customer.color[2] + ';"></div>' +
415                    '<span>' + name + '</span>' +
416                    '<span class="my-tooltip-value">' + salesV+ '</span>' +
417                    '</div>';
418                //单月销量
419                if (value.length && value[1]) {
420                    let v = value[1].value === undefined ? "-" : Number(value[1].value).toFixed(2) + "%";
421                    temp = temp + '<div>' + '<div class="my-tooltip-mark2" style="background-color: ' + value[1].color + ';"></div>' +
422                        '<span>' + value[1].seriesName + '</span>' +
423                        '<span class="my-tooltip-value">' + v + '</span>' +
424                        '</div>';
425                }
426                temp = temp + '</div>';
427            }
428            return temp;
429        },
430        //--------------加载keepa 评论趋势数据 end-------------------------
431        //------------- 加载asin详情---------
432        //-------------------加载asin详情--------------
433        loadinAsinInfor: function () {
434            let that = this,
435                tmplId = 'container-trend-sales-tmpl',
436                $modal = $("#" + that.node.modalId),
437                $container = $("#container-trend-table");
438            $modal.find('#container-asin-info').html($('#container-asin-info-tmpl').tmpl({
439                station: that.node.popItemData,
440                asinObj: that.node.pop_asinObj,
441                popInfo: that.node.pop_tab_info
442            }));
443            // table 列表
444            $($container.children('sales')).html($('#' + tmplId).tmpl({
445                station: that.node.popItemData,
446                asinObj: {},
447                levelCode: that.node.levelCode,
448                chartData: [{}],
449                chartLen: 1,
450            }));
451            $container.find('[data-tips]').popover("hide");
452            $('[data-tips]').popover("hide");
453            $modal.find('#container-asin-info [data-toggle="tooltip"]').tooltip();
454            // $.ajax({
455            //     type: 'get',
456            //     url: '/v2/f/' + that.node.popItemData.marketId + '/' + that.node.popItemData.asin,
457            //     data: {},
458            //     dataType: 'json',
459            //     success: function (ajaxResult) {
460            //         if (ajaxResult.code == "OK") {
461            //             let availableDate = "", firstReviewDate = "";
462            //             availableDate = ajaxResult.data.availableDate ? ajaxResult.data.availableDate : '';
463            //             firstReviewDate = ajaxResult.data.firstReviewDate ? ajaxResult.data.firstReviewDate : '';
464            //             if (!availableDate && !firstReviewDate) {
465            //                 ajaxResult.data.availableDate = availableDate > firstReviewDate ? firstReviewDate : availableDate;
466            //             } else {
467            //                 ajaxResult.data.availableDate = availableDate ? availableDate : firstReviewDate ? firstReviewDate : '';
468            //             }
469            //             $modal.find('#container-asin-info').html($('#container-asin-info-tmpl').tmpl({
470            //                 station: that.node.popItemData,
471            //                 asinObj: ajaxResult.data,
472            //                 popInfo: ajaxResult.data
473            //             }));
474
475            //         }
476            //     },
477            //     error: function () {
478            //     }
479            // });
480        },
481        //-------------------end --------------
482        //-----------------------加载销售数据 start----------------------------
483        _sales_init_options: function (colors) {
484            // 指定图表的配置项
485            let that = this,
486                legend = [that.node.text.tips_monthly_sales, that.node.text.tips_monthly_revenue],
487                is_guest = that.node.levelCode == 'G' || that.node.levelCode == 'Ts';
488            return {
489                color: colors,
490                tooltip: {
491                    axisPointer: {
492                        type: 'cross',
493                        label: {
494                            backgroundColor: 'rgba(0, 0, 0, .7)',
495                            precision: 0,
496                        }
497                    },
498                    trigger: 'axis',
499                    formatter: Customer.formatEchartToolTipV3
500                },
501                grid: {
502                    top: 70,
503                    left: (is_guest ? 30 : 10),
504                    right: (is_guest ? 30 : 0),
505                    bottom: 25,
506                    containLabel: true
507                },
508                legend: {
509                    data: legend
510                },
511                xAxis: {
512                    type: 'category',
513                    axisPointer: {
514                        type: 'shadow'
515                    },
516                    data: [],
517                    splitArea: { // 分隔区域
518                        interval: function (index) {
519                            if (index) {
520                                return true;
521                            }
522                        },
523                        show: true,
524                    },
525                    splitLine: {
526                        show: true,
527                        lineStyle: {
528                            color: ['#eee'],
529                            width: 1,
530                            type: 'dotted'
531                        }
532                    },
533                    axisLine: {
534                        lineStyle: {
535                            color: "#e5e5e5"
536                        }
537                    },
538                    axisLabel: {
539                        color: "#8b93a6",
540                        margin: 15,
541                        rotate: 60
542                    }
543                },
544                yAxis: [{
545                    type: 'value',
546                    name: legend[0],
547                    axisTick: {
548                        alignWithLabel: true
549                    },
550                    axisLine: {
551                        onZero: false,
552                        lineStyle: {
553                            color: colors[1]
554                        }
555                    },
556                    axisLabel: {
557                        formatter: '{value}'
558                    },
559                    splitLine: {
560                        show: true,
561                        lineStyle: {
562                            color: ['#eee'],
563                            width: 1,
564                            type: 'dotted'
565                        }
566                    }
567                },
568                    {
569                        type: 'value',
570                        name: legend[1],
571                        axisTick: {
572                            alignWithLabel: true
573                        },
574                        axisLine: {
575                            onZero: false,
576                            lineStyle: {
577                                color: colors[2]
578                            }
579                        },
580                        axisLabel: {
581                            formatter: '{value}'
582                        },
583                        splitLine: {
584                            show: true,
585                            lineStyle: {
586                                color: ['#eee'],
587                                width: 1,
588                                type: 'dotted'
589                            }
590                        }
591                    }
592                ],
593                avoidLabelOverlap: false,
594                series: [{
595                    name: legend[0],
596                    type: 'bar',
597                    color: colors[1],
598                    smooth: true,
599                    data: [],
600                    yAxisIndex: 0,
601                    barWidth: '30%',
602                },
603                    {
604                        name: legend[1],
605                        type: 'line',
606                        color: colors[2],
607                        smooth: true,
608                        data: [],
609                        yAxisIndex: 1
610                    },
611                ]
612            }
613        },
614
615        parseYearData: function() {
616        const { xData, unitsData } = this.node;
617        let that=this
618        let map = new Map();
619        let x = [
620            "1月",
621            "2月",
622            "3月",
623            "4月",
624            "5月",
625            "6月",
626            "7月",
627            "8月",
628            "9月",
629            "10月",
630            "11月",
631            "12月",
632        ];
633        let legend_data = new Set();
634        let series = [];
635        for (let index = 0; index < xData.length; index++) {
636            const element = xData[index];
637            let key = element.substring(0, 4);
638            legend_data.add(key);
639            if (map.has(key)) {
640            let arr = map.get(key);
641            arr.push({
642                date: element,
643                value: unitsData[index],
644            });
645            map.set(key, arr);
646            } else {
647            map.set(key, [
648                {
649                date: element,
650                value: unitsData[index],
651                },
652            ]);
653            }
654        }
655        if (langguage != "CN") {
656            var en_x = [];
657            for (var i in x) {
658            if (i) {
659                en_x.push(
660                moment()
661                    .month(parseInt(i.replace("月", "")))
662                    .locale(langguage == "JP" ? "ja" : 'en')
663                    .format("MMMM")
664                );
665            } else {
666                en_x.push(i);
667            }
668            }
669            x = en_x;
670        }
671        map.forEach((item, key) => {
672            series.push({
673            name: key.toString(),
674            type: "line",
675            smooth: !0,
676            data:that.node.levelCode == 'G' ? []: item == 12 ? item : this.fuillMonth(item),
677            });
678        });
679        legend_data = Array.from(legend_data);
680        legend_data.sort(function (o1, o2) {
681            return parseInt(o1.name) - parseInt(o2.name);
682        });
683        this.node.salesChart.clear();
684        this.loadYearChart(x, legend_data, series);
685        },
686        fuillMonth: function(value) {
687        let full = [];
688        let endDate = moment(value[0].date, "YYYY-MM");
689        const premonths = [...Array(endDate.month()).keys()].map((monthIndex) => {
690            const monthStartDate = moment(endDate)
691            .subtract(monthIndex + 1, "month")
692            .startOf("month");
693            return {
694            date: monthStartDate.format("YYYY-MM"),
695            value: undefined,
696            };
697        });
698
699        return full.concat(premonths.reverse()).concat(value);
700        },
701        getLocaleString:function(val) {
702        if (val || 0 == val) return val.toLocaleString();
703        return "";
704        },
705        loadYearChart: function(_x, legend_data, _series) {
706            let that = this;
707            let options = {
708                tooltip: {
709                axisPointer: {
710                    type: "cross",
711                    label: {
712                    backgroundColor: "rgba(0, 0, 0, .7)",
713                    formatter: (params) => {
714                        var value = Number(params.value);
715                        if (isNaN(value)) {
716                        return params.value;
717                        }
718                        if (value <= 1.0) {
719                        return value.toFixed(2);
720                        } else {
721                        return value.toFixed(0);
722                        }
723                    },
724                    },
725                },
726                trigger: "axis",
727                formatter: function (params) {
728                    let title = "";
729                    title = params[0].axisValue + `${that.lang == "cn" ? "份" : ""}`;
730                    let htmlContent =
731                    '<div class="my-tooltip">' +
732                    `<div>${that.node.text.tips_monthly_sales}: ` +
733                    title +
734                    `</div>`;
735                    params.forEach((element) => {
736                    htmlContent +=
737                        "<div>" +
738                        '<div class="my-tooltip-mark1" style="background-color:' +
739                        element.color +
740                        ' "></div>' +
741                        "<span>" +
742                        element.seriesName +
743                        "</span>" +
744                        '<span class="my-tooltip-value">' +
745                        that.getLocaleString(element.value) +
746                        "</span>" +
747                        "</div>";
748                    });
749                    htmlContent += "</div>";
750                    return htmlContent;
751                },
752                },
753                color: [
754                    "#FFAE2D",
755                    "#5FB0FF",
756                    "#6EC952",
757                    "#909CF7",
758                    "#FF8C45",
759                    "#44CAF6",
760                    "#A9E025",
761                    "#B593EB",
762                    "#FB7A7A",
763                    "#61A1FA",
764                    "#6CE5C2",
765                    "#FC81B4",
766                    "#59EBEA",
767                    "#7CE599",
768                ],
769                legend: {
770                data: legend_data,
771                itemGap: 5,
772                top: 10,
773                },
774                grid: {
775                top: "15%",
776                left: "4%",
777                right: "4%",
778                bottom: "15%",
779                containLabel: true,
780                },
781                xAxis: {
782                type: "category",
783                data: _x,
784                splitLine: {
785                    show: true,
786                    lineStyle: {
787                    color: ["#eee"],
788                    width: 1,
789                    type: "dotted",
790                    },
791                },
792                axisLabel: {
793                    color: "#8b93a6",
794                    margin: 15,
795                },
796                axisLine: {
797                    lineStyle: {
798                    color: "#e5e5e5",
799                    },
800                },
801                },
802                yAxis: {
803                name: that.node.text.tips_monthly_sales,
804                type: "value",
805                splitLine: {
806                    show: true,
807                    lineStyle: {
808                    color: ["#eee"],
809                    width: 1,
810                    type: "dotted",
811                    },
812                },
813                axisLabel: {
814                    color: "#8b93a6",
815                    margin: 15,
816                },
817                axisLine: {
818                    lineStyle: {
819                    color: "#FFAE2D",
820                    },
821                },
822                },
823                series: _series,
824            };
825            that.node.salesChart.setOption(options);
826            that.node.salesChart.resize();
827        },
828        loadSalesData: function () {
829            let that = this,
830                $container = $("#container-trend-table"),
831                $modal = $("#modal-trend-history-trends"),
832
833                tmplId = 'container-trend-sales-tmpl',
834                chartId = 'container-trend-sales-chart',
835                dailyChartId = 'container-month-daily-sales-chart',
836                colors = ['#5FB0FF', '#FFAE2D', '#6EC952', '#909CF7', '#FF8C45', '#44CAF6', '#A9E025', '#B593EB', '#FB7A7A', '#61A1FA', '#6CE5C2', '#FC81B4', '#59EBEA', '#7CE599'];
837            if (that.node.dailyChart) that.node.dailyChart.dispose();
838            if (that.node.salesChart) that.node.salesChart.dispose();
839            $('#'+chartId).html(null);
840            $('#'+dailyChartId).html(null);
841            $('#'+chartId).show();
842            $('#'+dailyChartId).hide();
843            $('#'+dailyChartId).prop('inited',false);
844            $('#container-trend-table .checkbox-switch__input').prop('checked',false)
845            if(FlagCop!=-1){
846                param = {
847                    asin: that.node.popItemData.asin,
848                    marketId: that.node.popItemData.marketId,
849                    parentModule:'CL'
850                }
851            }else if(FlagPro!=-1){
852                param = {
853                    asin: that.node.popItemData.asin,
854                    marketId: that.node.popItemData.marketId,
855                    parentModule:'PR'
856                }
857            }else{
858                param = {
859                    asin: that.node.popItemData.asin,
860                    marketId: that.node.popItemData.marketId,
861                }
862            }
863
864            that.node.salesChart = '';
865            Customer.showChartLoading(that.node.salesChart, chartId, true);
866
867            that.node.salesChart = echarts.init(document.getElementById(chartId), 'light');
868            that.node.salesChart.setOption(that._sales_init_options(colors));
869
870            let prompt_empty_html = that.node.levelCode == 'Ts'? '<div class="prompt-empty">' + that.node.text.tourists_tips  + '<a class="upgrade-member" href="' + that.node.text.login_link + '" target="_blank">'+ that.node.text.tourists_login_link +'</a></div>' : that.node.levelCode == 'G' ? '<div class="prompt-empty">' + that.node.text.limit_tips + '<a class="upgrade-member" href="' + that.node.text.price_link + '" target="_blank">' + that.node.text.upgrade_tips + '</a>' + that.node.text.limit_all + '</div>' : '<div class="prompt-empty">' + that.node.text.no_data_msg + '</div>';
871            $.ajax({
872                type: 'post',
873                url: '/v2/competitor-lookup/chart-monthly.json',
874                data: param,
875                dataType: 'json',
876                success: function (result) {
877                if (result.code != "OK") {
878                        setTimeout(function () {
879                            if (result.code != "OK") {
880                                Customer.closeChartLoading(that.node.salesChart);
881                                $($container.children('sales')).html($('#' + tmplId).tmpl({
882                                    station: '',
883                                    asinObj: {},
884                                    levelCode: that.node.levelCode,
885                                    chartData: [{}],
886                                    chartLen: (that.node.levelCode == 'G' && result.code == "ERR_GLOBAL_LIMIT" ? -1 : 1)
887                                }));
888                                $('#' + chartId).append(prompt_empty_html);
889                                $("[data-tips]").popover("hide");
890                            }
891                        }, 1000)
892                    }
893                    if (result.code == "OK") {
894                        let chartVO = result.data;
895                        let chartData = chartVO.chartData;
896                        //处理map对象
897                        let chartDataArray = (chartData && chartData != {}) ? Customer.mapToArray(chartData) : [];
898                        let reviewsRate = chartDataArray.length>1&&chartDataArray[chartDataArray.length-2].reviewsRate?(chartDataArray[chartDataArray.length-2].reviewsRate)+'%':'--';
899                        if(that.node.is_reversing_page == "isWeekly" && chartVO['asinObj'] && chartVO['asinObj']['availableDate']){
900                            // 处理 asin obj (上架时间) 取
901                            let datimer = null;
902                            if((null != chartVO['asinObj']['availableDate'] && '' != chartVO['asinObj']['availableDate']) && (null != chartVO['asinObj']['firstReviewDate'] && '' != chartVO['asinObj']['firstReviewDate'])){
903                                datimer = chartVO['asinObj']['availableDate'] > chartVO['asinObj']['firstReviewDate'] ? chartVO['asinObj']['firstReviewDate'] : chartVO['asinObj']['availableDate'];
904                            }else{
905                                datimer = (chartVO['asinObj']['availableDate'] || chartVO['asinObj']['firstReviewDate']) || null;
906                            }
907                            that.node.pop_tab_info = {
908                                price: chartVO['asinObj']['price'] || '--',
909                                reviews: chartVO['asinObj']['reviews'] || '
909--',
910                                reviewsRating: reviewsRate || '--',
911                                questions: '--',
912                                bsrRank:chartVO['asinObj']['bsrRank'] || '--',
913                                availableDate: moment(new Date(datimer)).format('YYYY-MM-DD') || '--'
914                            }
915                            $modal.find('#container-asin-info').html($('#container-asin-info-tmpl').tmpl({
916                                station: that.node.popItemData,
917                                asinObj: that.node.pop_asinObj,
918                                popInfo: that.node.pop_tab_info
919                            }));
920                        }
921
922                        //设置滚动条位置
923                        setTimeout(function () {
924                            $modal.find('#container-sales-overflow').scrollLeft(9000);
925                        }, 500);
926                        $modal.find('[data-toggle="tooltip"]').tooltip();
927                        //设置下载地址
928                        $modal.find('#modal-history-export').attr('href', '/v2/competitor-lookup/' + param.marketId + '/' + param.asin + '/export-history-monthly');
929                        $($container.children('sales')).html($('#' + tmplId).tmpl({
930                            station: chartVO.station,
931                            asinObj: chartVO.asinObj,
932                            levelCode: that.node.levelCode,
933                            chartData: chartDataArray,
934                            chartLen: chartDataArray.length
935                        }));
936                        $container.find('[data-tips]').each(tips_popover);
937                        $('[data-tips]').popover("hide");
938                        that.node.is_reversing_page?$modal.find('.poptitle-reviews-rating').text(reviewsRate).addClass(reviewsRate!='--'?'pop-data-s':''):'';
939                        //最少是12个月的维度
940                        let xData = [],
941                            unitsData = [],
942                            amountData = [];
943                        let curMon = '';
944                        if (chartDataArray.length < 12 && chartDataArray.length > 0) {
945                            //占位不足的月份
946                            let format = 'YYYY-MM';
947                            let dataKey = chartDataArray[0].key;
948                            let diffMonth = 12 - chartDataArray.length;
949                            for (let i = diffMonth; i > 0; i--) {
950                                let key = moment(dataKey, format).subtract(i, 'months').format(format);
951                                xData.push(key);
952                                unitsData.push(null);
953                                amountData.push(null);
954                            }
955                        }
956                        that.node.xData=xData
957                        that.node.unitsData=unitsData
958                        for (let i = 0; i < chartDataArray.length; i++) {
959                            let data = chartDataArray[i];
960                            xData.push(data.key);
961                            unitsData.push(data.totalUnits);
962                            amountData.push(data.totalAmount ? parseInt(data.totalAmount, 10) : data.totalAmount);
963                            if (data.curMon) curMon = data.key
964                        }
965                        // 指定图表的配置项和数据
966                        let AreaColor = that.getBackGroundColorPrivate(xData);
967                        let options = {
968                            xAxis: {
969                                data: that.node.levelCode == 'G' ? [] : xData,
970                                splitArea: { // 分隔区域
971                                    areaStyle: { // 属性areaStyle(详见areaStyle)控制区域样式
972                                        color: AreaColor
973                                    }
974                                },
975                            },
976                            series: [{
977                                data: that.node.levelCode == 'G' ? [] : unitsData,
978                                itemStyle: {
979                                    normal: {
980                                        color: function (params) {
981                                            return params.name === curMon ? colors[3] : colors[1];
982                                        }
983                                    }
984                                }
985                            },
986                                {
987                                    data: that.node.levelCode == 'G' ? [] : amountData,
988                                },
989                            ]
990                        };
991                        ($('#' + chartId).find(".prompt-empty").length == 0 && (chartDataArray.length <= 0 || that.node.levelCode == 'G')) ? $('#' + chartId).append(prompt_empty_html) : "";
992                        Customer.closeChartLoading(that.node.salesChart);
993                        // 使用刚指定的配置项和数据显示图表。
994                        that.node.salesChart.setOption(options);
995                        that.node.salesChart.resize();
996                        that.addChartInstance(that.node.salesChart);
997                        $('[cur-mon-sales]').on('click', function () {
998                            that.loadMonDailySales(eval('(' + $(this).attr('cur-mon-sales') + ')'));
999                        });
1000                        that.node.salesChart.on('click', function (params) {
1001                            if (params.name === curMon) $('[cur-mon-sales]').trigger('click');
1002                       });
1003                    }
1004                },
1005                error: function () {
1006                }
1007            });
1008        },
1009        loadMonDailySales: function (data) {
1010            let that = this,
1011                $historySalesChart = $('#container-trend-sales-chart'),
1012                curMonChartId = 'container-month-daily-sales-chart',
1013                $curMonChart = $('#' + curMonChartId),
1014                curMonDates = (new Date()).format('yyyy-MM-dd').split('-'),
1015                colors = ['#6EC952', '#FFAE2D', '#5FB0FF', '#909CF7'];
1016
1017            if ($curMonChart.prop('inited')) {
1018                if ($historySalesChart.is(':hidden')) {
1019                    $curMonChart.hide();
1020                    $historySalesChart.fadeIn();
1021                } else {
1022                    $historySalesChart.hide();
1023                    $curMonChart.fadeIn();
1024                }
1025                return
1026            }
1027            that.node.dailyChart = '';
1028            if (that.node.dailyChart) dailyChart.dispose();
1029            that.node.dailyChart = echarts.init(document.getElementById(curMonChartId), 'light');
1030            $historySalesChart.hide();
1031            $curMonChart.fadeIn();
1032            let legend = [that.node.text.legend_bsr, that.node.text.legend_daily_sales]; //that.node.text.legend_price
1033
1034            let options = {
1035                color: [colors[0], colors[1], colors[2],],
1036                tooltip: {
1037                    axisPointer: {
1038                        type: 'cross',
1039                        label: {
1040                            backgroundColor: 'rgba(0, 0, 0, .7)',
1041                            precision: 0,
1042                        }
1043                    },
1044                    trigger: 'axis',
1045                    formatter: Customer.formatEchartToolTip
1046                },
1047                grid: {
1048                    top: 70,
1049                    left: (that.node.levelCode == 'G' ? 30 : 10),
1050                    right: (that.node.levelCode == 'G' ? 30 : 0),
1051                    bottom: 25,
1052                    containLabel: true
1053                },
1054                legend: {data: legend},
1055                xAxis: {
1056                    type: 'category',
1057                    axisPointer: {
1058                        type: 'shadow'
1059                    },
1060                    data: that.node.levelCode == 'G' ? [] : data.days,
1061                    splitLine: {
1062                        show: true,
1063                        lineStyle: {
1064                            color: ['#eee'],
1065                            width: 1,
1066                            type: 'dotted'
1067                        }
1068                    },
1069                    axisLine: {
1070                        lineStyle: {
1071                            color: "#e5e5e5"
1072                        }
1073                    },
1074                    axisLabel: {
1075                        color: "#8b93a6",
1076                        margin: 15,
1077                        rotate: 60
1078                    }
1079                },
1080                yAxis: [{
1081                    name: legend[0],
1082                    type: 'value',
1083                    inverse: true,
1084                    nameLocation: 'start',
1085                    axisLabel: {color: "#6EC952"},
1086                    splitLine: {lineStyle: {type: "solid", color: "#e5e9f2"}},
1087                    axisLine: {lineStyle: {color: "#6EC952"}}
1088                }, {
1089                    name: legend[1],
1090                    type: 'value',
1091                    show: true,
1092                    nameLocation: 'end',
1093                    axisLabel: {color: "#fb8c1e"},
1094                    splitLine: {show: false},
1095                    axisLine: {lineStyle: {color: "#fb8c1e"}}
1096                },
1097                ],
1098                series: [
1099                    {
1100                        id: 'bsr',
1101                        name: legend[0],
1102                        type: 'line',
1103                        step: 'middle',
1104                        data: that.node.levelCode == 'G' ? [] : data.bsrs
1105                    },
1106                    {
1107                        id: 'sales',
1108                        name: legend[1],
1109                        type: 'bar',
1110                        yAxisIndex: 1,
1111                        barWidth: '30%',
1112                        data: that.node.levelCode == 'G' ? [] : data.sales,
1113                        itemStyle: {
1114                            normal: {
1115                                color: function (params) {
1116                                    let dates = params.name.split("/");
1117                                    return dates[0] === curMonDates[0] && dates[1] === curMonDates[1] ? colors[3] : colors[1];
1118                                }
1119                            }
1120                        }
1121                    },
1122                ]
1123            };
1124            if (data.mas && data.mas.length > 0) {
1125                options.series.push({
1126                  data: that.node.levelCode == 'G' ? [] : data.mas,
1127                  name: that.node.text.legend_average_daily_sales,
1128                  markPoint: {
1129                    itemStyle: {
1130                      color: 'transparent',
1131                    },
1132                    data: [
1133                      {
1134                        coord: that.node.levelCode == 'G' ? [] : data.mas[data.mas.length - 1],
1135                      },
1136                    ],
1137                  },
1138                  z: 1,
1139                  yAxisIndex: 1,
1140                  type: 'line',
1141                  symbol: 'circle',
1142                  showSymbol: false,
1143                  smooth: true,
1144                  itemStyle: {
1145                    normal: {
1146                      color: '#C2C7CD',
1147                      lineStyle: {
1148                        color: '#C2C7CD',
1149                      },
1150                    },
1151                  },
1152                });
1153                options.legend.data.push(that.node.text.legend_average_daily_sales);
1154              }
1155
1156            that.node.dailyChart.setOption(options);
1157            that.node.dailyChart.resize();
1158
1159            that.addChartInstance(that.node.dailyChart);
1160
1161            $curMonChart.prop('inited', true);
1162            that.node.dailyChart.on('click', function (params) {
1163                $('[cur-mon-sales]').trigger('click');
1164            });
1165
1166        },
1167        //-----------------------加载销售数据----------------------------
1168        // --------------------------历史趋势 start
1169        initkeepaEchart: function () {
1170            let that = this;
1171            that.loadkeepaChart();
1172            that.keepa_require_datas(function (rslt) {
1173              that._check_sync_update_keepa_data(that, rslt)
1174            });
1175        },
1176        keepa_require_datas: function (cb) {
1177            let that = this;
1178            if(FlagCop!=-1){
1179                url="/v2/keepa/subTrend/" + that.node.popItemData.marketId + "/" + that.node.popItemData.asin + "?_v=" + new Date().getTime()+'&parentModule=CL'
1180            }else if(FlagPro!=-1){
1181                url="/v2/keepa/subTrend/" + that.node.popItemData.marketId + "/" + that.node.popItemData.asin + "?_v=" + new Date().getTime()+'&parentModule=PR'
1182            }else{
1183                url="/v2/keepa/subTrend/" + that.node.popItemData.marketId + "/" + that.node.popItemData.asin + "?_v=" + new Date().getTime()
1184            }
1185
1186            $.ajax({
1187                type: 'GET',
1188                url: url,
1189                dataType: 'json',
1190                success: function (result) {
1191                    if (cb) cb(result);
1192
1193                }
1194            });
1195        },
1196        _keepa_data_options: function (data) {
1197            let header = _Header[langguage]
1198            let asinObj = data.asin,
1199                that=this,
1200                obj = data.keepa;
1201                bigBSRName = obj.rootCategoryLabel
1202                  ? `${header.module_keepa_title_bsr_big_ranking}[${obj.rootCategoryLabel}]`
1203                  : header.module_keepa_title_bsr_big_ranking;
1204            let data_options = {
1205                tooltip: {
1206                    formatter: function (items) { //这里是格式化弹层渲染
1207                        let text = items[0].axisValue;
1208                        items.forEach(function (item) {
1209                            let data = item.data;
1210                            let _name = item.seriesName;
1211                            let _result = '';
1212                            //名称格式化
1213                            if (item.seriesId.indexOf('bsr') > -1 && obj.rootCategoryLabel) {
1214                                _name = `${header.module_keepa_title_bsr_big_ranking}[${obj.rootCategoryLabel}]`;
1215                            }
1216                            //数据格式化
1217                            if (item.seriesId.indexOf('price') > -1 || item.seriesId.indexOf(that.node.text.legend_price_reference) > -1) {
1218                                _result = Customer.formatCurrency(data, 2);
1219                            } else if (item.seriesId.indexOf('rating') > -1) {
1220                                _result = Customer.commafy(data, 1);
1221                            } else if (data) {
1222                                _result = Customer.commafy(data, 0);
1223                            }
1224                            let _item_html = '<br/>_name_<span class="fr ml-3">_result_</span>';
1225                            text += _item_html.replace('_name_', (item.marker + _name)).replace('_result_', (data && data > -1 ? _result : 'N/A'));
1226                        });
1227
1228                        return text;
1229                    },
1230                },
1231                legend: {
1232                    data: [that.node.text.legend_price, bigBSRName, that.node.text.legend_reviews, that.node.text.legend_rating, that.node.text.legend_sellers, that.node.text.legend_dealprice, that.node.text.legend_buyboxprice],
1233                    orient: 'vertical',
1234                    width: '200px',
1235                    itemGap: 13,
1236                    top: 35,
1237                    right: 20,
1238                   formatter: function(name) {
1239                    return name.length > 8 ? name.slice(0, 7) + '...' : name;
1240                    },
1241                    tooltip: {
1242                    show: true,
1243                    },
1244                    selected: {}
1245                },
1246                dataZoom: [{
1247                    start: that.node.paramsStart == '' ? data.keepa.range.quarter : that.node.paramsStart,
1248                },
1249                    {
1250                        start: that.node.paramsStart == '' ? data.keepa.range.quarter : that.node.paramsStart
1251                    }
1252                ],
1253                xAxis: [{
1254                    data: obj.times,
1255                },
1256                    {
1257                        data: obj.times,
1258                    },
1259                    {
1260                        data: obj.times,
1261                    },
1262                    {
1263                        data: obj.times,
1264                    }
1265                ],
1266                series: [{
1267                        data: obj.keepa.price
1268                    },
1269                    {   name:bigBSRName,
1270                        data: obj.keepa.bsr
1271                    },
1272                    {
1273                        data: obj.keepa.reviews
1274                    },
1275                    {
1276                        data: obj.keepa.rating
1277                    },
1278                    {
1279                        data: obj.keepa.sellers
1280                    },
1281                    {
1282                        data: obj.keepa.dealPrice
1283                    },
1284                    {
1285                        data: obj.keepa.buyPrice
1286                    }
1287                ]
1288            };
1289            if (obj.keepa.subRanks) {
1290                let sub_idx = 0;
1291                let sub_label = '';
1292                let subRankSeries = [];
1293                let subRankLegends = [];
1294                for (let category in obj.keepa.subRanks) {
1295                    if (obj.keepa.subRanks.hasOwnProperty(category)) {
1296                        sub_idx += 1;
1297                        sub_label = `${header.module_keepa_title_bsr_small_ranking}[${category }]`;
1298                        subRankLegends.push(sub_label);
1299                        subRankSeries.push({
1300                            id: `subRank-${sub_idx}`,
1301                            name: sub_label,
1302                            type: 'line',
1303                            symbolSize: 1,
1304                            sampling: 'none',
1305                            showAllSymbol: false,
1306                            animationThreshold: 200,
1307                            xAxisIndex: 0,
1308                            yAxisIndex: 1,
1309                            step: true,
1310                            smooth: false,
1311                            itemStyle: {
1312                                normal: {
1313                                    lineStyle: {
1314                                        width: 1,
1315                                        type: 'solid'
1316                                    }
1317                                }
1318                            },
1319                            data: obj.keepa.subRanks[category]
1320                        });
1321                    }
1322                }
1323                data_options.series.splice(2, 0, ...subRankSeries
1323);
1324                data_options.legend.data.splice(2, 0, ...subRankLegends);
1325            }
1326                // data_options.series.push({
1327                //     name: that.node.text.legend_bsr_reference,
1328                //     data: obj.keepa.bsrMa,
1329                //     markPoint: {
1330                //       itemStyle: {
1331                //         color: 'transparent',
1332                //       },
1333                //       data: [
1334                //         {
1335                //           coord: obj.keepa&&obj.keepa.bsrMa?obj.keepa.bsrMa[obj.keepa.bsrMa.length - 1]:null,
1336                //         },
1337                //       ],
1338                //     },
1339                //     z: 1,
1340                //     type: 'line',
1341                //     symbol: 'circle',
1342                //     showSymbol: false,
1343                //     smooth: true,
1344                //     itemStyle: {
1345                //       normal: {
1346                //         color: '#C2C7CD',
1347                //         lineStyle: {
1348                //           color: '#C2C7CD',
1349                //         },
1350                //       },
1351                //     },
1352                //   },{
1353                //     name:that.node.text.legend_price_reference,
1354                //     data: obj.keepa.priceMa,
1355                //     markPoint: {
1356                //       itemStyle: {
1357                //         color: 'transparent',
1358                //       },
1359                //       data: [
1360                //         {
1361                //           coord: obj.keepa&&obj.keepa.priceMa?obj.keepa.priceMa[obj.keepa.priceMa.length - 1]:null,
1362                //         },
1363                //       ],
1364                //     },
1365                //     z: 1,
1366                //     type: 'line',
1367                //     symbol: 'circle',
1368                //     showSymbol: false,
1369                //     smooth: true,
1370                //     itemStyle: {
1371                //       normal: {
1372                //         color: '#9fa3a8',
1373                //         lineStyle: {
1374                //           color: '#9fa3a8',
1375                //         },
1376                //       },
1377                //     },
1378                //   });
1379
1380            return data_options;
1381        },
1382        _flush_load_keepa_range: function (data) { //配置时间
1383            let all_days = data.keepa.totalDays,
1384                that = this;
1385            let ranges = [{
1386                    label: that.node.text.range_7_days,
1387                    value: 7
1388                },
1389                {
1390                    label: that.node.text.range_30_days,
1391                    value: 30
1392                },
1393                {
1394                    label: that.node.text.range_90_days,
1395                    value: 90
1396                },
1397                {
1398                    label: that.node.text.range_180_days,
1399                    value: 180
1400                },
1401                {
1402                    label: that.node.text.range_365_days,
1403                    value: 365
1404                },
1405                {
1406                    label: that.node.text.range_all_days,
1407                    value: -1
1408                }
1409            ];
1410            let def_range = ranges[2].value;
1411            let range_html = '<div class="select-range-title">_range_title_</div>'.replace('_range_title_', that.node.text.range_title);
1412            range_html += '<div class="flex-w1 select-range fr">_items_</div>';
1413            let items_html = '';
1414            for (let i in ranges) {
1415                let _active = ranges[i].value === def_range;
1416                items_html += '<a href="javascript:;" class=" _active_" style="text-decoration:none" range="_range_val_" >_range_label_</a>'
1417                    .replace('_active_', _active ? 'active' : '').replace('_range_val_', ranges[i].value);
1418
1419                let _range_lable = -1 !== ranges[i].value ? ranges[i].label : ranges[i].label.replace('_all_', all_days);
1420                if (i === '0')
1421                    _range_lable += '<i id= "_id_" class=" fa fa-spin iconfont icon-query fa fa-spin"></i>'.replace('_id_', that.node.trend_sync_loading);
1422
1423                items_html = items_html.replace('_range_label_', _range_lable);
1424            }
1425            $("#keepa-sub-range").html(range_html.replace('_items_', items_html));
1426            $("#" + that.node.trend_sync_loading).hide();
1427            $("#keepa-sub-range").delegate('a', 'click', function () {
1428                let sel_range = $(this).attr('range');
1429                $(this).addClass('active').siblings().removeClass("active");
1430                that.node.paramsStart = 0;
1431                switch (Number(sel_range)) {
1432                    case 7:
1433                        that.node.paramsStart = data.keepa.range.week;
1434                        break;
1435                    case 30:
1436                        that.node.paramsStart = data.keepa.range.month;
1437                        break;
1438                    case 90:
1439                        that.node.paramsStart = data.keepa.range.quarter;
1440                        break;
1441                    case 180:
1442                        that.node.paramsStart = data.keepa.range.half;
1443                        break;
1444                    case 365:
1445                        that.node.paramsStart = data.keepa.range.year;
1446                        break;
1447                    case -1:
1448                        that.node.paramsStart = 0;
1449                        break;
1450                    default:
1451                        that.node.paramsStart = data.keepa.range.quarter;
1452                        break;
1453                }
1454                that.node.keepaChart.setOption({
1455                    dataZoom: [{
1456                        start: that.node.paramsStart
1457                        }
1458                    ]
1459                });
1460            });
1461        },
1462        _check_sync_update_keepa_data: function (that, result) {
1463            /**Fulsh Keepa Datas*/
1464            var chartId = "keepa-history-trend";
1465            if ($('#' + chartId).find(".prompt-empty").length == 0 && ((result.code != "OK" && !result.data) || (result.data && result.data.keepa && result.data.keepa == {}))) {
1466                $('#' + chartId).append('<div class="prompt-empty">' + that.node.text.no_data_msg + '</div>');
1467                Customer.closeChartLoading(that.node.keepaChart);
1468            }
1469            if (result.code == "OK") {
1470                that.node.keepaChart.setOption(that._keepa_data_options(result.data));
1471                excelKeepaData = result.data;
1472                Customer.closeChartLoading(that.node.keepaChart);
1473                /**Load Quick Range MENU*/
1474                if (!that.node.paramsStart) that._flush_load_keepa_range(result.data);
1475                /**Check Update Less Than 12 Hours*/
1476                let vaild_time = new Date();
1477                vaild_time.setDate(vaild_time.getDate() - 1);
1478                vaild_time.setHours(vaild_time.getHours() + 12);
1479                let update_time = result.data.keepa.updateTime ? new Date(result.data.keepa.updateTime) : null;
1480
1481                if (!update_time || (update_time <= vaild_time && that.node.wait_times < 5)) {
1482                    $("#" + that.node.trend_sync_loading).show();
1483                    if (that.node.wait_time_out) clearTimeout(that.node.wait_time_out);
1484                    that.node.wait_time_out = setTimeout(function () {
1485                        that.node.wait_times += 1;
1486                        that.keepa_require_datas(function (result) {
1487                            if (result.code === 'OK') {
1488                                that._check_sync_update_keepa_data(that, result);
1489                            }
1490                        });
1491                    }, 5000);
1492                } else {
1493                    $("#" + that.node.trend_sync_loading).hide();
1494                }
1495            }
1496        },
1497        loadkeepaChart: function () {
1498            let that = this,
1499                chartId = "keepa-history-trend";
1500
1501            that.node.keepaChart = "";
1502            Customer.showChartLoading(that.node.keepaChart, chartId);
1503            if (that.node.keepaChart) that.node.keepaChart.dispose();
1504            that.node.keepaChart = echarts.init(document.getElementById(chartId), 'light');
1505            let option = {
1506                color: ['#FFAE2D', '#5FB0FF', '#FB7A7A', '#6EC952', '#909CF7', '#FF8C45', '#FF8888', '#62E3BE', '#6ED4B7', '#B593EB', '#FB8C1E','#A8DA2'],
1507                title: {
1508                    text: '',
1509                    textStyle: {
1510                        width: '200px',
1511                        fontSzie: '15px',
1512                        color: '#FF9300',
1513                        rich: {
1514                            a: {}
1515                        }
1516                    },
1517                    subtext: "", //'关键词优化 | 大数据选品\n\n{a|}',
1518                    top: 0,
1519                    right: '20'
1520                },
1521                tooltip: {
1522                    trigger: 'axis',
1523                    axisPointer: {
1524                        type: 'cross',
1525                        label: {
1526                            backgroundColor: 'rgba(0, 0, 0, .6)',
1527                            precision: 0,
1528                        }
1529                    },
1530                    padding: [5, 10],
1531                    backgroundColor: 'rgba(0, 0, 0, .6)',
1532                },
1533                legend: {
1534                    data: [that.node.text.legend_price, that.node.text.legend_bsr, that.node.text.legend_reviews, that.node.text.legend_rating, that.node.text.legend_sellers, that.node.text.legend_dealprice, that.node.text.legend_buyboxprice],
1535                    orient: 'vertical',
1536                    width: '200px',
1537                    itemGap: 15,
1538                    top: 170,
1539                    right: 28,
1540                    selected: {}
1541                },
1542                grid: [{
1543                    top: 15,
1544                    left: 50,
1545                    right: 190,
1546                    height: '40%',
1547                }, {
1548                    left: 50,
1549                    right: 190,
1550                    top: '50%',
1551                    height: '40%',
1552                    bottom:'5%',
1553                }],
1554                axisPointer: {
1555                    link: {
1556                        xAxisIndex: 'all'
1557                    }
1558                },
1559                toolbox: {
1560                    top: 130,
1561                    right: 0,
1562                    feature: {
1563                        dataZoom: {
1564                            yAxisIndex: 'none',
1565                            title: {
1566                                zoom: that.node.text.toolbox_zoom, //'Time Interval Adjustment',
1567                                back: that.node.text.toolbox_back //'Restore the Time Interval'
1568                            },
1569                            emphasis: {
1570                                iconStyle: {
1571                                    borderColor: '#FF9300'
1572                                }
1573                            }
1574                        },
1575                        myToolBsr: {
1576                            show: true,
1577                            title: that.node.text.reverse_the_chart,
1578                             emphasis: {
1579                                iconStyle: {
1580                                    borderColor: '#FF9300'
1581                                }
1582                            },
1583                            iconStyle:{
1584                                borderColor :"#666",
1585                            },
1586                            icon: 'path://M73.5 330.3h882.8c1.7 0 3 1.3 3 3s-1.3 3-3 3h-890c-1.2 0-2.3-0.7-2.7-1.8-0.5-1.1-0.3-2.4 0.6-3.3l207.4-207.4c1.2-1.2 3.1-1.2 4.2 0 1.2 1.2 1.2 3.1 0 4.2L73.5 330.3z m875.6 363.4H66.3c-1.7 0-3-1.3-3-3s1.3-3 3-3h890c1.2 0 2.3 0.7 2.7 1.8 0.5 1.1 0.3 2.4-0.6 3.3L751 900.3c-1.2 1.2-3.1 1.2-4.2 0s-1.2-3.1 0-4.2l202.3-202.4z',
1587                            onclick: function (){
1588                                if(that.node.SellerSprite_reverse_chart == 'Y'){
1589                                    that.setLocalStorageItem('SellerSprite.ReverseChart',null);
1590                                    that.node.SellerSprite_reverse_chart = 'N';
1591                                    option.yAxis[1].inverse = false;
1592                                }else{
1593                                    that.setLocalStorageItem('SellerSprite.ReverseChart',1);
1594                                    that.node.SellerSprite_reverse_chart = 'Y';
1595                                    option.yAxis[1].inverse = true;
1596                                }
1597                                that.node.keepaChart.setOption({yAxis:option.yAxis});
1598                            }
1599                        },
1600                        restore: {
1601                            title: that.node.text.toolbox_restore, //'Restore',
1602                            emphasis: {
1603                                iconStyle: {
1604                                    borderColor: '#FF9300'
1605                                }
1606                            }
1607                        },
1608                        myExportExcel: {
1609                            show: true,
1610                            title: that.node.text.toolbox_save_excel,
1611                            icon: 'M4.7,22.9L29.3,45.5L54.7,23.4M4.6,43.6L4.6,58L53.8,58L53.8,43.6M29.2,45.1L29.2,0',
1612                            emphasis: {
1613                                iconStyle: {
1614                                    borderColor: '#FF9300',
1615                                },
1616                            },
1617                            onclick: async function () {
1618                                let asin = excelKeepaData.asin.asin;
1619                                let keepa = excelKeepaData.keepa;
1620                                let currency = keepa.currency;
1621                                let keepaValue = keepa.keepa;
1622                                let header = _Header[langguage]
1623                                let subranks = [];
1624                                for (let key in keepaValue.subRanks) {
1625                                    let bsrTitle = 'BSR[' + key + ']';
1626                                    let subRanks = {
1627                                        header: bsrTitle,
1628                                        width: 16,
1629                                        style: { alignment: { vertical: 'middle', horizontal: 'center' } },
1630                                    };
1631                                    subranks.push(subRanks);
1632                                }
1633                                let columns = [
1634                                    {
1635                                        header: header['excel_keepa_date'],
1636                                        width: 14,
1637                                        style: {
1638                                            alignment: {vertical: 'middle', horizontal: 'center'}
1639                                        },
1640                                    },
1641                                    {
1642                                        header: header['module_keepa_title_bsr_ranking'],
1643                                        width: 14,
1644                                        style: {
1645                                            alignment: {vertical: 'middle', horizontal: 'center'}
1646                                        },
1647                                    },
1648                                    {
1649                                        header: header['module_keepa_title_seller'],
1650                                        width: 14,
1651                                        style: {
1652                                            alignment: {vertical: 'middle', horizontal: 'center'}
1653                                        },
1654                                    },
1655                                    {
1656                                        header: header['module_keepa_title_rating'],
1657                                        width: 14,
1658                                        style: {
1659                                            alignment: {vertical: 'middle', horizontal: 'center'}
1660                                        },
1661                                    },
1662                                    {
1663                                        header: header['module_keepa_title_reviews'],
1664                                        width: 14,
1665                                        style: {
1666                                            alignment: {vertical: 'middle', horizontal: 'center'}
1667                                        },
1668                                    },
1669                                    {
1670                                        header: header['module_keepa_title_price'] + '('+ currency +')',
1671                                        width: 14,
1672                                        style: {
1673                                            alignment: {vertical: 'middle', horizontal: 'center'}
1674                                        },
1675                                    },
1676                                    {
1677                                        header: header['module_keepa_title_deal_price'] + '('+ currency +')',
1678                                        width: 14,
1679                                        style: {
1680                                            alignment: {vertical: 'middle', horizontal: 'center'}
1681                                        },
1682                                    },
1683                                    {
1684                                        header: header['module_keepa_title_buybox_price'] + '('+ currency +')',
1685                                        width: 14,
1686                                        style: {
1687                                            alignment: {vertical: 'middle', horizontal: 'center'}
1688                                        },
1689                                    },
1690                                ];
1691                                if (subranks.length >= 1) {
1692                                    subranks.forEach(item => {
1693                                        columns.splice(2, 0, item);
1694                                    });
1695                                }
1696                                let headerStyles = [null, null, null, null, null, null, null, null, null];
1697
1698                                let rows = [];
1699                                let times = keepa.times
1700                                let indexes = [];
1701                                for (let i = 0; i < times.length; i++) {
1702                                    if (indexes.length === 0) {
1703                                        indexes.push(i);
1704                                        continue;
1705                                    }
1706                                    let index = indexes[indexes.length - 1];
1707                                    let date1 = times[index].split(' ')[0];
1708                                    let date2 = times[i].split(' ')[0];
1709
1710                                    if (date1 !== date2) {
1711                                        indexes.push(i);
1712                                        indexes[indexes.length - 2] = i - 1;
1713                                    }
1714                                    if (i === times.length - 1) {
1715                                        indexes[indexes.length - 1] = i;
1716                                    }
1717                                }
1718                                indexes.reverse();
1719
1720                                indexes.forEach(idx => {
1721                                    let lastDate = times == null ? '/' : (times[idx].split(' ')[0] = times[idx].split(' ')[0].replace(/-/g, '/'));
1722                                    let bsrRanks = [];
1723                                    for (let key in keepaValue.subRanks) {
1724                                        let bsrRank = keepaValue.subRanks[key] == null ? '/' : keepaValue.subRanks[key][idx];
1725                                        bsrRanks.push(bsrRank);
1726                                    }
1727                                    let row = [
1728                                        lastDate,
1729                                        (keepaValue.bsr && keepaValue.bsr[idx]) || '/',
1730                                        (keepaValue.sellers && keepaValue.sellers[idx]) || '/',
1731                                        (keepaValue.rating && keepaValue.rating[idx]) || '/',
1732                                        (keepaValue.reviews && keepaValue.reviews[idx]) || '/',
1733                                        (keepaValue.price && keepaValue.price[idx]) || '/',
1734                                        (keepaValue.dealPrice && keepaValue.dealPrice[idx]) || '/',
1735                                        (keepaValue.buyPrice && keepaValue.buyPrice[idx]) || '/',
1736                                    ];
1737                                    if (bsrRanks.length >= 1) {
1738                                        bsrRanks.forEach(item => {
1739                                            row.splice(2, 0, item == null ? '/' : item);
1740                                        });
1741                                    }
1742                                    rows.push(row);
1743                                });
1744
1745                                let valueStyles = [
1746                                    null,
1747                                    { numFmt: NumberFormatConstant.NUMBER, alignment: { vertical: 'middle', horizontal: 'right' } },
1748                                    { alignment: { vertical: 'middle', horizontal: 'center' } },
1749                                    { alignment: { vertical: 'middle', horizontal: 'center' } },
1750                                    { numFmt: NumberFormatConstant.NUMBER, alignment: { vertical: 'middle', horizontal: 'right' } },
1751                                    { numFmt: NumberFormatConstant.NUMBER_2, alignment: { vertical: 'middle', horizontal: 'right' } },
1752                                    { numFmt: NumberFormatConstant.NUMBER_2, alignment: { vertical: 'middle', horizontal: 'right' } },
1753                                    { numFmt: NumberFormatConstant.NUMBER_2, alignment: { vertical: 'middle', horizontal: 'right' } },
1754                                ];
1755                                if (subranks.length >= 1) {
1756                                    let style = { numFmt: NumberFormatConstant.NUMBER, alignment: { vertical: 'middle', horizontal: 'right' } };
1757                                    for (let i = 0; i < subranks.length; i++) {
1758                                        valueStyles.splice(2, 0, style);
1759                                    }
1760                                }
1761
1762                                let sheet = new Sheet(asin, columns, rows, headerStyles, valueStyles, (w, s) => {
1763                                    s.getCell('G1').alignment = { vertical: 'middle', horizontal: 'center' };
1764                                    s.getCell('H1').alignment = { vertical: 'middle', horizontal: 'center' };
1765                                    s.getCell('I1').alignment = { vertical: 'middle', horizontal: 'center' };
1766                                    s.getCell('J1').alignment = { vertical: 'middle', horizontal: 'center' };
1767                                });
1768
1769                                await new ExcelExportUtil(`keepa-` + asin, langguage, [sheet], null).export();
1770                            }
1771                        }
1772                    }
1773                },
1774                dataZoom: [
1775                    {
1776                        type: 'slider',
1777                        show: true,
1778                        realtime: true,
1779                        start: 90,
1780                        end: 100,
1781                        top: '92%',
1782                        xAxisIndex: [0, 1, 2, 3],
1783                        filterMode: 'filter',
1784                        borderColor: '#E5E7EC',
1785                        dataBackground: {
1786                            lineStyle: {
1787                                color: '#E7ECF7'
1788                            },
1789                            areaStyle: {
1790                                color: '#F2F5FB'
1791                            }
1792                        },
1793                        fillerColor: 'rgba(229,234,245,.4)'
1794                      },
1795                ],
1796                xAxis: [{
1797                    type: 'category',
1798                    boundaryGap: false,
1799                    axisLine: {
1800                        onZero: true,
1801                        lineStyle: {
1802                            color: '#E5E7EC'
1803                        }
1804                    },
1805                    axisLabel: {
1806                        color: '#7B7E81',
1807                        // interval: 1
1808                        formatter: function (x) {
1809                            x = _data_formaters._date_parse(x);
1810                            return _data_formaters._date_fmt(x, 'yyyy-MM-dd HH:mm');
1811                        }
1812                    },
1813                    data: [] /*timeData*/,
1814                    position: 'bottom'
1815                },
1816                    {
1817                        type: 'category',
1818                        boundaryGap: false,
1819                        axisLine: {
1820                            onZero: true,
1821                            lineStyle: {
1822                                color: '#E5E7EC'
1823                            }
1824                        },
1825                        axisLabel: {
1826                            color: '#7B7E81'
1827                        },
1828                        show: false,
1829                        data: [] /*timeData*/,
1830                        position: 'bottom'
1831                    },
1832                    {
1833                        gridIndex: 1,
1834                        type: 'category',
1835                        boundaryGap: false,
1836                        show: false,
1837                        axisLine: {
1838                            onZero: true,
1839                            lineStyle: {
1840                                color: '#E5E7EC'
1841                            }
1842                        },
1843                        axisLabel: {
1844                            show: false,
1845                            color: '#7B7E81'
1846                        },
1847                        data: [] /*timeData*/,
1848                        position: 'bottom'
1849                    },
1850                    {
1851                        gridIndex: 1,
1852                        type: 'category',
1853                        boundaryGap: false,
1854                        axisLine: {
1855                            onZero: true
1856                        },
1857                        show: false,
1858                        data: [] /*timeData*/,
1859                        position: 'bottom'
1860                    }
1861                ],
1862                yAxis: [{
1863                    type: 'value',
1864                    scale:true,
1865                    splitLine: {
1866                        show: false
1867                    },
1868                    axisLine: {
1869                        lineStyle: {
1870                            color: '#E5E7EC'
1871                        }
1872                    },
1873                    axisLabel: {
1874                        color: '#7B7E81',
1875                        formatter: function (value) { //上图左边y轴 价格
1876                            return _data_formaters._short_num_fmt(value, 1);
1877                        }
1878                    },
1879                    axisPointer: {
1880                        label: {
1881                            formatter: function (params) {
1882                                return _data_formaters._short_num_fmt(params.value, 2);
1883                            }
1884                        }
1885                    },
1886                    z: 2,
1887                },
1888                    {
1889                        type: 'value',
1890                        scale: true,
1891                        splitLine: {
1892                            show: false
1893                        },
1894                        axisLine: {
1895                            onZero: true,
1896                            lineStyle: {
1897                                color: '#E5E7EC'
1898                            }
1899                        },
1900                        axisLabel: {
1901                            color: '#7B7E81',
1902                            formatter: function (value) { //上图右边y轴 BSR
1903                                return _data_formaters._short_num_fmt(value, 0);
1904                            }
1905                        },
1906                        axisPointer: {
1907                            label: {
1908                                formatter: function (params) {
1909                                    return Customer.commafy(params.value, 0);
1910                                }
1911                            }
1912                        },
1913                        z: 2,
1914                        min: 1,
1915                        inverse:that.node.SellerSprite_reverse_chart == 'Y',
1916                    },
1917                    {
1918                        gridIndex: 1,
1919                        type: 'value',
1920                        splitLine: {
1921                            show: false
1922                        },
1923                        axisLine: {
1924                            onZero: true,
1925                            lineStyle: {
1926                                color: '#E5E7EC'
1927                            }
1928                        },
1929                        axisLabel: {
1930                            color: '#7B7E81',
1931                            formatter: function (value) { //下图左边y轴 评分值
1932                                return Customer.commafy(value, 1);
1933                            }
1934                        },
1935                        axisPointer: {
1936                            label: {
1937                                formatter: function (params) { //左边y轴辅助线标签 评分值
1938                                    return Customer.commafy(params.value, 1);
1939                                }
1940                            }
1941                        },
1942                        z: 2,
1943                    },
1944                    {
1945                        gridIndex: 1,
1946                        scale: true,
1947                        type: 'value',
1948                        splitLine: {
1949                            show: false
1950                        },
1951                        axisLine: {
1952                            onZero: true,
1953                            lineStyle: {
1954                                color: '#E5E7EC'
1955                            }
1956                        },
1957                        axisLabel: {
1958                            color: '#7B7E81',
1959                            formatter: function (value) { //下图右边y轴 评论数
1960                                return _data_formaters._short_num_fmt(value, 0);
1961                            }
1962                        },
1963                        axisPointer: {
1964                            label: {
1965                                formatter: function (params) { //右边y轴辅助线标签 评论数
1966                                    return Customer.commafy(params.value, 0);
1967                                }
1968                            }
1969                        },
1970                        z: 2,
1971                    },
1972                    {
1973                        type: 'value',
1974                        show: false,
1975                        axisPointer: {
1976                            show: false
1977                        },
1978                        z: 2,
1979                    }
1980                ],
1981                series: [{
1982                    id: 'price',
1983                    name: that.node.text.legend_price,
1984                    type: 'line',
1985                    symbolSize: 1,
1986                    sampling: 'none',
1987                    showAllSymbol: false,
1988                    animationThreshold: 1000,
1989                    step: true,
1990                    smooth: false,
1991                    itemStyle: {
1992                        normal: {
1993                            lineStyle: {
1994                                width: 1.5,
1995                                type: 'solid'
1996                            }
1997                        }
1998                    },
1999                    data: []
2000                },
2001                    {
2002                        id: 'bsr',
2003                        name: that.node.text.legend_bsr,
2004                        type: 'line',
2005                        symbolSize: 1,
2006                        sampling: 'none',
2007                        showAllSymbol: false,
2008                        animationThreshold: 1000,
2009                        xAxisIndex: 0,
2010                        yAxisIndex: 1,
2011                        step: true,
2012                        smooth: false,
2013                        itemStyle: {
2014                            normal: {
2015                                lineStyle: {
2016                                    width: 1.5,
2017                                    type: 'solid'
2018                                }
2019                            }
2020                        },
2021                        data: []
2022                    },
2023                    {
2024                        id: 'reviews',
2025                        name: that.node.text.legend_reviews,
2026                        type: 'line',
2027                        symbolSize: 1,
2028                        sampling: 'none',
2029                        showAllSymbol: false,
2030                        animationThreshold: 1000,
2031                        xAxisIndex: 3,
2032                        yAxisIndex: 3,
2033                        step: true,
2034                        smooth: false,
2035                        itemStyle: {
2036                            normal: {
2037                                lineStyle: {
2038                                    width: 1.5,
2039                                    type: 'solid'
2040                                }
2041                            }
2042                        },
2043                        data: []
2044                    },
2045                    {
2046                        id: 'rating',
2047                        name: that.node.text.legend_rating,
2048                        type: 'line',
2049                        symbolSize: 1,
2050                        showSymbol: false,
2051                        sampling: 'none',
2052                        showAllSymbol: false,
2053                        animationThreshold: 1000,
2054                        xAxisIndex: 2,
2055                        yAxisIndex: 2,
2056                        step: true,
2057                        smooth: false,
2058                        itemStyle: {
2059                            normal: {
2060                                lineStyle: {
2061                                    width: 1.5,
2062                                    type: 'solid'
2063                                }
2064                            }
2065                        },
2066                        data: []
2067                    },
2068                    {
2069                        id: 'sellers',
2070                        name: that.node.text.legend_sellers,
2071                        type: 'line',
2072                        symbolSize: 1,
2073                        sampling: 'none',
2074                        showAllSymbol: false,
2075                        animationThreshold: 1000,
2076                        xAxisIndex: 3,
2077                        yAxisIndex: 3,
2078                        step: true,
2079                        smooth: false,
2080                        itemStyle: {
2081                            normal: {
2082                                lineStyle: {
2083                                    width: 1.5,
2084                                    type: 'solid'
2085                                }
2086                            }
2087                        },
2088                        data: []
2089                    },
2090                    {
2091                        id: 'deal_price',
2092                        name: that.node.text.legend_dealprice,
2093                        type: 'scatter',
2094                        symbol: 'circle',
2095                        symbolSize: 4,
2096                        sampling: 'none',
2097                        showAllSymbol: false,
2098                        animationThreshold: 1000,
2099                        data: []
2100                    },
2101                    {
2102                        id: 'buybox_price',
2103                        name: that.node.text.legend_buyboxprice,
2104                        type: 'scatter',
2105                        symbol: 'circle',
2106                        symbolSize: 4,
2107                        sampling: 'none',
2108                        showAllSymbol: false,
2109                        animationThreshold: 1000,
2110                        data: []
2111                    }
2112                ]
2113            };
2114
2115
2116            var hasLogo = false;
2116 //true为有logo渲染模式,反之是无logo渲染模式
2117            if (option && typeof option === "object") {
2118                if (!hasLogo) { //如果没有logo
2119                    option.title.top = 0;
2120                    option.title.right = 34;
2121                    //option.title.subtextStyle.rich.a = {};
2122                    option.toolbox.top = 0;
2123                    option.legend.top = 40;
2124                }
2125                let legends = option.legend.data;
2126                for (let i = legends.length - 1; i >= legends.length - 3; i--)
2127                    option.legend.selected[legends[i]] = false;
2128
2129                that.node.keepaChart.setOption(option);
2130                that.node.keepaChart.resize();
2131                that.addChartInstance(that.node.keepaChart);
2132            }
2133        },
2134        //---------------------核心关键词
2135        loadKeyWordSearch: function () {
2136            //展示加载中
2137            let that = this;
2138            that.loadKernelkeyword();
2139            if (that.node.popItemData.asin == undefined || that.node.popItemData.asin == '') {
2140                that.node.popItemData.asin = null;
2141            }
2142            if(FlagCop!=-1){
2143                var reqUrl = '/v2/product-research/keywordTrend/' + that.node.popItemData.marketId + '?t=' + 3 +
2144                '&nrn=' + 3 + '&asin=' + that.node.popItemData.asin+'&parentModule=CL';
2145            }else if(FlagPro!=-1){
2146                var reqUrl = '/v2/product-research/keywordTrend/' + that.node.popItemData.marketId + '?t=' + 3 +
2147                '&nrn=' + 3 + '&asin=' + that.node.popItemData.asin+'&parentModule=PR';
2148            }else{
2149                var reqUrl = '/v2/product-research/keywordTrend/' + that.node.popItemData.marketId + '?t=' + 3 +
2150                '&nrn=' + 3 + '&asin=' + that.node.popItemData.asin;
2151            }
2152
2153            $.getJSON(reqUrl, function (result) {
2154                if (result && result['code'] === 0) {
2155                    that.initKeywordTrendChart(result);
2156                }
2157            });
2158        },
2159        loadKernelkeyword: function () {
2160            let chartId = "container-trend-keyword-search-chart",
2161                that = this;
2162            Customer.showChartLoading(that.node.keywordCharts, chartId);
2163            if (that.node.keywordCharts) that.node.keywordCharts.dispose();
2164            that.node.keywordCharts = echarts.init(document.getElementById(chartId), 'light');
2165            let __colors = ['#FFAE2D', '#5FB0FF', '#6EC952', '#909CF7', '#FF8C45', '#44CAF6', '#A9E025', '#B593EB', '#FB7A7A',
2166                '#61A1FA', '#6CE5C2', '#FC81B4', '#59EBEA', '#7CE599'
2167            ];
2168            let options = {
2169                color: __colors,
2170                grid: {
2171                    top: '15%',
2172                    left: '4%',
2173                    right: '4%',
2174                    bottom: '15%',
2175                    containLabel: true
2176                },
2177                tooltip: {
2178                    axisPointer: {
2179                        type: 'cross',
2180                        label: {
2181                            backgroundColor: 'rgba(0, 0, 0, .7)',
2182                            precision: 0,
2183                        }
2184                    },
2185                    trigger: 'axis',
2186                    formatter: function (params) {
2187                        var _html = '<div class="my-tooltip tooltip-long-title">';
2188                        params.forEach(function (item, index) {
2189                            var keyword = item.seriesName;
2190                            var search;
2191                            if (item.data && item.data != null) {
2192                                search = (item.data.toString().indexOf('.') !== -1) ? item.data.toLocaleString() :
2193                                    item.data.toString().replace(/(\d)(?=(?:\d{3})+$)/g, '$1,');
2194                            }
2195                            var color = item.color;
2196                            var month = item.name;
2197                            var monthDiv = index == 0 ? '<div>' + month + '</div>' : '';
2198                            var div = monthDiv +
2199                                '<div>' + '<div class="my-tooltip-mark1" style="background-color:' + color + ' "></div>' +
2200                                '<span class="keyword-span">' +
2201                                keyword + '</span>' + '<span class="my-tooltip-value">' + (search?search:'N/A') + '</span>' +
2202                                '</div>';
2203                            _html += div;
2204                        });
2205                        _html += '</div>';
2206                        return _html;
2207                    }
2208                },
2209                legend: {
2210                    data: [],
2211                    selectedMode: 'multiple'
2212                },
2213                xAxis: {
2214                    type: 'category',
2215                    boundaryGap: true,
2216                    data: [],
2217                    axisLabel: {
2218                        margin: 15,
2219                        rotate: 60,
2220                        color: '#8b93a6'
2221                    },
2222                    splitLine: {
2223                        show: true,
2224                        lineStyle: {
2225                            color: ['#eee'],
2226                            width: 1,
2227                            type: 'dotted'
2228                        }
2229                    },
2230                    axisLine: {
2231                        lineStyle: {
2232                            color: "#eee"
2233                        }
2234                    }
2235                },
2236                yAxis: [{
2237                    type: 'value',
2238                    name: that.node.text.searches_name,
2239                    splitLine: {
2240                        show: true,
2241                        lineStyle: {
2242                            color: ['#eee'],
2243                            width: 1,
2244                            type: 'dotted'
2245                        }
2246                    },
2247                    axisLabel: {
2248                        color: __colors[1],
2249                        margin: 15
2250                    },
2251                    axisLine: {
2252                        lineStyle: {
2253                            color: __colors[1]
2254                        }
2255                    },
2256                    inverse: !1
2257                }
2258
2259                ],
2260            };
2261
2262            that.node.keywordCharts.setOption(options);
2263            that.node.keywordCharts.resize();
2264            that.addChartInstance(that.node.keywordCharts);
2265        },
2266        initKeywordTrendChart: function (result) {
2267            var chartId = "container-trend-keyword-search-chart",
2268                that = this;
2269            var __colors = ['#FFAE2D', '#5FB0FF', '#6EC952', '#909CF7', '#FF8C45', '#44CAF6', '#A9E025', '#B593EB', '#FB7A7A',
2270                '#61A1FA', '#6CE5C2', '#FC81B4', '#59EBEA', '#7CE599'
2271            ];
2272            $('#' + chartId).find(".prompt-empty").length == 0 && result.data.length <= 0 ? $('#' + chartId).append('<div class="prompt-empty">' + that.node.text.no_data_msg + '</div>') : "";
2273            //核心关键词搜索量趋势
2274            let AreaColor = result['data'][0] ? that.getBackGroundColorPrivate(result['data'][0].months) : [];
2275            that.node.keywordCharts.setOption({
2276                legend: {
2277                    data: result['data'].map(function (item) {
2278                        return item.keyword;
2279                    }),
2280                    selectedMode: 'multiple'
2281                },
2282                xAxis: {
2283                    data: (function () {
2284                        return result['data'][0] && result['data'][0].months;
2285                    })(),
2286                    splitArea: { // 分隔区域
2287                        interval: function (index) {
2288                            if (index) {
2289                                return true;
2290                            }
2291                        },
2292                        show: true,
2293                        areaStyle: { // 属性areaStyle(详见areaStyle)控制区域样式
2294                            color: AreaColor
2295                        }
2296                    }
2297                },
2298                series: function () {
2299                    var serie = [];
2300                    var length = result['data'].length;
2301                    for (var i = 0; i < length; i++) {
2302                        var single = result['data'][i];
2303                        var item = {
2304                            name: single.keyword,
2305                            data: single.searches,
2306                            type: 'line',
2307                            smooth: true,
2308                            itemStyle: {
2309                                normal: {
2310                                    color: __colors[i],
2311                                }
2312                            }
2313                        };
2314                        serie.push(item);
2315                    }
2316                    return serie;
2317                }()
2318            });
2319            Customer.closeChartLoading(that.node.keywordCharts);
2320        },
2321        //--------------加载自有 qa数趋势数据-------------------------
2322        loadqaTrendData: function () {
2323            let qaChartId = 'container-trend-qa-chart',
2324                that = this;
2325            var subtractMonth = $('#container-trend-bsr-subtractMonth').val();
2326            if (!subtractMonth) subtractMonth = 2;
2327            if(FlagCop!=-1){
2328                data={
2329                    subtractMonth: subtractMonth,
2330                    parentModule:'CL'
2331                }
2332            }else if(FlagPro!=-1){
2333                data={
2334                    subtractMonth: subtractMonth,
2335                    parentModule:'PR'
2336                }
2337            }else{
2338                data={
2339                    subtractMonth: subtractMonth
2340                }
2341            }
2342            $(".container-trend-qa-switch>button[data=" + subtractMonth + "]").addClass("active").siblings().removeClass("active");
2343            that.initQaChart(qaChartId);
2344            $.ajax({
2345                type: 'post',
2346                url: '/v2/f/bsr/' + that.node.popItemData.marketId + '/' + that.node.popItemData.asin,
2347                data: data,
2348                dataType: 'json',
2349                success: function (obj) {
2350                    var asinDatas = {
2351                        "d": [],
2352                        "p": [],
2353                        "q": [],
2354                        "r": [],
2355                        "ra": [],
2356                        "r5": [],
2357                        "r4": [],
2358                        "r3": [],
2359                        "r2": [],
2360                        "r1": []
2361                    };
2362                    var chartVO = obj && obj.data ? obj.data : "";
2363                    if (obj.code == "OK") {
2364                        if (chartVO && chartVO.items && chartVO.groups) {
2365                            //处理items
2366                            for (var i = 0; i < chartVO.items.length; i++) {
2367                                var chartData = chartVO.items[i];
2368                                asinDatas.d.push(moment(chartData.snapDate).format('YYYY-MM-DD'));
2369                                asinDatas.p.push(chartData.price ? chartData.price : null);
2370                                asinDatas.q.push(chartData.questions ? chartData.questions : null);
2371                                asinDatas.r.push(chartData.reviews ? chartData.reviews : null);
2372                                asinDatas.ra.push(chartData.rating ? chartData.rating : null);
2373                                asinDatas.r5.push(chartData.reviews5star ? chartData.reviews5star : null);
2374                                asinDatas.r4.push(chartData.reviews4star ? chartData.reviews4star : null);
2375                                asinDatas.r3.push(chartData.reviews3star ? chartData.reviews3star : null);
2376                                asinDatas.r2.push(chartData.reviews2star ? chartData.reviews2star : null);
2377                                asinDatas.r1.push(chartData.reviews1star ? chartData.reviews1star : null);
2378                            }
2379                        }
2380                    }
2381                    //Q&A
2382                    that.qaTrendChartData(asinDatas, qaChartId);
2383
2384                },
2385                error: function () {
2386                }
2387            });
2388        },
2389        qaTrendChartData: function (asinDatas, chartId) {
2390            let xData = asinDatas ? asinDatas.d : [],
2391                that = this;
2392            let AreaColor = that.getBackGroundColorPrivate(xData);
2393            // 指定图表的配置项和数据
2394            let option = {
2395                xAxis: {
2396                    data: xData,
2397                    splitArea: { // 分隔区域
2398                        interval: function (index) {
2399                            if (index) {
2400                                return true;
2401                            }
2402                        },
2403                        show: true,
2404                        areaStyle: { // 属性areaStyle(详见areaStyle)控制区域样式
2405                            color: AreaColor
2406                        }
2407                    }
2408                },
2409                series: [{
2410                    data: asinDatas.q
2411                }]
2412            };
2413            ($('#' + chartId).find(".prompt-empty").length == 0 && asinDatas.q.length <= 0) ? $('#' + chartId).append('<div class="prompt-empty">' + that.node.text.no_data_msg + '</div>') : "";
2414            // 使用刚指定的配置项和数据显示图表。
2415            that.node.qaTrendChart.setOption(option);
2416            that.node.qaTrendChart.resize();
2417            that.addChartInstance(that.node.qaTrendChart);
2418            //关闭加载中
2419            asinDatas.q.length <= 0 ? Customer.closeChartLoading(that.node.qaTrendChart) : "";
2420        },
2421        initQaChart: function (qaChartId) {
2422            let that = this;
2423            //处理items
2424            Customer.showChartLoading(that.node.qaTrendChart, qaChartId);
2425            if (that.node.qaTrendChart) that.node.qaTrendChart.dispose();
2426            that.node.qaTrendChart = echarts.init(document.getElementById(qaChartId), 'light');
2427            // 指定图表的配置项和数据
2428            var qaOption = {
2429                tooltip: {
2430                    axisPointer: {
2431                        type: 'cross',
2432                        label: {
2433                            backgroundColor: 'rgba(0, 0, 0, .7)',
2434                            precision: 0,
2435                        }
2436                    },
2437                    trigger: 'axis',
2438                    formatter: Customer.formatEchartToolTip
2439                },
2440                grid: {
2441                    top: 70,
2442                    left: '1%',
2443                    right: '1%',
2444                    bottom: 25,
2445                    containLabel: !0
2446                },
2447                legend: {
2448                    data: ['Q&A']
2449                },
2450                xAxis: {
2451                    type: 'category',
2452                    axisPointer: {
2453                        type: 'shadow'
2454                    },
2455                    data: [],
2456                    axisLabel: {
2457                        color: "#8b93a6",
2458                        margin: 15,
2459                        rotate: 60
2460                    },
2461                    splitLine: {
2462                        show: true,
2463                        lineStyle: {
2464                            color: ['#eee'],
2465                            width: 1,
2466                            type: 'dotted'
2467                        }
2468                    },
2469                    axisLine: {
2470                        lineStyle: {
2471                            color: '#eee'
2472                        }
2473                    },
2474                },
2475                yAxis: {
2476                    type: 'value',
2477                    axisTick: {
2478                        alignWithLabel: true
2479                    },
2480                    splitLine: {
2481                        show: true,
2482                        lineStyle: {
2483                            color: ['#eee'],
2484                            width: 1,
2485                            type: 'dotted'
2486                        }
2487                    },
2488                    axisLine: {
2489                        lineStyle: {
2490                            color: '#FFAE2D'
2491                        }
2492                    },
2493                },
2494                series: [{
2495                    name: 'Q&A',
2496                    data: [],
2497                    type: 'line',
2498                    symbol: 'circle',
2499                    itemStyle: {
2500                        color: '#fd963c'
2501                    },
2502                    areaStyle: {
2503                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
2504                            offset: 0,
2505                            color: '#FEEEE0'
2506                        }, {
2507                            offset: 1,
2508                            color: '#FFFFFF'
2509                        }])
2510                    }
2511                }]
2512            };
2513            // 使用刚指定的配置项和数据显示图表。
2514            that.node.qaTrendChart.setOption(qaOption);
2515            that.node.qaTrendChart.resize();
2516            that.addChartInstance(that.node.qaTrendChart);
2517        },
2518        //--------------加载自有 qa数趋势数据 end-------------------------
2519
2520        //echart 动态趋势图
2521        getBackGroundColorPrivate: function (data, Month) {
2522            var colors = [];
2523            if (data == undefined) {
2524                return colors;
2525            }
2526            Month = Month ? Month : '';
2527            colors = [];
2528            let normal = 'rgba(250,250,250,0)',
2529                first = 'rgba(245,247,250,1)';
2530            for (var i = 0; i < data.length; i++) {
2531                let item = Month ? Month == 'week' ? data[i].split(".")[1] : data[i].substring(4) : data[i].split("-")[1];
2532                if (item == "01") {
2533                    colors.push(first)
2534                } else {
2535                    colors.push(normal)
2536                }
2537            }
2538            return colors;
2539        },
2540        addChartInstance: function (chart) {
2541            var needAdd = true;
2542            for (var i = 0; i < Fn.node.charts.length; i++) {
2543                var dchart = Fn.node.charts[i];
2544                if (chart.id == dchart.id) {
2545                    needAdd = false;
2546                    break;
2547                }
2548            }
2549            if (needAdd) Fn.node.charts.push(chart);
2550        },
2551        resizeCharts: function () {
2552            for (var i = 0; i < Fn.node.charts.length; i++) {
2553                var chart = Fn.node.charts[i];
2554                if (chart && chart['id'] && chart['resize']) {
2555                    try {
2556                        chart.resize();
2557                    } catch (err) {
2558
2559                    }
2560                }
2561            }
2562        },
2563        getTooltipHtml: function (data) {
2564            var _html = '<table class="market-tooltip market-tooltip-small" frame="void" ><span>' + data[0].title + '</span>';
2565            data.forEach(function (item) {
2566                var div = '<div class="my-tooltip market-tooltip-small">' +
2567                    '<div>' +
2568                    '<div class="my-tooltip-mark1" style="background-color:' + item.color + ' "></div>' +
2569                    '<span>' + item.key + '</span>' +
2570                    '<span class="my-tooltip-value">' + item.value + '</span>' +
2571                    '</div>' +
2572                    '</div>';
2573                _html +=
2574                    '    <tr>' +
2575                    '        <td>' + div + '</td>'
2576                '    </tr>';
2577            });
2578            _html += '</table>';
2579            return _html;
2580        },
2581        price(num) {
2582            num = (num || 0).toString();
2583            var result = '';
2584            var arrs;
2585            if (num.indexOf(".")) {
2586                arrs = num.split(".");
2587                num = arrs[0];
2588            }
2589
2590            while (num.length > 3) {
2591                result = ',' + num.slice(-3) + result;
2592                num = num.slice(0, num.length - 3);
2593            }
2594            if (num) {
2595                result = num + result;
2596            }
2597
2598            return result + (arrs[1] !== undefined ? "." + Fn.completionDecimal(arrs[1]) : ".00");
2599        },
2600        toThousands: function (num) {
2601            num = (num || 0).toString(), result = '';
2602
2603            var arrs;
2604            if (num.indexOf(".")) {
2605                arrs = num.split(".");
2606                num = arrs[0];
2607            }
2608
2609            while (num.length > 3) {
2610                result = ',' + num.slice(-3) + result;
2611                num = num.slice(0, num.length - 3);
2612            }
2613            if (num) {
2614                result = num + result;
2615            }
2616
2617            return result + (arrs[1] !== undefined ? "." + Fn.completionDecimal(arrs[1]) : "");
2618        },
2619        completionDecimal: function (d) {
2620            if (d.length === 1) {
2621                d = d + "0"
2622            }
2623            return d;
2624        },
2625        rounding: function (value) {
2626            if (value.indexOf(".") > -1) {
2627                return value.split(".")[0];
2628            }
2629            return value;
2630        }
2631
2632    };
2633
2634    let _Text = {
2635        "CN": {
2636            no_data_msg: "主人-暂无数据哦!",
2637            google_trend_name: '搜索指数',
2638            purchase_name: "购买量",
2639            searches_name: "搜索量",
2640            purchase_rate_name: "购买率",
2641            year_name: 'å¹´',
2642            unit_name: '份',
2643            language_name: 'zh-cn',
2644            price_link: '/price',
2645            comment_legend: '当月评分数增长值',
2646            comment_rate: '当月留评率',
2647            tips_monthly_sales: '当月销量',
2648            tips_monthly_revenue: '月销售额',
2649            limit_tips: '仅付费用户可见,',
2650            upgrade_tips: '升级套餐',
2651            login_link:'/cn/w/user/login',
2652            tourists_login_link:'立即登录',
2653            tourists_tips: '登录后可查看全部哦~',
2654            limit_all: '后可查看全部',
2655            range_title: '范围:',
2656            range_7_days: '近7天',
2657            range_30_days: '近1个月',
2658            range_90_days: '近3个月',
2659            range_180_days: '近6个月',
2660            range_365_days: '最近一年',
2661            range_all_days: '全部(_all_ 天)',
2662            toolbox_zoom: '区域缩放',
2663            toolbox_back: '区域缩放还原',
2664            toolbox_restore: '还原',
2665            toolbox_saveimg: '保存为图片',
2666            toolbox_save_excel: '导出excel',
2667            legend_daily_sales: '日销量',
2668            legend_average_daily_sales: '日销量5日均线',
2669            legend_price: 'ä»·æ ¼',
2670            legend_bsr: 'BSR排名',
2671            legend_bsr_reference:'BSR5日平均线',
2672            legend_reviews: '评分数',
2673            legend_rating: '评分',
2674            legend_sellers: '卖家数',
2675            legend_dealprice: 'Dealä»·æ ¼',
2676            legend_price_reference:'价格5日平均线',
2677            legend_buyboxprice: 'Buyboxä»·æ ¼',
2678            tips_copy_success: '已复制到剪贴板',
2679            reverse_the_chart:'BSR坐标反向',
2680
2681        },
2682        "EN": {
2683            no_data_msg: "There  is  no  core  keyword  data  temporarily",
2684            google_trend_name: 'Search Interest',
2685            purchase_name: "Purchase",
2686            searches_name: "Searches",
2687            purchase_rate_name: "Purchase Rate",
2688            year_name: '',
2689            unit_name: '',
2690            language_name: 'en',
2691            price_link: '/en/price',
2692            comment_legend: 'Ratings Increase',
2693            comment_rate: 'Ratings Rate',
2694            tips_monthly_sales: 'Sales/M',
2695            tips_monthly_revenue: 'Revenue',
2696            limit_tips: "It's only available to subscribers, please",
2697            upgrade_tips: 'upgrade your plan',
2698            login_link:'/en/w/user/login',
2699            tourists_login_link:'Login immediately',
2700            tourists_tips: 'After logging in, you can view all of them. ',
2701            limit_all: '.',
2702            range_title: 'Time:',
2703            range_7_days: '7 days',
2704            range_30_days: '1 Month',
2705            range_90_days: '3 Months',
2706            range_180_days: '6 Months',
2707            range_365_days: '1 Year',
2708            range_all_days: 'All Time (_all_ days)',
2709            toolbox_zoom: 'Time Interval Adjustment',
2710            toolbox_back: 'Restore the Time Interval',
2711            toolbox_restore: 'Restore',
2712            toolbox_saveimg: 'Save as image',
2713            toolbox_save_excel: 'Export As Excel',
2714            legend_daily_sales: 'Daily Sales',
2715            legend_average_daily_sales:'Daily Sales(5-day Average Sales)',
2716            legend_price: 'Price',
2717            legend_bsr: 'BSR',
2718            legend_bsr_reference:'BSR(5-day Average Sales)',
2719            legend_reviews: 'Ratings',
2720            legend_rating: 'Rating',
2721            legend_sellers: 'Sellers',
2722            legend_dealprice: 'Deal Price',
2723            legend_price_reference:'Price(5-day Average Sales)',
2724            legend_buyboxprice: 'Buybox Price',
2725            tips_copy_success: 'Copied Successfully',
2726            reverse_the_chart:'Reverse the chart',
2727        },
2728        "JP": {
2729            no_data_msg: "キーワードのデータはまだないよ。",
2730            google_trend_name: '検索指数',
2731            purchase_name: "販売数",
2732            searches_name: "検索数",
2733            purchase_rate_name: "転換率",
2734            year_name: '',
2735            unit_name: '',
2736            language_name: 'jp',
2737            price_link: '/jp/price',
2738            comment_legend: '当月評価数増加値',
2739            comment_rate: '当月評価率',
2740            tips_monthly_sales: '該当月販売数',
2741            tips_monthly_revenue: '該当月売上',
2742            limit_tips: 'この機能は有料会員だけがご利用いただけます~',
2743            upgrade_tips: 'プランをアップグレード',
2744            login_link:'/jp/w/user/login',
2745            tourists_login_link:'すぐにログインする',
2746            tourists_tips: '登録して全てを見る~',
2747            limit_all: '.',
2748            range_title: '範囲:',
2749            range_7_days: '直近7日',
2750            range_30_days: '1ヶ月間',
2751            range_90_days: '3ヶ月間',
2752            range_180_days: '6ヶ月間',
2753            range_365_days: '直近一年間',
2754            range_all_days: '全部(_all_ 日間)',
2755            toolbox_zoom: '縮小表示',
2756            toolbox_back: '元に戻す',
2757            toolbox_restore: '元に戻す',
2758            toolbox_saveimg: '画像を保存',
2759            toolbox_save_excel: 'エクスポート',
2760            legend_daily_sales: '日販売数',
2761            legend_average_daily_sales:'日販売数(5-day Average Sales)',
2762            legend_price: '価格',
2763            legend_bsr: 'BSR',
2764            legend_bsr_reference:'BSR(5-day Average Sales)',
2765            legend_reviews: '評価数',
2766            legend_rating: '評価',
2767            legend_sellers: 'セラー数',
2768            legend_dealprice: 'Deal価格',
2769            legend_price_reference:'価格(5-day Average Sales)',
2770            legend_buyboxprice: 'Buybox価格',
2771            tips_copy_success: 'クリップボードにコピーした',
2772            reverse_the_chart:'BSRの座標を反転',
2773        }
2774    };
2775
2776    let _Header = {
2777        "CN": {
2778            excel_keepa_date: "日期",
2779            module_keepa_title_bsr_ranking: 'BSR排名',
2780            module_keepa_title_bsr_big_ranking: '大类BSR',
2781            module_keepa_title_bsr_small_ranking: '小类BSR',
2782            module_keepa_title_bsr: 'BSR',
2783            module_keepa_title_seller: "卖家数",
2784            module_keepa_title_rating: "评分",
2785            module_keepa_title_reviews: "评分数",
2786            module_keepa_title_price: 'ä»·æ ¼',
2787            module_keepa_title_deal_price: 'Dealä»·æ ¼',
2788            module_keepa_title_buybox_price: 'Buyboxä»·æ ¼',
2789
2790        },
2791        "EN": {
2792            excel_keepa_date: "Date",
2793            module_keepa_title_bsr_ranking: 'BSR',
2794            module_keepa_title_bsr_big_ranking: 'BSR',
2795            module_keepa_title_bsr_small_ranking: 'BSR',
2796            module_keepa_title_bsr: 'BSR',
2797            module_keepa_title_seller: "Sellers",
2798            module_keepa_title_rating: "Rating",
2799            module_keepa_title_reviews: "Ratings",
2800            module_keepa_title_price: 'Price',
2801            module_keepa_title_deal_price: 'Deal Price',
2802            module_keepa_title_buybox_price: 'Buybox Price',
2803        },
2804        "JP": {
2805            excel_keepa_date: "日付",
2806            module_keepa_title_bsr_ranking: 'BSR',
2807            module_keepa_title_bsr_big_ranking: 'BSR',
2808            module_keepa_title_bsr_small_ranking: 'BSR',
2809            module_keepa_title_bsr: 'BSR',
2810            module_keepa_title_seller: "セラー数",
2811            module_keepa_title_rating: "評価",
2812            module_keepa_title_reviews: "評価数",
2813            module_keepa_title_price: '価格',
2814            module_keepa_title_deal_price: 'Deal価格',
2815            module_keepa_title_buybox_price: 'Buybox価格',
2816        }
2817    };
2818
2819    // Fn.init();
2820    window.ModuleHistoryKepaTrends = Fn;
2821    var timeout = null;
2822    $(document).ready(function () {
2823        //window 大小重置
2824        $(window).resize(function () {
2825            if (timeout) {
2826                clearTimeout(timeout);
2827            }
2828            timeout = setTimeout(function () {
2829                Fn.resizeCharts();
2830            }, 100);
2831        });
2832        //window 大小重置
2833    });
2834    // 对Date的扩展,将 Date 转化为指定格式的String
2835    // 月(M)、日(d)、小时(h)、分(m)、秒(s)、季度(q) 可以用 1-2 个占位符,
2836    // 年(y)可以用 1-4 个占位符,毫秒(S)只能用 1 个占位符(是 1-3 位的数字)
2837    // 例子:
2838    // (new Date()).Format("yyyy-MM-dd hh:mm:ss.S") ==> 2006-07-02 08:09:04.423
2839    // (new Date()).Format("yyyy-M-d h:m:s.S")      ==> 2006-7-2 8:9:4.18
2840    Date.prototype.format = function (fmt) { //author: meizz
2841        var o = {
2842            "M+": this.getMonth() + 1, //月份
2843            "d+": this.getDate(), //日
2844            "h+": this.getHours(), //小时
2845            "m+": this.getMinutes(), //分
2846            "s+": this.getSeconds(), //秒
2847            "q+": Math.floor((this.getMonth() + 3) / 3), //季度
2848            "S": this.getMilliseconds() //毫秒
2849        };
2850        if (/(y+)/.test(fmt))
2851            fmt = fmt.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
2852        for (var k in o)
2853            if (new RegExp("(" + k + ")").test(fmt))
2854                fmt = fmt.replace(RegExp.$1, (RegExp.$1.length == 1) ? (o[k]) : (("00" + o[k]).substr(("" + o[k]).length)));
2855        return fmt;
2856    };
2857    _data_formaters = {
2858        _date_fmt: function (date, fmt) {
2859            let o = {
2860                'M+': date.getMonth() + 1, //月份
2861                'd+': date.getDate(), //日
2862                'h+': date.getHours(), //小时
2863                'H+': date.getHours(), //小时
2864                'm+': date.getMinutes(), //分
2865                's+': date.getSeconds(), //秒
2866                'q+': Math.floor((date.getMonth() + 3) / 3), //季度
2867                'S': date.getMilliseconds() //毫秒
2868            };
2869            if (/(y+)/.test(fmt))
2870                fmt = fmt.replace(RegExp.$1, (date.getFullYear() + '').substr(4 - RegExp.$1.length));
2871            for (let k in o)
2872                if (new RegExp('(' + k + ')').test(fmt))
2873                    fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)));
2874            return fmt;
2875        },
2876        _date_parse: function (date_min_str) {
2877            let arrs = date_min_str.split(' ');
2878            let dateArr = arrs[0].split('-');
2879            let hourArr = arrs[1].split(':');
2880
2881            let year = parseInt(dateArr[0]);
2882            let month = parseInt(dateArr[1]);
2883            let day = parseInt(dateArr[2]);
2884            let hour = parseInt(hourArr[0]);
2885            let min = parseInt(hourArr[1]);
2886            let sec = 0;
2887            return new Date(year, month - 1, day, hour, min, sec);
2888        },
2889        _short_num_fmt: function (num, s) {
2890            if (!s || s === 2 && Fn.node.popItemData.countryCode === 'JP') s = 0;
2891            return num >= 1000000 ? Customer.commafy(num / 1000000, 0) + 'M' : num >= 10000 ? Customer.commafy(num / 1000, 1) + 'K' : Customer.commafy(num, s);
2892        }
2893    }
2894});

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.