HTML Preparation code:
x
 
1
<html xmlns="http://www.w3.org/1999/xhtml">
2
<head>
3
<meta name="WebPartPageExpansion" content="full" />
4
<title>Subway Map</title>
5
    <script type="text/javascript" src="../_catalogs/masterpage/bgl/js/libraries/jquery-1.10.2.min.js"></script>
6
    <script type="text/javascript" src="../_catalogs/masterpage/bgl/js/plugins/jquery.subwayMap-0.5.0.js"></script>
7
    <style type="text/css">
8
    @media only screen {
9
        .instructions {
10
            display:block;  
11
        }
12
    }
13
    @media only screen and (min-width: 40.063em) { 
14
        .instructions {
15
            display:none;   
16
        }
17
    }
18
    @media only screen and (min-width: 64.063em) { 
19
        .instructions {
20
            display:none;   
21
        }
22
    }
23
    
24
    
25
    
26
    body
27
    {
28
        font-family: Verdana;
29
        font-size: 8pt;
30
    }
31
32
    /* The main DIV for the map */
33
    .subway-map
34
    {
35
        margin: 0;
36
        width: 500px;
37
        height:410px;
38
        background-color: white;
39
    }
40
41
    /* Text labels */
42
    .text
43
    {
44
        text-decoration: none;
45
        color: black;
46
    }
47
48
    #legend
49
    {
50
        float: left;
51
        width: 250px;
52
        height:400px;
53
    }
54
55
    #legend div
56
    {
57
        height: 25px;
58
    }
59
60
    #legend span
61
    {
62
        margin: 5px 5px 5px 0;
63
    }
64
    .subway-map span
65
    {
66
        margin: 5px 5px 5px 0;
67
    }
68
 
69
    </style>
70
</head>
71
<body>
72
    <div class="instructions">
73
        &lt;--------- scroll left or right ---------&gt;
74
    </div>
75
    <div class="subway-map" data-columns="22" data-rows="40" data-cellSize="30" data-legendId="legend" data-textClass="text" data-gridNumbers="true" data-grid="false" data-lineWidth="8">
76
        <ul data-color="#F7941D" data-label="seniorTechnicalManager1">          
77
            <li data-coords="2,10"><a href="/sites/mibgl/Documents/Career%20Paths/Junior%20Software%20Engineer_Aug16.pdf">Junior</a></li>  
78
            <li data-coords="2,9" ></li>
79
            <li data-coords="3,8" data-dir="N"></li>
80
            <li data-coords="5,6" ><a target="_self" href="/sites/mibgl/Documents/Career%20Paths/DevOps%20Engineer.pdf">Engineer</a></li>
81
            <li data-coords="9,6" ><a href="/sites/mibgl/Documents/Career%20Paths/Senior%20DevOps%20Engineer.pdf">Senior Engineer</a></li>            
82
        </ul>
83
        <ul data-color="#F7941D" data-label="seniorTechnicalManager2"> 
84
            <li data-coords="2,10"></li>
85
            <li data-coords="5,10" ><a href="http://jqueryui.com/demos/tabs/">Developer</a></li>
86
            <li data-coords="9,10" ><a href="http://jqueryui.com/demos/tabs/">Senior Developer</a></li>
87
            <!--<li data-coords="7,9" data-dri="N"></li>-->
88
            <li data-coords="5,6"></li>
89
        </ul>
90
        <ul data-color="#F7941D" data-label="seniorTechnicalManager3"> 
91
            <li data-coords="9,10" ></li>
92
            <li data-coords="13,10" ><a href="/sites/mibgl/Documents/Career%20Paths/DevOps%20Tech%20Lead.pdf">Technical Lead</a></li>
93
            <li data-coords="17,10" ><a href="http://jqueryui.com/demos/tabs/">Senior Technical Lead</a></li>
94
            <li data-coords="21,10" ></li>
95
        </ul>
96
        <ul data-color="#F7941D" data-label="seniorTechnicalManager4"> 
97
            <li data-coords="2,10" ></li>
98
            <li data-coords="2,11" ></li>
99
            <li data-coords="3,12" data-dir="S"></li>
100
            <li data-coords="4.9,14" data-marker="interchange" ><a href="http://jqueryui.com/demos/tabs/">Analyst</a></li>          
101
            <li data-coords="9,14" ><a href="http://jqueryui.com/demos/tabs/">Senior Analyst</a></li>           
102
            <li data-coords="5,10" ></li>
103
        </ul>
104
        <ul data-color="#F7941D" data-label="seniorTechnicalManager5"> 
105
            <li data-coords="9,14" ></li>
106
            <li data-coords="10,13" ></li>
107
            <li data-coords="13,13" ><a href="http://jqueryui.com/demos/tabs/">Development Lead</a></li>            
108
        </ul>
109
        <ul data-color="#F7941D" data-label="seniorTechnicalManager6"> 
110
            <li data-coords="12,13" ></li>
111
            <li data-coords="9,10" ></li>
112
        </ul>
113
        <ul data-color="#F6ED31" data-label="seniorManager1"> 
114
            <li data-coords="13,13" ></li>
115
            <li data-coords="17,13" ><a href="http://jqueryui.com/demos/tabs/">Development Manager</a></li>
116
            <li data-coords="21,13" ></li>
117
        </ul>
118
        <ul data-color="#662D91" data-label="seniorManagerITOperations1"> 
119
            <li data-coords="9,6" ></li>
120
            <li data-coords="10,5" ></li>
121
            <li data-coords="12,3" ></li>
122
            <li data-coords="13,3" ><a href="http://jqueryui.com/demos/tabs/">Team Lead / Tech Lead</a></li>                        
123
            <li data-coords="17,3" ><a href="http://jqueryui.com/demos/tabs/">IT Operations Manager</a></li>                        
124
            <li data-coords="21,3" ></li>           
125
        </ul>
126
        <ul data-color="#EC008D" data-label="seniorManagerArchitect1"> 
127
            <li data-coords="9,6" ></li>
128
            <li data-coords="13,6" ><a href="http://jqueryui.com/demos/tabs/">Solutions Architect</a></li>                      
129
            <li data-coords="17,6" ><a href="http://jqueryui.com/demos/tabs/">Estate / Senior Solutions Architect</a></li>                                              
130
            <li data-coords="21,6" ></li>       
131
        </ul>
132
        <ul data-color="#8DC63F" data-label="seniorManagerQualityAssurance1"> 
133
            <li data-coords="9,14" ></li>
134
            <li data-coords="11,16" ></li>
135
            <li data-coords="13,16" ><a href="http://jqueryui.com/demos/tabs/">QA Team Lead</a></li>                        
136
            <li data-coords="17,16" ><a href="http://jqueryui.com/demos/tabs/">Test Manager</a></li>                        
137
            <li data-coords="21,16" ></li>      
138
        </ul>
139
        <ul data-color="#14A79D" data-label="seniorProjectManager1"> 
140
            <li data-coords="5,14" ></li>
141
            <li data-coords="5,15" ></li>
142
            <li data-coords="6,16" data-dir="S"></li>
143
            <li data-coords="9,19" ><a href="http://jqueryui.com/demos/tabs/">Project / Implementation Lead</a></li>                                    
144
            <li data-coords="13,19" ><a href="http://jqueryui.com/demos/tabs/">Project / Implementation Manager</a></li>                        
145
            <li data-coords="17,19" ><a href="http://jqueryui.com/demos/tabs/">Portfolio Manager</a></li>                       
146
            <li data-coords="21,19" ></li>      
147
        </ul>
148
        <ul data-color="#25AAE1" data-label="seniorManagerComDev1" data-shiftCoords="-1,0"> 
149
            <li data-coords="5,14" ></li>
150
            <li data-coords="5,18" ></li>
151
            <li data-coords="6,19" data-dir="S" ></li>
152
            <li data-coords="9,22" ><a href="http://jqueryui.com/demos/tabs/">Analyst - Business / Technical</a></li>                                   
153
            <li data-coords="15,22" ><a href="http://jqueryui.com/demos/tabs/">Senior Analyst - Business / Techical</a></li>                        
154
            <li data-coords="21,22" ></li>
155
        </ul>
156
        <ul data-color="#25AAE1" data-label="test1">
157
            <li data-coords="2,25"></li>
158
            <li data-coords="4,25"><a href="http://jqueryui.com/demos/tabs/">Test 1</a></li>
159
            <li data-coords="7,25"><a href="http://jqueryui.com/demos/tabs/">Test 2</a></li>
160
            <li data-coords="10,25"><a href="http://jqueryui.com/demos/tabs/">Test 3</a></li>
161
            <li data-coords="13,25"><a href="http://jqueryui.com/demos/tabs/">Test 4</a></li>
162
            <li data-coords="16,25"><a href="http://jqueryui.com/demos/tabs/">Test 5</a></li>
163
            <li data-coords="19,25"><a href="http://jqueryui.com/demos/tabs/">Test 6</a></li>                                               
164
            <li data-coords="21,25" ></li>          
165
        </ul>
166
        <ul data-color="#25AAE1" data-label="test2">
167
            <li data-coords="2,28"></li>
168
            <li data-coords="4,28"><a href="http://jqueryui.com/demos/tabs/">Test 1</a></li>
169
            <li data-coords="7,28"><a href="http://jqueryui.com/demos/tabs/">Test 2</a></li>
170
            <li data-coords="10,28"><a href="http://jqueryui.com/demos/tabs/">Test 3</a></li>
171
            <li data-coords="13,28"><a href="http://jqueryui.com/demos/tabs/">Test 4</a></li>
172
            <li data-coords="16,28"><a href="http://jqueryui.com/demos/tabs/">Test 5</a></li>
173
            <li data-coords="19,28"><a href="http://jqueryui.com/demos/tabs/">Test 6</a></li>                                               
174
            <li data-coords="21,28" ></li>          
175
        </ul>
176
        <ul data-color="#25AAE1" data-label="test3">
177
            <li data-coords="2,31"></li>
178
            <li data-coords="4,31"><a href="http://jqueryui.com/demos/tabs/">Test 1</a></li>
179
            <li data-coords="7,31"><a href="http://jqueryui.com/demos/tabs/">Test 2</a></li>
180
            <li data-coords="10,31"><a href="http://jqueryui.com/demos/tabs/">Test 3</a></li>
181
            <li data-coords="13,31"><a href="http://jqueryui.com/demos/tabs/">Test 4</a></li>
182
            <li data-coords="16,31"><a href="http://jqueryui.com/demos/tabs/">Test 5</a></li>
183
            <li data-coords="19,31"><a href="http://jqueryui.com/demos/tabs/">Test 6</a></li>                                               
184
            <li data-coords="21,31" ></li>          
185
        </ul>
186
    </div>
187
   
188
    
189
190
    <script type="text/javascript">
191
        $(".subway-map").subwayMap({ debug: false });
192
    </script>
193
</body>
194
</html>
195
Script Preparation code:
 
/*
Copyright (c) 2010 Nik Kalyani nik@kalyani.com http://www.kalyani.com
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
(function ($) {
    var plugin = {
        defaults: {
            debug: false,
            grid: false
        },
        options: {
    },
    identity: function (type) {
        if (type === undefined) type = "name";
        switch (type.toLowerCase()) {
            case "version": return "1.0.0"; break;
            default: return "subwayMap Plugin"; break;
        }
    },
    _debug: function (s) {
        if (this.options.debug)
            this._log(s);
    },
    _log: function () {
        if (window.console && window.console.log)
            window.console.log('[subwayMap] ' + Array.prototype.join.call(arguments, ' '));
    },
    _supportsCanvas: function () {
        var canvas = $("<canvas></canvas>");
        if (canvas[0].getContext)
            return true;
        else
            return false;
    },
    _getCanvasLayer: function (el, overlay) {
        this.layer++;
        var canvas = $("<canvas style='position:absolute;z-Index:" + ((overlay ? 2000 : 1000) + this.layer) + "' width='" + this.options.pixelWidth + "' height='" + this.options.pixelHeight + "'></canvas>");
        el.append(canvas);
        return (canvas[0].getContext("2d"));
    },
    _render: function (el) {
        this.layer = -1;
        var rows = el.attr("data-rows");
        if (rows === undefined) 
            rows = 10;
        else
            rows = parseInt(rows);
        var columns = el.attr("data-columns");
        if (columns === undefined) 
            columns = 10;
        else
            columns = parseInt(columns);
        var scale = el.attr("data-cellSize");
        if (scale === undefined) 
            scale = 100;
        else
            scale = parseInt(scale);
        var lineWidth = el.attr("data-lineWidth");
        if (lineWidth === undefined) 
            lineWidth = 10;
        else
            lineWidth = parseInt(lineWidth);
        var textClass = el.attr("data-textClass");
        if (textClass === undefined) textClass = "";
        var grid = el.attr("data-grid");
        if ((grid === undefined) || (grid.toLowerCase() == "false"))
            grid = false;
        else
            grid = true;
        var legendId = el.attr("data-legendId");
        if (legendId === undefined) legendId = "";
        var gridNumbers = el.attr("data-gridNumbers");
        if ((gridNumbers === undefined) || (gridNumbers.toLowerCase() == "false"))
            gridNumbers = false;
        else
            gridNumbers = true;
        var reverseMarkers = el.attr("data-reverseMarkers");
        if ((reverseMarkers === undefined) || (reverseMarkers.toLowerCase() == "false"))
            reverseMarkers = false;
        else
            reverseMarkers = true;
        this.options.pixelWidth = columns * scale;
        this.options.pixelHeight = rows * scale;
        //el.css("width", this.options.pixelWidth);
        //el.css("height", this.options.pixelHeight);
        self = this;
        var lineLabels = [];
        var supportsCanvas = $("<canvas></canvas>")[0].getContext;
        if (supportsCanvas) {
            if (grid) this._drawGrid(el, scale, gridNumbers);
            $(el).children("ul").each(function (index) {
                var ul = $(this);
                var color = $(ul).attr("data-color");
                if (color === undefined) color = "#000000";
                var lineTextClass = $(ul).attr("data-textClass");
                if (lineTextClass === undefined) lineTextClass = "";                
                var shiftCoords = $(ul).attr("data-shiftCoords");
                if (shiftCoords === undefined) shiftCoords = "";
                var shiftX = 0.00;
                var shiftY = 0.00;
                if (shiftCoords.indexOf(",") > -1) {
                    shiftX = parseInt(shiftCoords.split(",")[0]) * lineWidth/scale;
                    shiftY = parseInt(shiftCoords.split(",")[1]) * lineWidth/scale;
                }
                var lineLabel = $(ul).attr("data-label");
                if (lineLabel === undefined) 
                    lineLabel = "Line " + index;
                lineLabels[lineLabels.length] = {label: lineLabel, color: color};
                var nodes = [];
                $(ul).children("li").each(function () {
                    var coords = $(this).attr("data-coords");
                    if (coords === undefined) coords = "";
                    var dir = $(this).attr("data-dir");
                    if (dir === undefined) dir = "";
                    var labelPos = $(this).attr("data-labelPos");
                    if (labelPos === undefined) labelPos = "s";
                    var marker = $(this).attr("data-marker");
                    if (marker == undefined) marker = "";
                    var markerInfo = $(this).attr("data-markerInfo");
                    if (markerInfo == undefined) markerInfo = "";
                    var anchor = $(this).children("a:first-child");
                    var label = $(this).text();
                    if (label === undefined) label = "";
                    var link = "";
                    var title = "";
                    if (anchor != undefined) {
                        link = $(anchor).attr("href");
                        if (link === undefined) link = "";
                        title = $(anchor).attr("title");
                        if (title === undefined) title = "";
                    }
                    self._debug("Coords=" + coords + "; Dir=" + dir + "; Link=" + link + "; Label=" + label + "; labelPos=" + labelPos + "; Marker=" + marker);
                    var x = "";
                    var y = "";
                    if (coords.indexOf(",") > -1) {
                        x = Number(coords.split(",")[0]) + (marker.indexOf("interchange") > -1 ? 0 : shiftX);
                        y = Number(coords.split(",")[1]) + (marker.indexOf("interchange") > -1 ? 0 : shiftY);
                    }
                    nodes[nodes.length] = { x: x, y:y, direction: dir, marker: marker, markerInfo: markerInfo, link: link, title: title, label: label, labelPos: labelPos};
                });
                if (nodes.length > 0)
                    self._drawLine(el, scale, rows, columns, color, (lineTextClass != "" ? lineTextClass : textClass), lineWidth, nodes, reverseMarkers);
                $(ul).remove();
            });
            if ((lineLabels.length > 0) && (legendId != ""))
            {
                var legend = $("#" + legendId);
                for(var line=0; line<lineLabels.length; line++)
                    legend.append("<div><span style='float:left;width:100px;height:" + lineWidth + "px;background-color:" + lineLabels[line].color + "'></span>" + lineLabels[line].label + "</div>");
            }
        }
    },
    _drawLine: function (el, scale, rows, columns, color, textClass, width, nodes, reverseMarkers) {
        var ctx = this._getCanvasLayer(el, false);
        ctx.beginPath();
        ctx.moveTo(nodes[0].x * scale, nodes[0].y * scale);
        var markers = [];
        var lineNodes = [];
        for(var node = 0; node < nodes.length; node++)
        {
            if (nodes[node].marker.indexOf("@") != 0)
                lineNodes[lineNodes.length] = nodes[node];
        }
        for (var lineNode = 0; lineNode < lineNodes.length; lineNode++) {
            if (lineNode < (lineNodes.length - 1)) {
                var nextNode = lineNodes[lineNode + 1];
                var currNode = lineNodes[lineNode];
                // Correction for edges so lines are not running off campus
                var xCorr = 0;
                var yCorr = 0;
                if (nextNode.x == 0) xCorr = width / 2;
                if (nextNode.x == columns) xCorr = -1 * width / 2;
                if (nextNode.y == 0) yCorr = width / 2;
                if (nextNode.y == rows) yCorr = -1 * width / 2;
                var xVal = 0;
                var yVal = 0;
                var direction = "";
                var xDiff = Math.round(Math.abs(currNode.x - nextNode.x));
                var yDiff = Math.round(Math.abs(currNode.y - nextNode.y));
                if ((xDiff == 0) || (yDiff == 0)) {
                    // Horizontal or Vertical
                    ctx.lineTo((nextNode.x * scale) + xCorr, (nextNode.y * scale) + yCorr);
                }
                else if ((xDiff == 1) && (yDiff == 1)) {
                    // 90 degree turn
                    if (nextNode.direction != "")
                        direction = nextNode.direction.toLowerCase();
                    switch (direction) {
                        case "s": xVal = 0; yVal = scale; break;
                        case "e": xVal = scale; yVal = 0; break;
                        case "w": xVal = -1 * scale; yVal = 0; break;
                        default: xVal = 0; yVal = -1 * scale; break;
                    }
                    ctx.quadraticCurveTo((currNode.x * scale) + xVal, (currNode.y * scale) + yVal,
                                                    (nextNode.x * scale) + xCorr, (nextNode.y * scale) + yCorr);
                }
                else if (xDiff == yDiff) {
                    // Symmetric, angular with curves at both ends
                    if (nextNode.x < currNode.x) {
                        if (nextNode.y < currNode.y)
                            direction = "nw";
                        else
                            direction = "sw";
                    }
                    else {
                        if (nextNode.y < currNode.y)
                            direction = "ne";
                        else
                            direction = "se";
                    }
                    var dirVal = 1;
                    switch (direction) {
                        case "nw": xVal = -1 * (scale / 2); yVal = 1; dirVal = 1; break;
                        case "sw": xVal = -1 * (scale / 2); yVal = -1; dirVal = 1; break;
                        case "se": xVal = (scale / 2); yVal = -1; dirVal = -1; break;
                        case "ne": xVal = (scale / 2); yVal = 1; dirVal = -1; break;
                    }
                    this._debug((currNode.x * scale) + xVal + ", " + (currNode.y * scale) + "; " + (nextNode.x + (dirVal * xDiff / 2)) * scale + ", " +
                    (nextNode.y + (yVal * xDiff / 2)) * scale)
                    ctx.bezierCurveTo(
                            (currNode.x * scale) + xVal, (currNode.y * scale),
                            (currNode.x * scale) + xVal, (currNode.y * scale),
                            (nextNode.x + (dirVal * xDiff / 2)) * scale, (nextNode.y + (yVal * xDiff / 2)) * scale);
                    ctx.bezierCurveTo(
                            (nextNode.x * scale) + (dirVal * scale / 2), (nextNode.y) * scale,
                            (nextNode.x * scale) + (dirVal * scale / 2), (nextNode.y) * scale,
                            nextNode.x * scale, nextNode.y * scale);
                }
                else
                    ctx.lineTo(nextNode.x * scale, nextNode.y * scale);
            }
        } 
        ctx.strokeStyle = color;
        ctx.lineWidth = width;
        ctx.stroke();
        ctx = this._getCanvasLayer(el, true);
        for (var node = 0; node < nodes.length; node++) {
            this._drawMarker(el, ctx, scale, color, textClass, width, nodes[node], reverseMarkers);
        }
    },
    _drawMarker: function (el, ctx, scale, color, textClass, width, data, reverseMarkers) {
        if (data.label == "") return;
        if (data.marker == "") data.marker = "station";
        // Scale coordinates for rendering
        var x = data.x * scale;
        var y = data.y * scale;
        // Keep it simple -- black on white, or white on black
        var fgColor = "#000000";
        var bgColor = "#ffffff";
        if (reverseMarkers)
        {
            fgColor = "#ffffff";
            bgColor = "#000000";
        }
        // Render station and interchange icons
        ctx.strokeStyle = fgColor;
        ctx.fillStyle = bgColor;
        ctx.beginPath();
        switch(data.marker.toLowerCase())
        {
            case "interchange":
            case "@interchange":
                ctx.lineWidth = width;
                if (data.markerInfo == "")
                    ctx.arc(x, y, width * 0.7, 0, Math.PI * 2, true);
                else
                {
                    var mDir = data.markerInfo.substr(0,1).toLowerCase();
                    var mSize = parseInt(data.markerInfo.substr(1,10));
                    if (((mDir == "v") || (mDir == "h")) && (mSize > 1))
                    {
                        if (mDir == "v")
                        {
                            ctx.arc(x, y, width * 0.7,290 * Math.PI/180, 250 * Math.PI/180, false);
                            ctx.arc(x, y-(width*mSize), width * 0.7,110 * Math.PI/180, 70 * Math.PI/180, false);
                        }
                        else
                        {
                            ctx.arc(x, y, width * 0.7,20 * Math.PI/180, 340 * Math.PI/180, false);
                            ctx.arc(x+(width*mSize), y, width * 0.7,200 * Math.PI/180, 160 * Math.PI/180, false);
                        }
                    }
                    else
                        ctx.arc(x, y, width * 0.7, 0, Math.PI * 2, true);
                }
                break;
            case "station":
            case "@station":
                ctx.lineWidth = width/2;
                ctx.arc(x, y, width/2, 0, Math.PI * 2, true);
                break;
        }
        ctx.closePath();
        ctx.stroke();
        ctx.fill();
        
        // Render text labels and hyperlinks
        var pos = "";
        var offset = width + 4;
        var topOffset = 0;
        var centerOffset = "-50px";
        switch(data.labelPos.toLowerCase())
        {
            case "n":
                pos = "text-align: center; margin: 0 0 " + offset + "px " + centerOffset;
                topOffset = offset * 2;
                break;
            case "w":
                pos = "text-align: right; margin:0 " + offset + "px 0 -" + (100 + offset) + "px";
                topOffset = offset;
                break;
            case "e":
                pos = "text-align: left; margin:0 0 0 " + offset + "px";
                topOffset = offset;
                break;
            case "s":
                pos = "text-align: center; margin:" + offset + "px 0 0 " + centerOffset;
                break;
            case "se":
                pos = "text-align: left; margin:" + offset + "px 0 0 " + offset + "px";
                break;
            case "ne":
                pos = "text-align: left; padding-left: " + offset + "px; margin: 0 0 " + offset + "px 0";
                topOffset = offset * 2;
                break;
            case "sw": //TODO
                pos = "text-align: right; margin:0 " + offset + "px 0 -" + (100 + offset) + "px";
                topOffset = offset;
                break;
            case "nw": //TODO
                pos = "text-align: right; margin:0 " + offset + "px 0 -" + (100 + offset) + "px";
                topOffset = offset;
                break;
        }
        var style = (textClass != "" ? "class='" + textClass + "' " : "") + "style='" + (textClass == "" ? "font-size:8pt;font-family:Verdana,Arial,Helvetica,Sans Serif;text-decoration:none;" : "") + "width:100px;" + (pos != "" ? pos : "") + ";position:absolute;top:" + (y + el.offset().top - (topOffset > 0 ? topOffset : 0)) + "px;left:" + (x + el.offset().left) + "px;z-index:3000;'";
        if (data.link != "")
            $("<a " + style + " title='" + data.title.replace(/\\n/g,"<br />") + "' href='" + data.link + "' target='_parent'>" + data.label.replace(/\\n/g,"<br />") + "</span>").appendTo(el);
        else
            $("<span " + style + ">" + data.label.replace(/\\n/g,"<br />") + "</span>").appendTo(el);;
        
    },
    _drawGrid: function (el, scale, gridNumbers) {
        var ctx = this._getCanvasLayer(el, false);
        ctx.fillStyle = "#000";
        ctx.beginPath();
        var counter = 0;
        for (var x = 0.5; x < this.options.pixelWidth; x += scale) {
            if (gridNumbers)
            {
                ctx.moveTo(x, 0);
                ctx.fillText(counter++, x-15, 10);
            }
            ctx.moveTo(x, 0);
            ctx.lineTo(x, this.options.pixelHeight);
        }
        ctx.moveTo(this.options.pixelWidth - 0.5, 0);
        ctx.lineTo(this.options.pixelWidth - 0.5, this.options.pixelHeight);
        counter = 0;
        for (var y = 0.5; y < this.options.pixelHeight; y += scale) {
            if (gridNumbers)
            {
                ctx.moveTo(0, y);
                ctx.fillText(counter++, 0, y-15);
            }
            ctx.moveTo(0, y);
            ctx.lineTo(this.options.pixelWidth, y);
        }
        ctx.moveTo(0, this.options.pixelHeight - 0.5);
        ctx.lineTo(this.options.pixelWidth, this.options.pixelHeight - 0.5);
        ctx.strokeStyle = "#eee";
        ctx.lineWidth = 1;
        ctx.stroke();
        ctx.fill();
        ctx.closePath();
    }
}
var methods = {
    init: function (options) {
        plugin.options = $.extend({}, plugin.defaults, options);
        // iterate and reformat each matched element
        return this.each(function (index) {
            plugin.options = $.meta
                                    ? $.extend(plugin.options, $(this).data())
                                    : plugin.options;
            plugin._debug("BEGIN: " + plugin.identity() + " for element " + index);
            plugin._render($(this));
            plugin._debug("END: " + plugin.identity() + " for element " + index);
        });
    },
    drawLine: function (data) {
        plugin._drawLine(data.element, data.scale, data.rows, data.columns, data.color, data.width, data.nodes);
    },
};
$.fn.subwayMap = function (method) {
    // Method calling logic
    if (methods[method]) {
        return methods[method].apply(this, Array.prototype.slice.call(arguments, 1));
    } else if (typeof method === 'object' || !method) {
        return methods.init.apply(this, arguments);
    } else {
        $.error('Method ' + method + ' does not exist on jQuery.tooltip');
    }
};
})(jQuery);
Tests:
  • test1

     
    1
  • test2

     
    2
Rendered benchmark preparation results:

Suite status: <idle, ready to run>

Previous results

Experimental features:

  • Test case name Result
    test1
    test2

    Fastest: N/A

    Slowest: N/A

Latest run results:
Run details: (Test run date: 8 years ago)
Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/53.0.2785.116 Safari/537.36
Chrome 53 on Mac OS X 10.11.6
View result in a separate tab
Test name Executions per second
test1 100463352.0 Ops/sec
test2 96446480.0 Ops/sec