PageSourceSearch

https://d.stockcharts.com/chartnotes/js/annotations/inspectdata.js

js stockcharts.com collected 2026-09-24 15:25:02 UTC 3,497 bytes, 106 lines download raw bytes

1
2var InspectData = Class.extend(drawutil, {
3    // This will display the data from the active mouse point at the bottom of the panel
4    init: function (easel, arg, shiftOnCreate) {
5        this.name = "inspectdata";
6        this.easel = easel;
7        this.chartnotes = easel.chartnotes;
8        this.pubsub = easel.pubsub;
9        this.MARGIN = 3;
10
11        this.lastMousePoint = this.chartnotes.mousePoint.clone();
12
13        this.subscriptions = [
14            this.pubsub.subscribe("mousemove", this.onMouseMove, this)
15        ];
16        
17        this.uid = this.toString();
18    },
19    isValid: function () {
20        return true;
21    },
22    destroy: function () {
23        // cancel all subscriptions
24        for (let subscription of this.subscriptions) {
25            subscription.unsubscribe();
26        }
27    },
28    isMultiClick: function () {
29        return false;
30    },
31    isComplete: function () {
32        return true;
33    },
34    numberWithCommas: function (x) { 
35        return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
36    },
37    paint: function () {
38        var dateId = this.chartnotes.getDateIdFromMouse();
39        var month = parseInt(dateId.substring(4, 6)) - 1;
40        var day = dateId.substring(6, 8);
41        var m = this.chartnotes.metaDataPrices.monthStrings[month];
42
43        var panel = this.chartnotes.getPanelFromPoint(this.lastMousePoint);
44        if (panel == null) {
45            return;
46        }
47
48        var v = this.chartnotes.getValueFromMouse();
49        if (Math.abs(v) > 1) {
50            v = v.toFixed(2);
51        } else {
52            v = v.toFixed(4);
53        }
54        v = Math.abs(v) > 1000 ? this.numberWithCommas(v) : v;
55
56        panel = this.chartnotes.getPanelFromPoint(this.lastMousePoint);
57
58        var str = day + " " + m + " Y:" + v;
59
60        if (panel.isPrice) {
61            var candle = this.chartnotes.metaDataPrices.getCandleFromDateId(dateId);
62            var open, high, low, close;
63            var decPlaces = candle.low > 1 ? 2 : 4;
64
65            if (candle.open == undefined) {
66                return;
67            }
68            open = candle.open.toFixed(decPlaces);
69            high = candle.high.toFixed(decPlaces);
70            low = candle.low.toFixed(decPlaces);
71            close = candle.close.toFixed(decPlaces);
72
73            open = open > 1000 ? this.numberWithCommas(open) : open;
74            high = high > 1000 ? this.numberWithCommas(high) : high;
75            low = low > 1000 ? this.numberWithCommas(low) : low;
76            close = close > 1000 ? this.numberWithCommas(close) : close;
77
78            if (!isNaN(candle.open)) {
79                str = day + " " + m + " O: " + open + "   H: " + high + "   L: " + low + "   C: " + close + "   V: " + this.numberWithCommas(candle.volume) + "   Y: " + v;
80            }
81        }
82
83        var boxWidth = this.chartnotes.ctx.measureText(str).width;
84
85        var y = panel.bounds.point3.y;
86        var x = panel.bounds.point4.x;
87
88        this.chartnotes.ctx.save();
89
90        this.chartnotes.ctx.fillStyle = '#cccccc';
91        this.chartnotes.ctx.fillRect(x, y, boxWidth + (this.MARGIN * 2), 16);
92
93        this.chartnotes.ctx.fillStyle = 'black';
94        this.chartnotes.ctx.fillText(str, x + this.MARGIN, y + 12);
95        
96        this.chartnotes.ctx.restore();
97    },
98    onMouseMove: function (oldMousePoint, newMousePoint) {
99        this.lastMousePoint = newMousePoint.clone();
100        this.pubsub.publish("repaint");
101    },
102    toString: function () {
103        return "";
104    }
105});
106

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.