PageSourceSearch

https://www.milanofinanza.it/Scripts/grafici.js

js milanofinanza.it collected 2026-09-24 08:41:34 UTC 72,507 bytes, 2,157 lines download raw bytes

1/* imposto le opzioni per i grafici */
2$(document).ready(function () {
3    Highcharts.setOptions({
4        lang: {
5            rangeSelectorZoom: "",
6            weekdays: ['Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'],
7            months: ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre'],
8            shortMonths: ['Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'],
9            thousandsSep: ".",
10            decimalPoint: ','
11        }
12        //plotOptions: {
13        //    series: {
14        //        dataGrouping: {
15        //            dateTimeLabelFormats: {
16        //                millisecond: ['\u00a0%a %e %b, %H:%M:%S.%L', '\u00a0%a %e %b, %H:%M:%S.%L', '-%H:%M:%S.%L'],
17        //                second: ['\u00a0%a %e %b, %H:%M:%S', '\u00a0%a %e %b, %H:%M:%S', '-%H:%M:%S'],
18        //                minute: ['\u00a0%a %e %b, %H:%M', '\u00a0%a %e %b, %H:%M', '-%H:%M'],
19        //                hour: ['\u00a0%a %e %b, %H:%M', '\u00a0%a %e %b, %H:%M', '-%H:%M'],
20        //                day: ['\u00a0%a %e %b %Y', '\u00a0%a %e %b', '-%a %e %b %Y'],
21        //                week: ['\u00a0Settimana da: %a %e %b %Y', '\u00a0%a %e %b', '-%a, %e %b %Y'],
22        //                month: ['\u00a0%B %Y', '\u00a0%B', '-%B %Y'],
23        //                year: ['\u00a0%Y', '\u00a0%Y', '-%Y']
24        //            }
25        //        }
26        //    }
27        //}
28    });
29});
30
31function graficoIntraday(containerGraph, titoloGrafico, stockCodeRT, codiceStrumento, key, isCache, isDettaglio, h) {
32    let descrizione = "";
33    let chiusura = "";
34    let valoriIntraday = [];
35    let url = "";
36    let chartOptions = [];
37    let nomeTitolo = "";
38    let height = (h != null) ? h : "300";
39
40    var color = ((key === "spread") || (key === "tassi") ? '#7cb5ec' : (key === "spreadapp") ? '#f00' : '#46cd3a');
41    var negativeColor = ((key === 'spread') || (key === 'tassi') ? '#7cb5ec' : (key === "spreadapp") ? '#46cd3a' : '#f00');
42   
43    //console.log("stockCodeRT:" + stockCodeRT);
44    //console.log("codiceStrumento:" + codiceStrumento);
45    //console.log("container:" + containerGraph);
46    //console.log("key:" + key);
47    //console.log("isAuthenticated:" + isAuthenticated);
48
49    if (isCache === "1") {
50        url = "/Grafici/GraficoIntradayWS?";
51    }
52    else {
53        url = "/Grafici/GraficoIntraday?";
54    };
55
56    url += "stockCodeRT=" + stockCodeRT + "&codiceStrumento=" + codiceStrumento;
57    //console.log('url: ' + url);
58
59    fetch(url).then(r => r.json()).then(result => {
60
61        if (result === "error") {
62            $("#" + containerGraph).html("<img src=\"https://static.milanofinanza.it/milanofinanza/images/grafico-non-disponibile.jpg\" class=\"img-fluid\" />");
63            return;
64        }
65
66        descrizione = result[0][0];
67        chiusura = result[1][0];
68
69        chiusura = parseFloat(result[1][0]);
70
71        /*il ciclo parte dal terzo elemento perchè i primi due sono il nome e la chiusura del giorno precedente*/
72
73        for (var x = 2; x < result.length; x++) {
74            valoriIntraday.push([
75                parseInt(result[x][0]),
76                parseFloat(result[x][1])
77            ]);
78        }
79
80        // nome titolo 
81        if (isDettaglio == "0") {
82            nomeTitolo = titoloGrafico;
83        }
84        else {
85            nomeTitolo = (titoloGrafico === "") || (titoloGrafico == null) ? descrizione : titoloGrafico;
86        }
87        
88        if (isDettaglio == "0") {
89            chartOptions = {
90                chart: {
91                    height: height,
92                    marginLeft: 5,
93                    marginRight: 5
94                },
95
96                legend: {
97                    enabled: false
98                },
99
100                rangeSelector: {
101                    enabled: false
102                },
103
104                navigator: {
105                    enabled: false
106                },
107
108                scrollbar: {
109                    enabled: false
110                },
111
112                exporting: {
113                    buttons: {
114                        contextButton: {
115                            menuItems: ['viewFullscreen', 'printChart', 'downloadPNG', 'downloadJPEG', 'downloadPDF']
116                        }
117                    }
118                },
119
120                credits: {
121                    text: '© MilanoFinanza.it',
122                    href: 'https://www.milanofinanza.it',
123                    position: {
124                        align: 'center',
125                    }
126                },
127
128                title: {
129                    text: '<b>' + nomeTitolo + '</b>',
130                    align: 'center',
131                    margin: 20,
132                    style: {
133                        fontSize: '12px',
134                        fontFamily: 'Arial'
135                    },
136                    useHTML: true
137                },
138
139                fillColor: {
140                    linearGradient: {
141                        x1: 0,
142                        y1: 0,
143                        x2: 0,
144                        y2: 1
145                    },
146                    stops: [
147                        [0, Highcharts.getOptions().colors[0]],
148                        [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
149                    ]
150                },
151
152                tooltip: {
153                    borderRadius: 0,
154                    padding: 4,
155                    borderColor: '#000000',
156                    backgroundColor: "rgba(0, 0, 0, 0.75)",
157                    style: {
158                        color: "#F0F0F0",
159                        fontSize: 11
160                    },
161                    crosshairs: [true, false],
162                    formatter: function () {
163                        // The first returned item is the header, subsequent items are the points
164                        return [Highcharts.dateFormat('\u00a0%a %e %b %H:%M', this.x)].concat(
165                            this.points ?
166                                this.points.map(function (point) {
167                                    return '<b>' + point.y + '</b>';
168                                }) : []
169                        );
170                    },
171                    split: true,
172                },
173
174                plotOptions: {
175                    series: {
176                        fillOpacity: 0.4,
177                        states: {
178
179                            hover: {
180                                enabled: true,
181                                lineWidth: 2
182                            }
183                        }
184                    }
185                },
186
187                xAxis: {
188                    type: 'datetime',
189                    labels: {
190                        style: {
191                            fontSize: '10px'
192                        }
193                    },
194                    tickInterval: 3 * 3600 * 1000
195                },
196
197                yAxis: {
198                    margin: 0,
199                    opposite: true,
200                    offset: -50,
201                    title: {
202                        text: null
203                    },
204                    plotLines: [{
205                        value: chiusura,
206                        color: '#2e4c9b',
207                        dashStyle: 'dash',
208                        width: 1,
209                        label: {
210                            text: chiusura.toLocaleString('it-IT'),
211                            style: {
212                                fontSize: '10px'
213                            }
214                        },
215                        zIndex: 5
216                    }],
217                    labels: {
218                        style: {
219                            fontSize: '10px'
220                        }
221                    }
222                },
223
224                series: [{
225                    name: nomeTitolo,
226                    type: 'areaspline',
227                    data: valoriIntraday,
228                    threshold: chiusura,
229                    color: color,
230                    negativeColor: negativeColor,
231                    zIndex: 3,
232                    marker: {
233                        radius: 0,
234                        fillColor: '#555'
235                    },
236                    states: {
237                        hover: {
238                            halo: {
239                                size: 6
240                            }
241                        }
242                    }
243                }]
244            };
245        }
246        else {
247            chartOptions = {
248                chart: {
249                    height: 400,
250                    marginLeft: 0,
251                    marginRight: 0
252                },
253
254                legend: {
255                    enabled: false
256                },
257
258                scrollbar: {
259                    enabled: true
260                },
261
262                navigator: {
263                    enabled: true
264                },
265
266                exporting: {
267                    buttons: {
268                        contextButton: {
269                            menuItems: ['viewFullscreen', 'printChart', 'downloadPNG', 'downloadJPEG', 'downloadPDF']
270                        }
271                    }
272                },
273
274                credits: {
275                    text: '© MilanoFinanza.it',
276                    href: 'https://www.milanofinanza.it',
277                    position: {
278                        align: 'center',
279                    }
280                },
281
282                stockTools: {
283                    gui: {
284                        enabled: false
285                    }
286                },
287
288                rangeSelector: {
289                    enabled: true,
290                    allButtonsEnabled: true,
291                    buttons: [{
292                        type: 'hour',
293                        count: 1,
294                        text: '1h'
295                    },
296                    {
297                        type: 'hour',
298                        count: 5,
299                        text: '5h'
300                    },
301                    {
302                        type: 'all',
303                        count: 1,
304                        text: 'All'
305                    }],
306                    selected: 2,
307                    buttonTheme: {
308                        width: 60
309                    },
310                    inputEnabled: false
311                },
312
313                title: {
314                    text: '<p style="font-size: 16px; text-align: center; margin: 0px; line-height: 120%;font-family: Arial;"><b>' + nomeTitolo + '</b> - Intraday</p>',
315                    useHTML: true
316                },
317
318                tooltip: {
319                    borderRadius: 0,
320                    padding: 4,
321                    borderColor: '#000000',
322                    backgroundColor: "rgba(0, 0, 0, 0.75)",
323                    style: {
324                        color: "#F0F0F0",
325                        fontSize: 11
326                    },
327                    crosshairs: [true, false],
328                    formatter: function () {
329                        // The first returned item is the header, subsequent items are the points
330                        return [Highcharts.dateFormat('\u00a0%a %e %b %H:%M', this.x)].concat(
331                            this.points ?
332                                this.points.map(function (point) {
333                                    return '<b>' + point.y + '</b>';
334                                }) : []
335                        );
336                    },
337                    split: true,
338                },
339
340                plotOptions: {
341                    series: {
342                        states: {
343                            hover: {
344                                enabled: true,
345                                lineWidth: 2
346                            }
347                        }
348                    }
349                },
350
351                yAxis: {
352                    margin: 0,
353                    offset: -50,
354                    title: {
355                        enabled: false
356                    },
357                    plotLines: [{
358                        value: chiusura,
359                        color: '#f00',
360                        width: 1,
361                        dashStyle: 'dash',
362                        zIndex: 5
363                    }]
364                },
365
366                xAxis: {
367                    type: 'datetime',
368                    labels: {
369                        style: {
370                            fontSize: '10px'
371                        }
372                    },
373                    tickInterval: 3 * 3600 * 1000
374                },
375
376                series: [{
377                    name: nomeTitolo,
378                    data: valoriIntraday,
379                    type: 'areaspline',
380                    threshold: false,
381                    fillColor: {
382                        linearGradient: {
383                            x1: 0,
384                            y1: 0,
385                            x2: 0,
386                            y2: 1
387                        },
388                        stops: [
389                            [0, Highcharts.getOptions().colors[0]],
390                            [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
391                        ]
392                    },
393                    tooltip: {
394                        valueDecimals: 4
395                    },
396                    color: '#7cb5ec',
397                    zIndex: 3
398                }]
399            };
400        }
401
402        Highcharts.chart(containerGraph, chartOptions);
403
404    });
405}
406//utilizzato nella dashboard mercati per app mf
407function graficoIntradaySmall(containerGraph, stockCodeRT, codiceStrumento, key, isCache, h) {
408    let chiusura = "";
409    let valoriIntraday = [];
410    let url = "";
411    let chartOptions = [];
412    let height = (h != null) ? h : "300";
413
414    var color = ((key === "spread") || (key === "tassi") ? '#7cb5ec' : (key === "spreadapp") ? '#f00' : '#46cd3a');
415    var negativeColor = ((key === 'spread') || (key === 'tassi') ? '#7cb5ec' : (key === "spreadapp") ? '#46cd3a' : '#f00');
416
417    if (isCache === "1") {
418        url = "/Grafici/GraficoIntradayWS?";
419    }
420    else {
421        url = "/Grafici/GraficoIntraday?";
422    };
423    url += "stockCodeRT=" + stockCodeRT + "&codiceStrumento=" + codiceStrumento;
424
425    fetch(url).then(r => r.json()).then(result => {
426
427        if (result === "error") {
428            return;
429        }
430
431        //chiusura
432        chiusura = result[1][0];
433        chiusura = parseFloat(result[1][0]);
434
435        /*il ciclo parte dal terzo elemento perchè i primi due sono il nome e la chiusura del giorno precedente*/
436        for (var x = 2; x < result.length; x++) {
437            valoriIntraday.push([
438                parseInt(result[x][0]),
439                parseFloat(result[x][1])
440            ]);
441        }
442
443        chartOptions = {
444            //chart impostazioni
445            chart: {
446                height: height,
447                margin: 0
448            },
449            //disabilita la legenda
450            legend: {
451                enabled: false
452            },
453            //non mostra il titolo
454            title: {
455                text: null
456            },
457            //disabilita il menu x esportare il grafico
458            exporting: {
459                enabled: false
460            },
461            //non mostra i credits a fondo pagina
462            credits: {
463                enabled: false
464            },
465            //disabilita il tooltip con i dati
466            tooltip: {
467                enabled: false
468            },
469            //area: regola trasparenza e disabilita i puntamenti sui diversi valori grafico
470            plotOptions: {
471                series: {
472                    fillOpacity: 0.3,
473                    states: {
474                        hover: {
475                            enabled: false
476                        }
477                    }
478                }
479            },
480            //asse delle X
481            xAxis: {
482                type: 'datetime',
483                gridLineWidth: 0,
484                labels: {
485                    enabled: false
486                },
487            },
488            //asse delle Y
489            yAxis: {
490                margin: 0,
491                opposite: true,
492                offset: -50,
493                gridLineWidth: 0,
494                title: {
495                    text: null
496                },
497                labels: {
498                    enabled: false
499                }
500            },
501
502            fillColor: {
503                linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
504                stops: [
505                    [0, "rgba(255, 105, 104, 0)"],
506                    [1, "rgba(255, 105, 104, 0.3)"],
507                ]
508            },
509
510            //serie di dati
511            series: [{
512                name: null,
513                type: 'areaspline',
514                data: valoriIntraday,
515                threshold: chiusura,
516                color: color,
517                negativeColor: negativeColor,
518                zIndex: 3,
519                marker: {
520                    radius: 0,
521                    fillColor: '#555'
522                },
523                states: {
524                    enabled: false
525                },
526                zones: [
527                    {
528                        value: chiusura,
529                        color: negativeColor,
530                        fillColor: {
531                            linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
532                            stops: [
533                                [0, "rgba(255, 105, 104, 0)"],
534                                [1, "rgba(255, 105, 104, 0.3)"],
535                            ],
536                        },
537                        threshold: Infinity,
538                    },
539                    {
540                        color: color,
541                        fillColor: {
542                            linearGradient: { x1: 0, y1: 0, x2: 0, y2: 1 },
543                            stops: [
544                                [0, "rgba(34, 197, 94, 0.3)"],
545                                [1, "rgba(34, 197, 94, 0)"],
546                            ],
547                        },
548                    }
549                ]
550            }]
551        };
552
553        Highcharts.chart(containerGraph, chartOptions);
554
555    });
556}
557//utilizzato nella dashboard mercati per app mf (blue chip)
558function graficoIntradayLine(containerGraph, stockCodeRT, codiceStrumento, key, isCache, h) {
559    let chiusura = "";
560    let valoriIntraday = [];
561    let url = "";
562    let chartOptions = [];
563    let height = (h != null) ? h : "300";
564
565    var color = ((key === "spread") || (key === "tassi") ? '#7cb5ec' : (key === "spreadapp") ? '#f00' : '#46cd3a');
566    var negativeColor = ((key === 'spread') || (key === 'tassi') ? '#7cb5ec' : (key === "spreadapp") ? '#46cd3a' : '#f00');
567
568    if (isCache === "1") {
569        url = "/Grafici/GraficoIntradayWS?";
570    }
571    else {
572        url = "/Grafici/GraficoIntraday?";
573    };
574    url += "stockCodeRT=" + stockCodeRT + "&codiceStrumento=" + codiceStrumento;
575
576    fetch(url).then(r => r.json()).then(result => {
577        if (result === "error") {
578            $("#" + containerGraph).html("NO GRAFICO");
579            return;
580        }
581
582        //chiusura
583        chiusura = result[1][0];
584        chiusura = parseFloat(result[1][0]);
585
586        /*il ciclo parte dal terzo elemento perchè i primi due sono il nome e la chiusura del giorno precedente*/
587        for (var x = 2; x < result.length; x++) {
588            valoriIntraday.push([
589                parseInt(result[x][0]),
590                parseFloat(result[x][1])
591            ]);
592        }
593
594        chartOptions = {
595            //chart impostazioni
596            chart: {
597                height: height,
598                margin: 0
599            },
600            //disabilita la legenda
601            legend: {
602                enabled: false
603            },
604            //non mostra il titolo
605            title: {
606                text: null
607            },
608            //disabilita il menu x esportare il grafico
609            exporting: {
610                enabled: false
611            },
612            //non mostra i credits a fondo pagina
613            credits: {
614                enabled: false
615            },
616            //disabilita il tooltip con i dati
617            tooltip: {
618                enabled: false
619            },
620            //disabilita i puntamenti sui diversi valori grafico
621            plotOptions: {
622                series: {
623                    states: {
624                        hover: {
625                            enabled: false
626                        }
627                    }
628                }
629            },
630            //asse delle X
631            xAxis: {
632                type: 'datetime',
633                gridLineWidth: 0,
634                labels: {
635                    enabled: false
636                },
637            },
638            //asse delle Y
639            yAxis: {
640                margin: 0,
641                opposite: true,
642                gridLineWidth: 0,
643                offset: -50,
644                title: {
645                    text: null
646                },
647                labels: {
648                    enabled: false
649                }
650            },
651            //serie di dati
652            series: [{
653                name: null,
654                data: valoriIntraday,
655                type: 'line',
656                threshold: chiusura,
657                color: color,
658                negativeColor: negativeColor,
659                zIndex: 3,
660                marker: {
661                    enabled: false
662                },
663                states: {
664                    enabled: false
665                }
666            }]
667        };
668
669        Highcharts.chart(containerGraph, chartOptions);
670
671    });
672}
673
674function graficoStoricoSpreads(titoloGrafico, containerGraph, stockCodeRT) {
675    let nomeTitolo = "";
676    let chiusura = "";
677    let valoriStorico = [];
678    let url = "/Grafici/GraficoStoricoSpreads?stockcodert=" + stockCodeRT;
679
680    fetch(url).then(r => r.json()).then(result => {
681
682        if (result === "error") {
683            $("#" + containerGraph).html("<img src=\"https://static.milanofinanza.it/milanofinanza/images/grafico-non-disponibile.jpg\" class=\"img-fluid\" />");
684            return;
685        }
686
687        // nome titolo 
688        nomeTitolo = titoloGrafico;
689
690        for (var x = 0; x < result.length; x++) {
691            valoriStorico.push([
692                parseInt(result[x][0]),
693                parseFloat(result[x][1])
694            ]);
695        }
696
697        var chartOptions = [];
698
699        chartOptions = {
700            rangeSelector: {
701                buttons: [{
702                    type: 'month',
703                    count: 1,
704                    text: '1m'
705                },
706                {
707                    type: 'month',
708                    count: 3,
709                    text: '3m'
710                },
711                {
712                    type: 'month',
713                    count: 6,
714                    text: '6m'
715                }],
716                selected: 1,
717                inputEnabled: false
718            },
719            navigator: {
720                enabled: false
721            },
722            chart: {
723                height: 300,
724                marginLeft: 5,
725                marginRight: 5
726            },
727            legend: {
728                enabled: false
729            },
730            scrollbar: {
731                enabled: false
732            },
733            exporting: {
734                buttons: {
735                    contextButton: {
736                        menuItems: ['viewFullscreen', 'printChart', 'downloadPNG', 'downloadJPEG', 'downloadPDF', 'downloadCSV', 'downloadXLS']
737                    }
738                }
739            },
740
741            credits: {
742                text: '© MilanoFinanza.it',
743                href: 'https://www.milanofinanza.it',
744                position: {
745                    align: 'center',
746                }
747            },
748            stockTools: {
749                gui: {
750                    enabled: false
751                }
752            },
753
754            title: {
755                text: '<b>' + nomeTitolo + '</b>'
756            },
757
758            tooltip: {
759                borderRadius: 0,
760                padding: 4,
761                borderColor: '#000000',
762                backgroundColor: "rgba(0, 0, 0, 0.75)",
763                style: {
764                    color: "#F0F0F0",
765                    fontSize: 11
766                },
767                crosshairs: [true, false],
768                formatter: function () {
769                    // The first returned item is the header, subsequent items are the
770                    // points
771                    return [Highcharts.dateFormat('%b %d', this.x)].concat(
772                        this.points ?
773                            this.points.map(function (point) {
774                                return '<b>' + point.y + '</b>';
775                            }) : []
776                    );
777                },
778                split: true,
779            },
780            plotOptions: {
781                series: {
782                    states: {
783
784                        hover: {
785                            enabled: true,
786                            lineWidth: 2
787                        }
788                    }
789                }
790            },
791            yAxis: {
792                margin: 0,
793                offset: -50,
794                title: {
795                    enabled: false
796                }
797            },
798            xAxis: {
799                type: 'datetime',
800            },
801            series: [{
802                name: nomeTitolo,
803                data: valoriStorico,
804                type: 'areaspline',
805                threshold: false,
806                fillColor: {
807                    linearGradient: {
808                        x1: 0,
809                        y1: 0,
810                        x2: 0,
811                        y2: 1
812                    },
813                    stops: [
814                        [0, Highcharts.getOptions().colors[0]],
815                        [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
816                    ]
817                },
818                tooltip: {
819                    valueDecimals: 4
820                },
821
822                color: '#7cb5ec',
823                zIndex: 3
824
825            }]
826        };
827
828        Highcharts.chart(containerGraph, chartOptions);
829    });
830}
831
832function graficoStorico(titoloGrafico, stockCode, codiceStrumento, container, tipoGrafico, enableStockTools, enableMM10, enableMM20, enableBollinger, isCache) {
833    let nomeTitolo = "";
834    let ohlc = [];
835    let volumi = [];
836    let chiusure = [];
837    let MM10 = [];
838    let MM20 = [];
839    let stdDev = [];
840    let bollinger = [];
841    /*let typeGraph = "Storico";*/
842    /*let nomeTitolo = "";*/
843
844
845    let descrizione = "";
846    let data = [];
847    let nome = "";
848
849    //console.log("stockCode:" + stockCode);
850    //console.log("codiceStrumento:" + codiceStrumento);
851    //console.log("container:" + container);
852    //console.log("isCache:" + isCache);
853
854    if (isCache === "1") {
855        url = "/Grafici/GraficoStoricoWS?";
856    }
857    else {
858        url = "/Grafici/GraficoStorico?";
859    };
860
861    /*url += "stockCodeRT=" + stockCodeRT + "&codiceStrumento=" + codiceStrumento + "&nome=" + nome;*/
862    url += "stockCodeRT=" + stockCode + "&codiceStrumento=" + codiceStrumento + "&nome=" + nome;
863    //console.log('url: ' + url);
864
865    fetch(url).then(r => r.json()).then(response => {
866
867        if (response === "error") {
868            $("#" + container).html("<img src=\"https://static.milanofinanza.it/milanofinanza/images/grafico-non-disponibile.jpg\" class=\"img-fluid\" />");
869            return;
870        }
871
872        //console.log("TYPE = Storico");
873        data = response.reverse();
874        descrizione = data[data.length - 1][0]; /* nome del titolo */
875
876        // se il nome titolo non è in input viene ottenuto dal result
877        nomeTitolo = (titoloGrafico === "") || (titoloGrafico == null) ? descrizione : titoloGrafico;
878
879        /*$scope.TitleGraph = data[data.length - 1][0];*/
880        data.pop(); /* elimina l'ultimo elemento */
881        dataLength = data.length;
882
883        if (data[0].length === 2) {
884
885            for (let i = 0; i < dataLength; i++) {
886                chiusure.push([
887                    parseInt(data[i][0]),
888                    parseFloat(data[i][1])
889                ]);
890            }
891
892            //if (localStorage.getItem(idstore) !== null) {
893            //    localStorage.removeItem(idstore);
894            //}
895            //let object1 = { id: idstore, chiusura: "", titleName: descrizione, timestamp: new Date().getTime(), values: chiusure };
896            //localStorage.setItem(idstore, JSON.stringify(object1));
897
898        } else {
899
900            for (let x = 0; x < dataLength; x++) {
901                chiusure.push([
902                    parseInt(data[x][0]),
903                    parseFloat(data[x][4])
904                ]);
905                ohlc.push([
906                    parseInt(data[x][0]),
907                    parseFloat(data[x][3]),
908                    parseFloat(data[x][2]),
909                    parseFloat(data[x][1]),
910                    parseFloat(data[x][4])
911                ]);
912                volumi.push([
913                    parseInt(data[x][0]),
914                    parseFloat(data[x][5])
915                ]);
916            }
917        }
918
919        /* calcolo media mobile 10gg */
920        let sum = 0;
921        let i = 0;
922        for (i = 0; i < chiusure.length; i++) {
923            sum += chiusure[i][1];
924            if (i < 10) {
925                MM10.push([chiusure[i][0], null]);
926            } else {
927                sum -= chiusure[i - 10][1];
928                MM10.push([chiusure[i][0], (sum / 10)]);
929            }
930        }
931
932        /* calcolo media mobile 20gg  e deviazione standard */
933        sum = 0;
934        let sum2 = 0;
935        let dev = 0;
936        for (i = 0; i < chiusure.length; i++) {
937            sum += chiusure[i][1];
938            sum2 += (chiusure[i][1]) * (chiusure[i][1]);
939            if (i < 20) {
940                MM20.push([chiusure[i][0], null]);
941                stdDev.push([chiusure[i][0], null]);
942            } else {
943                sum -= chiusure[i - 20][1];
944                sum2 -= (chiusure[i - 20][1]) * (chiusure[i - 20][1]);
945                dev = (Math.sqrt(20 * sum2 - sum * sum)) / 20;
946                MM20.push([chiusure[i][0], (sum / 20)]);
947                stdDev.push([chiusure[i][0], dev]);
948            }
949        }
950
951        /* Bollinger band */
952        let lowerVal = 0;
953        let upperVal = 0;
954        let y = 0;
955        for (y = 0; y < chiusure.length; y++) {
956            if (y < 20) {
957                bollinger.push([chiusure[y][0], null, null]);
958            } else {
959                lowerVal = MM20[y][1] - 2 * stdDev[y][1];
960                upperVal = MM20[y][1] + 2 * stdDev[y][1];
961                bollinger.push([chiusure[y][0], lowerVal, upperVal]);
962            }
963        }
964
965        let chartOptions = [];
966
967        chartOptions = {
968            chart: {
969                marginLeft: 0,
970                marginRight: 0
971            },
972
973            exporting: {
974                buttons: {
975                    contextButton: {
976                        menuItems: ['viewFullscreen', 'printChart', 'downloadPNG', 'downloadJPEG', 'downloadPDF']
977                    }
978                }
979            },
980
981            rangeSelector: {
982                enabled: true,
983                allButtonsEnabled: true,
984                buttons: [{
985                    type: 'month',
986                    count: 1,
987                    text: '1m'
988                },
989                {
990                    type: 'month',
991                    count: 3,
992                    text: '3m'
993                },
994                {
995                    type: 'month',
996                    count: 6,
997                    text: '6m'
998                },
999                {
1000                    type: 'year',
1001                    count: 1,
1002                    text: '1y'
1003                },
1004                {
1005                    type: 'year',
1006                    count: 2,
1007                    text: '2y'
1008                },
1009                {
1010                    type: 'all',
1011                    text: 'All'
1012                }],
1013                selected: 1,
1014                inputEnabled: false
1015            },
1016
1017            credits: {
1018                text: '© MilanoFinanza.it',
1019                href: 'https://www.milanofinanza.it',
1020                position: {
1021                    align: 'center'
1022                }
1023            },
1024
1025            scrollbar: {
1026                enabled: false
1027            },
1028
1029            navigator: {
1030                enabled: true,
1031                height: 50,
1032                margin: 5,
1033                adaptToUpdatedData: true,
1034                series: {
1035                    dataGrouping: {
1036                        enabled: false
1037                    }
1038                },
1039                xAxis: {
1040                    labels: {
1041                        rotation: 0,
1042                        style: {
1043                            fontSize: "9px",
1044                            textOverflow: "string",
1045                            lineHeight: "9px",
1046                            whiteSpace: "nowrap",
1047                            paddingBottom: "5px"
1048                        }
1049                    }
1050                },
1051                minRange: 120000
1052            },
1053
1054            plotOptions: {
1055                line: {
1056                    color: '#08057a',
1057                    softThreshold: false,
1058                    dataGrouping: {
1059                        approximation: "average",
1060                        groupPixelWidth: 4,
1061                        enabled: false
1062                    },
1063                    point: {
1064                        events: {
1065
1066                        }
1067                    }
1068                },
1069                states: {
1070
1071                    hover: {
1072                        enabled: true,
1073                        lineWidth: 2
1074                    }
1075                },
1076                ohlc: {
1077                    color: '#08057a'
1078                },
1079                candlestick: {
1080                    color: '#c40003',
1081                    upColor: '#16a600'
1082                }
1083            },
1084
1085            title: {
1086                text: '<p style="font-size: 16px; text-align: center; margin: 0px; line-height: 120%;font-family: Arial;"><b>' + nomeTitolo + '</b> - Storico</p>',
1087                useHTML: true
1088            },
1089
1090            subtitle: {
1091                text: '(Clicca una voce per nascondere)',
1092                floating: false,
1093                align: 'center',
1094                color: '#aaa',
1095                y: 35
1096            },
1097
1098            tooltip: {
1099                crosshairs: [true, false],
1100                borderColor: '#08057a',
1101                //split: true,
1102                useHTML: true
1103            },
1104
1105            legend: {
1106                enabled: true,
1107                layout: 'horizontal',
1108                align: 'center',
1109                verticalAlign: 'top',
1110                y: 40,
1111                backgroundColor: '#fff',
1112                borderColor: '#dedede',
1113                borderWidth: 1,
1114                shadow: true
1115            },
1116
1117            xAxis: {
1118                type: 'datetime',
1119                labels: {
1120                    style: {
1121                        fontSize: '10px'
1122                    }
1123                }
1124                //tickInterval: 3 * 3600 * 1000
1125            },
1126
1127            yAxis: [{
1128                    startOnTick: false, // only when navigator enabled 
1129                    endOnTick: false, // only when navigator enabled
1130                    margin: 0,
1131                    offset: -40,
1132                    opposite: true,
1133                    title: {
1134                        enabled: false
1135                    }
1136                },
1137                {
1138                    labels: {
1139                        enabled: false
1140                    },
1141                    top: '50%',
1142                    height: '50%',
1143                    gridLineWidth: 0,
1144                    minorGridLineWidth: 0
1145                }
1146            ],
1147
1148            navigation: {
1149                bindingsClassName: 'stktool'
1150            },
1151
1152            stockTools: {
1153                gui: {
1154                    enabled: enableStockTools
1155                }
1156            },
1157
1158            series: [
1159                {
1160                    id: 'storico',
1161                    type: tipoGrafico,
1162                    name: nomeTitolo,
1163                    data: ((tipoGrafico === "line") ? chiusure : ohlc),
1164                    tooltip: {
1165                        valueDecimals: 4
1166                    },
1167                    zIndex: 10,
1168                    showInLegend: false
1169                },
1170
1171                {
1172                    id: 'mm10',
1173                    type: 'line',
1174                    name: 'MM 10gg',
1175                    visible: enableMM10,
1176                    data: MM10,
1177                    tooltip: {
1178                        valueDecimals: 2
1179                    },
1180                    color: '#7b502e',
1181                    zIndex: 5,
1182                    lineWidth: 1
1183                },
1184                {
1185                    id: 'mm20',
1186                    type: 'line',
1187                    name: 'MM 20gg',
1188                    visible: enableMM20,
1189                    data: MM20,
1190                    tooltip: {
1191                        valueDecimals: 2
1192                    },
1193                    color: '#3f7bcd',
1194                    zIndex: 5,
1195                    lineWidth: 1
1196                },
1197                {
1198                    id: 'bollinger',
1199                    type: 'arearange',
1200                    name: 'Bollinger Band',
1201                    visible: enableBollinger,
1202                    data: bollinger,
1203                    enableMouseTracking: false,
1204                    color: '#c5dcf7',
1205                    zIndex: 0
1206                }
1207            ]
1208        };
1209
1210        if (volumi.length !== 0) {
1211            chartOptions.series.push(
1212                {
1213                    type: 'column',
1214                    name: 'Volume',
1215                    data: volumi,
1216                    yAxis: 1
1217                }
1218            );
1219        }
1220
1221        Highcharts.stockChart(container, chartOptions);
1222    });
1223}
1224
1225function graficoStoricoLight(titoloGrafico, containerGraph, stockCodeRT, codiceStrumento, isCache, datadal) {
1226    var nomeTitolo = "";
1227    var chiusura = "";
1228    var valoriStorico = [];
1229    var data = [];
1230    var ohlc = [];
1231    let url = "";
1232
1233    if (isCache === "1") {
1234        url = "/Grafici/GraficoStoricoWS?";
1235    }
1236    else {
1237        url = "/Grafici/GraficoStorico?";
1238    };
1239    url += "stockCodeRT=" + stockCodeRT + "&codiceStrumento=" + codiceStrumento + "&datadal=" + datadal;
1240    
1241    fetch(url).then(r => r.json()).then(result => {
1242
1243        if (result === "error") {
1244            $("#" + containerGraph).html("<img src=\"https://static.milanofinanza.it/milanofinanza/images/grafico-non-disponibile.jpg\" class=\"img-fluid\" />");
1245            return;
1246        }
1247
1248
1249
1250        // nome titolo 
1251        nomeTitolo = titoloGrafico;
1252
1253        data = result.reverse();
1254        
1255        /*il ciclo parte dal secondo elemento*/
1256        if (data[0].length === 2) {
1257
1258            for (var i = 1; i < result.length; i++) {
1259                valoriStorico.push([
1260                    parseInt(data[i][0]),
1261                    parseFloat(data[i][1])
1262                ]);
1263            }
1264
1265        } else {
1266            for (var z = 1; z < result.length; z++) {
1267                valoriStorico.push([
1268                    parseInt(data[z][0]),
1269                    parseFloat(data[z][4])
1270                ]);
1271            }
1272
1273        }
1274
1275        var chartOptions = [];
1276
1277        chartOptions = {
1278            rangeSelector: {
1279                buttons: [{
1280                    type: 'month',
1281                    count: 1,
1282                    text: '1m'
1283                },
1284                {
1285                    type: 'month',
1286                    count: 3,
1287                    text: '3m'
1288                },
1289                {
1290                    type: 'month',
1291                    count: 6,
1292                    text: '6m'
1293                }],
1294                selected: 1,
1295                inputEnabled: false
1296            },
1297            navigator: {
1298                enabled: false
1299            },
1300            chart: {
1301                height: 300,
1302                marginLeft: 5,
1303                marginRight: 5
1304            },
1305            legend: {
1306                enabled: false
1307            },
1308            scrollbar: {
1309                enabled: false
1310            },
1311
1312            exporting: {
1313                buttons: {
1314                    contextButton: {
1315                        menuItems: ['viewFullscreen', 'printChart', 'downloadPNG', 'downloadJPEG', 'downloadPDF']
1316                    }
1317                }
1318            },
1319
1320            credits: {
1321                enabled: false
1322            },
1323
1324            title: {
1325                text: '<p>' + nomeTitolo + '</p>',
1326                align: 'center',
1327                margin: 5,
1328                style: {
1329                    fontSize: '12px'
1330                },
1331                useHTML: true
1332            },
1333            fillColor: {
1334                linearGradient: {
1335                    x1: 0,
1336                    y1: 0,
1337                    x2: 0,
1338                    y2: 1
1339                },
1340                stops: [
1341                    [0, Highcharts.getOptions().colors[0]],
1342                    [1, Highcharts.Color(Highcharts.getOptions().colors[0]).setOpacity(0).get('rgba')]
1343                ]
1344            },
1345            tooltip: {
1346                borderRadius: 0,
1347                padding: 4,
1348                borderColor: '#000000',
1349                backgroundColor: "rgba(0, 0, 0, 0.75)",
1350                style: {
1351                    color: "#F0F0F0",
1352                    fontSize: 11
1353                },
1354                crosshairs: [true, false],
1355                formatter: function () {
1356                    // The first returned item is the header, subsequent items are the
1357                    // points
1358                    return [Highcharts.dateFormat('%b %d', this.x)].concat(
1359                        this.points ?
1360                            this.points.map(function (point) {
1361                                return point.y;
1362                            }) : []
1363                    );
1364                },
1365                split: true
1366            },
1367            plotOptions: {
1368                series: {
1369
1370                    fillOpacity: 0.4,
1371                    states: {
1372
1373                        hover: {
1374                            enabled: true,
1375                            lineWidth: 2
1376                        }
1377                    }
1378                }
1379            },
1380
1381            xAxis: {
1382                type: 'datetime',
1383            },
1384
1385            yAxis: {
1386                margin: 0,
1387                opposite: true,
1388                offset: -50,
1389                title: {
1390                    text: null
1391                }
1392            },
1393
1394            series: [{
1395                name: nomeTitolo,
1396                type: 'areaspline',
1397                data: valoriStorico,
1398                color: '#7cb5ec',
1399                zIndex: 3,
1400                marker: {
1401                    radius: 0,
1402                    fillColor: '#555'
1403                },
1404                states: {
1405                    hover: {
1406                        halo: {
1407                            size: 6
1408                        }
1409                    }
1410                }
1411            }]
1412        };
1413    
1414        //Highcharts.setOptions({
1415
1416        //    lang: {
1417        //        rangeSelectorZoom: "",
1418        //        weekdays: ['Domenica', 'Lunedì', 'Martedì', 'Mercoledì', 'Giovedì', 'Venerdì', 'Sabato'],
1419        //        months: ['Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', '
1419Settembre', 'Ottobre', 'Novembre', 'Dicembre'],
1420        //        shortMonths: ['Gen', 'Feb', 'Mar', 'Apr', 'Mag', 'Giu', 'Lug', 'Ago', 'Set', 'Ott', 'Nov', 'Dic'],
1421        //        viewFullscreen: ['Apri a tutto schermo'],
1422        //        printChart: ['Stampa Grafico'],
1423        //        downloadJPEG: ['Download immagine JPG'],
1424        //        downloadPNG: ['Download immagine PNG'],
1425        //        downloadPDF: ['Download PDF'],
1426        //        thousandsSep: ".",
1427        //        decimalPoint: ','
1428        //    },
1429
1430        //    plotOptions: {
1431        //        series: {
1432        //            dataGrouping: {
1433        //                dateTimeLabelFormats: {
1434        //                    millisecond: ['\u00a0%a %e %b, %H:%M:%S.%L', '\u00a0%a %e %b, %H:%M:%S.%L', '-%H:%M:%S.%L'],
1435        //                    second: ['\u00a0%a %e %b, %H:%M:%S', '\u00a0%a %e %b, %H:%M:%S', '-%H:%M:%S'],
1436        //                    minute: ['\u00a0%a %e %b, %H:%M', '\u00a0%a %e %b, %H:%M', '-%H:%M'],
1437        //                    hour: ['\u00a0%a %e %b, %H:%M', '\u00a0%a %e %b, %H:%M', '-%H:%M'],
1438        //                    day: ['\u00a0%a %e %b %Y', '\u00a0%a %e %b', '-%a %e %b %Y'],
1439        //                    week: ['\u00a0Settimana da: %a %e %b %Y', '\u00a0%a %e %b', '-%a, %e %b %Y'],
1440        //                    month: ['\u00a0%B %Y', '\u00a0%B', '-%B %Y'],
1441        //                    year: ['\u00a0%Y', '\u00a0%Y', '-%Y']
1442        //                }
1443        //            }
1444        //        }
1445        //    }
1446        //});
1447
1448        Highcharts.chart(containerGraph, chartOptions);
1449    });
1450}
1451
1452function graficoStoricoNative(titoloGrafico, stockCode, codiceStrumento, container, tipoGrafico, isCache) {
1453    let nomeTitolo = "";
1454    let ohlc = [];
1455    let chiusure = [];
1456    let descrizione = "";
1457    let data = [];
1458    let nome = "";
1459
1460    //console.log("stockCode:" + stockCode);
1461    //console.log("codiceStrumento:" + codiceStrumento);
1462    //console.log("container:" + container);
1463    //console.log("isCache:" + isCache);
1464
1465    if (isCache === "1") {
1466        url = "/Grafici/GraficoStoricoWS?";
1467    }
1468    else {
1469        url = "/Grafici/GraficoStorico?";
1470    };
1471
1472    url += "stockCodeRT=" + stockCode + "&codiceStrumento=" + codiceStrumento + "&nome=" + nome;
1473
1474    fetch(url).then(r => r.json()).then(response => {
1475
1476        if (response === "error") {
1477            $("#" + container).html("<img src=\"https://static.milanofinanza.it/milanofinanza/images/grafico-non-disponibile.jpg\" class=\"img-fluid\" />");
1478            return;
1479        }
1480
1481        data = response.reverse();
1482        descrizione = data[data.length - 1][0]; /* nome del titolo */
1483
1484        // se il nome titolo non è in input viene ottenuto dal result
1485        nomeTitolo = (titoloGrafico === "") || (titoloGrafico == null) ? descrizione : titoloGrafico;
1486
1487        data.pop(); /* elimina l'ultimo elemento */
1488        dataLength = data.length;
1489
1490        if (data[0].length === 2) {
1491
1492            for (let i = 0; i < dataLength; i++) {
1493                chiusure.push([
1494                    parseInt(data[i][0]),
1495                    parseFloat(data[i][1])
1496                ]);
1497            }
1498
1499        } else {
1500
1501            for (let x = 0; x < dataLength; x++) {
1502                chiusure.push([
1503                    parseInt(data[x][0]),
1504                    parseFloat(data[x][4])
1505                ]);
1506                ohlc.push([
1507                    parseInt(data[x][0]),
1508                    parseFloat(data[x][3]),
1509                    parseFloat(data[x][2]),
1510                    parseFloat(data[x][1]),
1511                    parseFloat(data[x][4])
1512                ]);
1513            }
1514        }
1515
1516        let chartOptions = [];
1517
1518        chartOptions = {
1519            chart: {
1520                marginLeft: 0,
1521                marginRight: 0
1522            },
1523
1524            exporting: {
1525                buttons: {
1526                    contextButton: {
1527                        menuItems: ['viewFullscreen', 'printChart', 'downloadPNG', 'downloadJPEG', 'downloadPDF']
1528                    }
1529                }
1530            },
1531
1532            rangeSelector: {
1533                enabled: true,
1534                allButtonsEnabled: true,
1535                buttons: [{
1536                    type: 'month',
1537                    count: 1,
1538                    text: '1m'
1539                },
1540                {
1541                    type: 'month',
1542                    count: 3,
1543                    text: '3m'
1544                },
1545                {
1546                    type: 'month',
1547                    count: 6,
1548                    text: '6m'
1549                },
1550                {
1551                    type: 'year',
1552                    count: 1,
1553                    text: '1y'
1554                },
1555                {
1556                    type: 'year',
1557                    count: 2,
1558                    text: '2y'
1559                },
1560                {
1561                    type: 'all',
1562                    text: 'All'
1563                }],
1564                selected: 1,
1565                inputEnabled: false
1566            },
1567
1568            credits: {
1569                text: '© MilanoFinanza.it',
1570                href: 'https://www.milanofinanza.it',
1571                position: {
1572                    align: 'center'
1573                }
1574            },
1575
1576            scrollbar: {
1577                enabled: false
1578            },
1579
1580            navigator: {
1581                enabled: true,
1582                height: 50,
1583                margin: 5,
1584                adaptToUpdatedData: true,
1585                series: {
1586                    dataGrouping: {
1587                        enabled: false
1588                    }
1589                },
1590                xAxis: {
1591                    labels: {
1592                        rotation: 0,
1593                        style: {
1594                            fontSize: "9px",
1595                            textOverflow: "string",
1596                            lineHeight: "9px",
1597                            whiteSpace: "nowrap",
1598                            paddingBottom: "5px"
1599                        }
1600                    }
1601                },
1602                minRange: 120000
1603            },
1604
1605            plotOptions: {
1606                line: {
1607                    color: '#08057a',
1608                    softThreshold: false,
1609                    dataGrouping: {
1610                        approximation: "average",
1611                        groupPixelWidth: 4,
1612                        enabled: false
1613                    },
1614                    point: {
1615                        events: {
1616
1617                        }
1618                    }
1619                },
1620                states: {
1621                    hover: {
1622                        enabled: true,
1623                        lineWidth: 2
1624                    }
1625                },
1626                ohlc: {
1627                    color: '#08057a'
1628                },
1629                candlestick: {
1630                    color: '#c40003',
1631                    upColor: '#16a600'
1632                }
1633            },
1634
1635            title: {
1636                text: '<p style="font-size: 16px; text-align: center; margin: 0px; line-height: 120%;font-family: Arial;"><b>' + nomeTitolo + '</b> - Storico</p>',
1637                useHTML: true
1638            },
1639
1640            tooltip: {
1641                crosshairs: [true, false],
1642                borderColor: '#08057a',
1643                //split: true,
1644                useHTML: true
1645            },
1646
1647            legend: {
1648                enabled: true,
1649                layout: 'horizontal',
1650                align: 'center',
1651                verticalAlign: 'top',
1652                y: 40,
1653                backgroundColor: '#fff',
1654                borderColor: '#dedede',
1655                borderWidth: 1,
1656                shadow: true
1657            },
1658
1659            xAxis: {
1660                type: 'datetime',
1661                labels: {
1662                    style: {
1663                        fontSize: '10px'
1664                    }
1665                }
1666                //tickInterval: 3 * 3600 * 1000
1667            },
1668
1669            yAxis: [{
1670                startOnTick: false, // only when navigator enabled 
1671                endOnTick: false, // only when navigator enabled
1672                margin: 0,
1673                offset: -10,
1674                opposite: true,
1675                title: {
1676                    enabled: false
1677                }
1678            },
1679            {
1680                labels: {
1681                    enabled: false
1682                },
1683                top: '50%',
1684                height: '50%',
1685                gridLineWidth: 0,
1686                minorGridLineWidth: 0
1687            }
1688            ],
1689
1690            navigation: {
1691                bindingsClassName: 'stktool'
1692            },
1693
1694            stockTools: {
1695                gui: {
1696                    enabled: false
1697                }
1698            },
1699
1700            series: [
1701                {
1702                    id: 'storico',
1703                    type: tipoGrafico,
1704                    name: nomeTitolo,
1705                    data: ((tipoGrafico === "line") ? chiusure : ohlc),
1706                    tooltip: {
1707                        valueDecimals: 4
1708                    },
1709                    zIndex: 10,
1710                    showInLegend: false
1711                }
1712            ]
1713        };
1714
1715        Highcharts.stockChart(container, chartOptions);
1716    });
1717}
1718
1719function creaGraficoStoricoSmall(stockCodeRT, codiceStrumento, titolo) {
1720
1721    $.ajax({
1722        url: '/Grafici/GraficoStorico?stockCodeRT=' + stockCodeRT + '&codiceStrumento=' + codiceStrumento + '&titolo=' + titolo,
1723        dataType: 'json',
1724        beforeSend: function () {
1725            $('#grafico-storico-small-' + codiceStrumento + stockCodeRT).html('<div style="width: 100%"><img src="//static.milanofinanza.it/img/loading197x145.gif" style="display: block; margin: 0px auto;"/></div>');
1726        },
1727        success: function (data) {
1728            if (data == "error") {
1729
1730                var errorMsg = '<p align="center" style="padding-top: 15px;"><b>Grafico non disponibile</b></p>';
1731                $('#grafico-storico-small-' + codiceStrumento + stockCodeRT).html(errorMsg);
1732
1733            } else {
1734
1735                data = data.reverse();
1736
1737                var descrizione = data[data.length - 1][0]; /* nome del titolo */
1738                data.pop(); /* elimina l'ultimo elemento */
1739                var dataLength = data.length;
1740
1741                var chiusure = [];
1742                if (data[0].length == 2) {
1743
1744                    for (i = 0; i < dataLength; i++) {
1745                        chiusure.push([
1746                            parseInt(data[i][0]),
1747                            parseFloat(data[i][1])
1748                        ]);
1749                    }
1750
1751                } else {
1752
1753                    for (i = 0; i < dataLength; i++) {
1754                        chiusure.push([
1755                            parseInt(data[i][0]),
1756                            parseFloat(data[i][4])
1757                        ]);
1758                    }
1759
1760                }
1761
1762                /* disegno il grafico */
1763                $('#grafico-storico-small-' + codiceStrumento + stockCodeRT).highcharts("StockChart", {
1764
1765                    rangeSelector: {
1766                        buttons: [
1767                            {
1768                                type: 'month',
1769                                count: 1,
1770                                text: '1m'
1771                            },
1772                            {
1773                                type: 'month',
1774                                count: 3,
1775                                text: '3m'
1776                            },
1777                            {
1778                                type: 'month',
1779                                count: 6,
1780                                text: '6m'
1781                            },
1782                            {
1783                                type: 'month',
1784                                count: 12,
1785                                text: '12m'
1786                            }
1787                            ,
1788                            {
1789                                type: 'year',
1790                                count: 3,
1791                                text: '3y'
1792                            },
1793                            {
1794                                type: 'year',
1795                                count: 5,
1796                                text: '5y'
1797                            }
1798                        ],
1799                        selected: 1,
1800                        inputEnabled: false
1801                    },
1802
1803                    navigator: {
1804                        enabled: true
1805                    },
1806
1807                    scrollbar: {
1808                        enabled: false
1809                    },
1810
1811                    exporting: {
1812                        enabled: false
1813                    },
1814
1815                    credits: {
1816                        enabled: false
1817                    },
1818
1819                    title: {
1820                        text: '<b>' + descrizione + '</b>',
1821                        align: 'center',
1822                        margin: 5,
1823                        style: {
1824                            fontSize: '12px'
1825                        },
1826                        useHTML: true
1827                    },
1828
1829                    tooltip: {
1830                        pointFormat: '\u00a0{series.name}: <b>{point.y} </b>\u00a0',
1831                        useHTML: true,
1832                        backgroundColor: "rgba(246, 246, 246, 1)",
1833                        style: {
1834                            padding: "1px"
1835                        },
1836                        valueDecimals: 2
1837                    },
1838
1839                    xAxis: {
1840                        labels: {
1841                            style: {
1842                                fontSize: '10px'
1843                            }
1844                        }
1845                    },
1846
1847                    yAxis: {
1848                        labels: {
1849                            style: {
1850                                fontSize: '10px'
1851                            }
1852                        }
1853                    },
1854
1855                    series: [{
1856                        name: descrizione,
1857                        data: chiusure,
1858                        color: '#2e4c9b',
1859                        zIndex: 3,
1860                        marker: {
1861                            radius: 0,
1862                            fillColor: '#555'
1863                        },
1864                        states: {
1865                            hover: {
1866                                halo: {
1867                                    size: 6
1868                                }
1869                            }
1870                        }
1871                    }]
1872
1873                });
1874
1875            }
1876        }
1877    });
1878}
1879
1880function graficoBondLine(containerGraph, tipo, mobile) {
1881    let valoriBond = [];
1882    let valoriBtpSup = [];
1883    let valoriBtpIta = [];
1884    let valoriBtpi = [];
1885    let valoriCcteu = [];
1886    let chartOptions = [];
1887    let inflazione = "";
1888    const seriesData = [];
1889    const allSeries = [];
1890    const ismobile = mobile.toLowerCase() === "true";
1891
1892    //chiamata Btp Valore-Futura
1893    fetch("/Grafici/GraficoBondWSAddValori?tipo=btpsup&tipografico=" + tipo).then(s => s.json()).then(result => {
1894        if (result != "error") {
1895            for (var x = 0; x < result.length; x++) {
1896                valoriBtpSup.push({
1897                    x: parseFloat(result[x][0]),
1898                    y: parseFloat(result[x][1]),
1899                    rendimento: tipo == 'curva' ? parseFloat(result[x][1]) : parseFloat(result[x][2]),
1900                    totalreturn: tipo == 'curva' ? parseFloat(result[x][2]) : parseFloat(result[x][1]),
1901                    duration: parseFloat(result[x][3]),
1902                    mfrisk: parseFloat(result[x][4]),
1903                    name: result[x][5],
1904                    link: result[x][6],
1905                    tipocurva: tipo
1906                });
1907            }
1908        }
1909    });
1910
1911    //chiamata Btp Italia
1912    fetch("/Grafici/GraficoBondWSAddValori?tipo=btpita&tipografico=" + tipo).then(b => b.json()).then(result => {
1913        if (result != "error") {
1914            for (var x = 0; x < result.length; x++) {
1915                valoriBtpIta.push({
1916                    x: parseFloat(result[x][0]),
1917                    y: parseFloat(result[x][1]),
1918                    rendimento: tipo == 'curva' ? parseFloat(result[x][1]) : parseFloat(result[x][2]),
1919                    totalreturn: tipo == 'curva' ? parseFloat(result[x][2]) : parseFloat(result[x][1]),
1920                    duration: parseFloat(result[x][3]),
1921                    mfrisk: parseFloat(result[x][4]),
1922                    name: result[x][5],
1923                    link: result[x][6],
1924                    tipocurva: tipo
1925                });
1926            }
1927        }
1928    });
1929
1930    //chiamata Btpi
1931    fetch("/Grafici/GraficoBondWSAddValori?tipo=btpi&tipografico=" + tipo).then(i => i.json()).then(result => {
1932        if (result != "error") {
1933            for (var x = 0; x < result.length; x++) {
1934                valoriBtpi.push({
1935                    x: parseFloat(result[x][0]),
1936                    y: parseFloat(result[x][1]),
1937                    rendimento: tipo == 'curva' ? parseFloat(result[x][1]) : parseFloat(result[x][2]),
1938                    totalreturn: tipo == 'curva' ? parseFloat(result[x][2]) : parseFloat(result[x][1]),
1939                    duration: parseFloat(result[x][3]),
1940                    mfrisk: parseFloat(result[x][4]),
1941                    name: result[x][5],
1942                    link: result[x][6],
1943                    tipocurva: tipo
1944                });
1945            }
1946        }
1947    });
1948
1949    //chiamata CctEu
1950    fetch("/Grafici/GraficoBondWSAddValori?tipo=cct&tipografico=" + tipo).then(z => z.json()).then(result => {
1951        if (result != "error") {
1952            for (var x = 0; x < result.length; x++) {
1953                valoriCcteu.push({
1954                    x: parseFloat(result[x][0]),
1955                    y: parseFloat(result[x][1]),
1956                    rendimento: tipo == 'curva' ? parseFloat(result[x][1]) : parseFloat(result[x][2]),
1957                    totalreturn: tipo == 'curva' ? parseFloat(result[x][2]) : parseFloat(result[x][1]),
1958                    duration: parseFloat(result[x][3]),
1959                    mfrisk: parseFloat(result[x][4]),
1960                    name: result[x][5],
1961                    link: result[x][6],
1962                    tipocurva: tipo
1963                });
1964            }
1965        }
1966    });
1967    
1968    //chiamata alle curve dei grafici
1969    var url = "/Grafici/GraficoBondWS?tipo=" + tipo;
1970
1971    fetch(url).then(r => r.json()).then(result => {
1972        if (result === "error") {
1973            $("#" + containerGraph).html("NO GRAFICO");
1974            return;
1975        }
1976
1977        for (var x = 0; x < result.length; x++) {
1978            var curvatabella = result[x][0] == "0.25" ? "3M" : result[x][0] == "0.5" ? "6M" : result[x][0];
1979            valoriBond.push({
1980                x: parseFloat(result[x][0]),
1981                y: parseFloat(result[x][1]),
1982                rendimento: tipo == 'curva' ? parseFloat(result[x][1]) : parseFloat(result[x][2]),
1983                totalreturn: tipo == 'curva' ? parseFloat(result[x][2]) : parseFloat(result[x][1]),
1984                duration: parseFloat(result[x][3]),
1985                mfrisk: parseFloat(result[x][4]),
1986                numtit: parseFloat(result[x][5]),
1987                link: '/quotazioni/ricerca/bond-curva' + curvatabella + '?gr=' + tipo,
1988                tipocurva: tipo
1989            });
1990        }
1991        
1992        allSeries.push({
1993            name: 'Bot-Btp',
1994            type: 'spline',
1995            data: valoriBond, 
1996            color: '#b00202',
1997            marker: { enabled: true },
1998            visible: true
1999        });
2000
2001        //valori da aggiungere al grafico
2002        setTimeout(function () {
2003            Object.assign(seriesData, { 'Btp Valore-Futura': valoriBtpSup });
2004            Object.assign(seriesData, { 'Btp Italia': valoriBtpIta });
2005            Object.assign(seriesData, { Btpi: valoriBtpi });
2006            Object.assign(seriesData, { CctEu: valoriCcteu });
2007            const seriesNames = Object.keys(seriesData);
2008
2009            seriesNames.forEach(name => {
2010                allSeries.push({
2011                    name,
2012                    type: 'scatter',
2013                    data: seriesData[name],
2014                    visible: true
2015                });
2016            });
2017
2018            //inflazione
2019            inflazione = parseFloat(result[0][6]);
2020            allSeries.push({
2021                name: 'Inflazione',
2022                type: 'scatter',
2023                data: [inflazione],
2024                marker: { enabled: false },
2025                showInLegend: false
2026            });
2027
2028            chartOptions = {
2029                chart: {
2030                    height: ismobile ? 400 : 500,
2031                    marginTop: ismobile ? 20 : 80,
2032                    marginBottom: ismobile ? 140 : 90,
2033                    marginRight: 30,
2034                    zoomType: 'xy'
2035                },
2036                //non mostra il titolo
2037                title: {
2038                    text: null
2039                },
2040                //tooltip
2041                tooltip: {
2042                    shared: true,
2043                    formatter: function () {
2044                        if (this.series.name == "Bot-Btp") {
2045                            var tooltipvalue = `Scadenza (anni): ${this.points[0].x}<br>` +
2046                                (this.tipocurva == "curva" ? `Rendim. a scad.: ${this.points[0].rendimento.toFixed(2).replace('.', ',')}<br>` : `Ritorni 12m.: ${this.points[0].totalreturn.toFixed(2).replace('.', ',')}<br>`) +
2047                                (this.tipocurva == "curva" ? `Ritorni 12m.: ${this.points[0].totalreturn.toFixed(2).replace('.', ',')}<br>` : `Rendim. a scad.: ${this.points[0].rendimento.toFixed(2).replace('.', ',')}<br>`) +
2048                                `Duration (anni): ${this.points[0].duration.toFixed(2).replace('.', ',')}<br>` +
2049                                `MF Risk (%): ${this.points[0].mfrisk.toFixed(1).replace('.', ',')}<br>` +
2050                                `Nr. titoli nel nodo: ${this.points[0].numtit}<br>`;
2051                        }
2052                        else {
2053                            var tooltipvalue = `<strong>${this.name}</strong><br>` +
2054                                (this.tipocurva == "curva" ? `Rendim. a scad.: ${this.rendimento.toFixed(2).replace('.', ',')}<br>` : `Ritorni 12m.: ${this.totalreturn.toFixed(2).replace('.', ',')}<br>`) +
2055                                (this.tipocurva == "curva" ? `Ritorni 12m.: ${this.totalreturn.toFixed(2).replace('.', ',')}<br>` : `Rendim. a scad.: ${this.rendimento.toFixed(2).replace('.', ',')}<br>`) +
2056                                `Duration (anni): ${this.duration.toFixed(2).replace('.', ',')}<br>` +
2057                                `MF Risk (%): ${this.mfrisk.toFixed(1).replace('.', ',')}<br>`;
2058
2059                        }
2060                        return tooltipvalue;
2061
2062                    },
2063                    style: {
2064                        color: '#808080',
2065                        lineHeight: 18
2066                    }
2067                },
2068                //asse X
2069                xAxis: {
2070                    title: {
2071                        text: 'Scadenza (anni)',
2072                        style: {
2073                            fontSize: 14
2074                        }
2075                    },
2076                    tickPositions: ismobile ? [0, 5, 10, 15, 20, 25, 30] : [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30],
2077                    gridLineWidth: 1,
2078                    labels: {
2079                        align: 'center',
2080                        style: {
2081                            color: '#808080',
2082                            fontSize: '11px'
2083                        }
2084                    }
2085                },
2086                //asse Y
2087                yAxis: {
2088                    title: {
2089                        text: tipo == 'curva' ? 'Rendimento annuo (%)' : 'Total return ultimi 12 mesi (%)',
2090                        style: {
2091                            color: '#b00202',
2092                            fontSize: 14
2093                        }
2094                    },
2095                    tickInterval: tipo == 'curva' ? 0.5 : 1,
2096                    labels: {
2097                        style: {
2098                            color: '#b00202',
2099                            fontWeight: 'bold'
2100                        }
2101                    },
2102                    plotLines: [{
2103                        value: inflazione,
2104                        color: '#2e4c9b',
2105                        dashStyle: 'dash',
2106                        width: 1,
2107                        zIndex: 4,
2108                        label: {
2109                            text: 'Inflazione: ' + inflazione.toFixed(2).replace('.',','),
2110                            style: {
2111                                fontSize: '10px'
2112                            }
2113                        }
2114                    }]
2115                },
2116                //plot opzioni
2117                plotOptions: {
2118                    series: {
2119                        stickyTracking: false,
2120                        cursor: 'pointer',
2121                        point: {
2122                            events: {
2123                                click: function () {
2124                                    location.href = this.link;
2125                                }
2126                            }
2127                        }
2128                    },
2129                    scatter: {
2130                        marker: {
2131                            symbol: 'circle'
2132                        }
2133                    }
2134                },
2135                //legenda
2136                legend: {
2137                    align: 'center',
2138                    verticalAlign: ismobile ? 'bottom' : 'top',
2139                    itemMarginTop: ismobile ? 0 : 30,
2140                    borderWidth: 0
2141                },
2142                //disabilita il menu x esportare il grafico
2143                exporting: {
2144                    enabled: false
2145                },
2146                //non mostra i credits a fondo pagina
2147                credits: {
2148                    enabled: false
2149                },
2150                //serie di dati
2151                series: allSeries
2152            };
2153            Highcharts.chart(containerGraph, chartOptions);
2154
2155        }, 1500);
2156    });
2157}

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.