// version: 2019-05-27 /** * o--------------------------------------------------------------------------------o * | This file is part of the RGraph package - you can learn more at: | * | | * | https://www.rgraph.net | * | | * | RGraph is licensed under the Open Source MIT license. That means that it's | * | totally free to use and there are no restrictions on what you can do with it! | * o--------------------------------------------------------------------------------o */ RGraph = window.RGraph || {isRGraph: true}; RGraph.SVG = RGraph.SVG || {}; RGraph.SVG.HTML = RGraph.SVG.HTML || {}; // Module pattern (function (win, doc, undefined) { var RG = RGraph, ua = navigator.userAgent, ma = Math; /** * Draws the graph key (used by various graphs) * * @param object obj The graph object * @param array key An array of the texts to be listed in the key * @param colors An array of the colors to be used */ RG.SVG.drawKey = function (obj) { var prop = obj.properties, key = prop.key, colors = prop.keyColors || prop.colors, defaultFont = 'Arial', blobSize = 0, width = 0, keyColorShape = prop.keyColorShape; // Work out the center point of the SVG tag var centerx = obj.svg.getAttribute('width') / 2; // If we're drawing a key on a funnel then work out the center of // the chart differently. This may be useful to other chart types // too if (obj.type === 'funnel') { centerx = (obj.graphWidth / 2) + prop.marginLeft; } // Loop thru the key and draw them if (key && key.length) { // First measure the length so that the key can be centered for (var i=0,length = 0; i'; /** * Add the individual key elements */ for (var i=0; i ' + (prop.links && prop.links[i] ? '' : '') + '' + prop.labels[i] + '' + (prop.links && prop.links[i] ? '' : '') + ''; } div.innerHTML += (str + ''); // Return the TABLE object that is the HTML key return doc.getElementById('rgraph_key'); }; // End module pattern })(window, document);