pax_global_header 0000666 0000000 0000000 00000000064 12157227240 0014514 g ustar 00root root 0000000 0000000 52 comment=0ab30df52d464f54ea0fb4b8b58c317ecba0fb8d jquery.sparkline-2.1.2/ 0000775 0000000 0000000 00000000000 12157227240 0015024 5 ustar 00root root 0000000 0000000 jquery.sparkline-2.1.2/.gitignore 0000664 0000000 0000000 00000000065 12157227240 0017015 0 ustar 00root root 0000000 0000000 # Ignore vim temp files .*.sw[a-z] *.un~ Session.vim jquery.sparkline-2.1.2/Changelog.txt 0000664 0000000 0000000 00000023513 12157227240 0017460 0 ustar 00root root 0000000 0000000 jQuery Sparkline Plugin ChangeLog http://omnipotent.net/jquery.sparkline/ 2.1.2 ??? + Make compatible with jQuery 1.10 + Fix intermittent "undefined error" with IE8 (issue 64) Thanks Tim Tucker 2.1.1 26/January/2013 + Fix a couple of issues rendering pie charts in IE when they slices that make up a negligible percentage of the whole chart (issue 49) + Don't display line chart final marker if final value is null (issue 46) + Make compatible with jQuery 1.9.0 (issue 60) 2.1 15/October/2012 + Added support for Internet Explorer 10 (issue 18) Thanks Jonathan Sampson + Enable the plugin to be loaded dynamically (issue 6) Thanks joeenzminger + Pie charts with zero in the array of values will no longer cause IE to display "undefined" in the page (issue 9) + Null values in bar charts are now correctly omitted by default (issue 23) + Null values in line charts would cause value highligting to be incorrect (issue 4) + Raise default z-index for tooltips to ensure they always appear on top of the chart (issue 5) + Allow target and performance values to be set to null for bullet charts, omitting them from the chart (issue 3) + Fix clipping of highlight marker spots if min/max/final spots are disabled in line charts (issue 31) + Line charts with normalRangeMin=0 will now render the normal range correctly (issue 7) Thanks Tim Mathewso + Add support for AMD based module loaders such as requirejs (PR 32) Thanks Tim Tucker + Fix interquartile range calculation used by box plots (PR 10) Thanks Claudio Riva 2.0 29/April/2012 + jQuery.sparkline now requires jQuery 1.4.3 or later + All charts now support mouseover and click actions Adds options: disableInteraction, disableTooltips, disableHighlight + Added sparklineClick and sparklineRegionChange events + Line charts have highlightSpotColor and highlightLineColor options for controlling mouseover highligiting + All charts display tooltips and highlight values when moused-over by default Adds options: tooltipContainer, tooltipOffsetX, tooltipOffsetY, tooltipFormatter, tooltipChartTitle, tooltipFormat, tooltipPrefix, tooltipSuffix, tooltipSkipNull, tooltipValueLookups, highlightLighten, numberFormatter, numberDigitGroupSep, numberDecimalMark, numberDigitGroupCount + Fix error when all null values are fed to a line chart Thanks Ton Voon + Fix off-by-one error that caused the bottom of filled line charts to be unlevel - Thanks Sylvain Vieujot for the bug report + Pie charts with a single value now render correctly Thanks Juan Manuel + Charts that have their dimensions specified exactly in pixels may see improved performance Thanks Sean Carpenter + Coloured spots may be added to some or all values on a line chart now using the new valueSpots option Thanks Russ Beebe for the suggestion + Bar and tristates charts now support using range of values for the colorMap option - Eg. allows all bars with values betweeen 10 and 20 to be green + Pie charts may now have a border using the borderWidth and borderColor options - Thanks Michael Mior for the suggestion + Added a disableHiddenCheck option - If you know your charts will never be in a hidden block (display:none) at time of rendering, disabling this check may improve performance + Reduce number of DOM interactions when rendering charts in Internet Explorer to increase render performance + Bar charts may now have stacked values by providing an array of arrays or by passing a comma and colon delimited series of values (eg. "1:2:3,2:3:1") + Fix a bug where some spots would be drawn in the wrong position on line charts if the x values were supplied as well as the y + Fix a bug causing hidden composite sparklines to fail to render once $.sparkline_display_visible() is called. + If there are multiple calls to sparkline() on a hidden element, the plugin will now only render the most recent one when the element becomes visible, saving CPU time for the same visual result. + If a hidden sparkline waiting to be rendered is removed from the DOM via jQuery's .remove() or .html() etc methods then it will be removed from the pending queue the next time $.sparkline_display_visible() is called, preventing a memory leak. + Add the $.range_map() and $.spformat() methods 1.6 30/November/2010 + Allow options to be set as tag attributes, as well as passed in to the sparkline function as an argument. See new enableTagOptions and tagOptionPrefix options. + Added alternate methods of passing values in via HTML. Can now include inline values in a comment, or pass values in as a values attribute on the tag: + bullet graphs now handle non-integer values correctly + Added drawNormalOnTop option to line charts to force the normal range to be drawn over the top of the line chart's fill color + Detect if an element is not inserted into the DOM so that $.sparkline_display_visible() will function correctly after it's later inserted. + Remove the use of the Array indexOf prototype that was added to IE to avoid conflicts with other libraries. + Default settings are now exposed as $.fn.sparkline.defaults allowing script-wide changes to be made instead of passing them to the sparkline function on each call 1.5.1 01/March/2010 + 1 character typo fix for IE - Thanks to Daniel Kenyon-Jones for the heads up 1.5 26/February/2010 + Very small pie slices could fill the whole chart in IE Thanks to Peter Doel for catching and fixing it + Added chartRangeClip option to force values outside of chartRangeMin/chartRangeMax to be clipped + Added chartRangeMinX/chartRangeMaxX for line charts + Allow chart types other than line chart to be used as composites. + colorMap may now pass null as a colour to omit that bar from display entirely + colorMap may now be passed as an Array of values allowing the colour of each bar to be specified individually, rather than mapping by value + Added nullColor option to bar charts to force null values to show up as a thin line + Performance improvements with IE 1.4.3 14/September/2009 + Updated default pie chart colours - Thanks Liel Dulev + Null values can now be supplied to line and bar charts (use 'null' as the value) - Thanks to Ed Blachman for testing/debugging help + Added colorMap option for bar charts + Added lineWidth option for line charts - Can be an integer or a float (try 1.5 or 2) 1.4.2 25/April/2009 + Fixed rendering of circular spots on line charts for Internet Explorer 8 1.4.1 27/March/2009 + Fixed minor off-by-1-pixel display glitch with IE + Improved compatibilty with jQuery 1.3 which could cause some sparklines not to be rendered in certain situations 1.4 25/February/2009 + Added the box plot chart type + Fixed a canvas rendering issue that would display some charts with fuzzy lines + Fixed error in bar charts which would causes bars to be too short. + Couple of other minor bug fixes 1.3 25/January/2009 + Sparklines can't be automatically displayed into hidden elements (ie. with display:none) - Added a $.sparkline_display_visible() function to render any sparklines that were generated while a tag was hidden + Fixed positioning issues where sparklines would be displayed a few pixels offset from their containers in some browsers + Made a first attempt at IE8 support. IE8 beta 2 seems to have some vml related bugs though so having more than one sparkline on a line doesn't work correctly, nor do the markers on line charts + Misc other bug fixes + Updated the web site with a new look 1.2.1 24/November/2008 + Pie chart bug fixes: Divide by zero error resolved and IE rendering issue if a pie slice is equal to 0 Thanks to Hubert Mandeville for a patch fixing both issues 1.2 - 19/November/2008 + Fixed positioning of min/max line markers for fixed range graphs (thanks to Stéphane Busso) + Fixed rendering of bar charts with negative values + All values in a bar chart have a height now (min values used to have height = 0) + Added zeroColor option for bar charts which allows assignment of a different color for values that are equal to zero + Line charts can now specify both x and y values if required in one of three ways: a) Inline with HTML with values interleaved: x1:y1,x2:y2,x3:y3 eg. 1:10,5:8,7:10 b) Programatically using an x,y array for each value: $('#mychart').sparkline([ [1,10], [5,8], [7,10] ]); c) Programatically using a separate array for the x values: $('#mychart').sparkline( [10,8,10], { xvalues: [1,5,7] }); + Added chartRangeMin and chartRangeMax to line, bar and discrete graphs This allows you to artificialy fix the min/max values for the graph so that multiple graphs can share the same scale. + Added defaultPixelsPerValue option to specify how many pixels wide each value should be in a dynamically sized line graph + Added offset option to piecharts - Takes a positive or negative degree offset to start drawing the chart from. 1.1 - 29/July/2008 + Added minSpotColor and maxSpotColor to line charts - If set then spot markers are placed at the cordinates of the minimum and maximum values. + Added normalRangeMin and normalRangeMax to line charts - If set then a normalRangeColor band will be drawn on the graph + Added chart compositing - Applying another chart to a DOM element with an option of composite: true will cause the second (or more) chart to be overlayed on the first rather than replacing it. + Added optional colorMap option to tristate chart - This allows specific colors to be supplied for specific values + Added discrete chart type - Uses fixed size discrete vertical lines to mark each values in a series + Added bullet graph type - Implementation of Stephen Few's bullet graphs + Added pie chart type + Improved auto height option to match the line height of the containing element + Fixed some off by one positioning errors + Reduced the default radius of spot markers from 2 to 1.5 pixels 1.0 - 17/July/2008 + Initial Release jquery.sparkline-2.1.2/Makefile 0000664 0000000 0000000 00000002125 12157227240 0016464 0 ustar 00root root 0000000 0000000 SRC_DIR = src DIST_DIR = dist COMPILER ?= `which uglifyjs` --no-copyright SRC_FILES = $(SRC_DIR)/header.js\ $(SRC_DIR)/defaults.js\ $(SRC_DIR)/utils.js\ $(SRC_DIR)/simpledraw.js\ $(SRC_DIR)/rangemap.js\ $(SRC_DIR)/interact.js\ $(SRC_DIR)/base.js\ $(SRC_DIR)/chart-line.js\ $(SRC_DIR)/chart-bar.js\ $(SRC_DIR)/chart-tristate.js\ $(SRC_DIR)/chart-discrete.js\ $(SRC_DIR)/chart-bullet.js\ $(SRC_DIR)/chart-pie.js\ $(SRC_DIR)/chart-box.js\ $(SRC_DIR)/vcanvas-base.js\ $(SRC_DIR)/vcanvas-canvas.js\ $(SRC_DIR)/vcanvas-vml.js\ $(SRC_DIR)/footer.js VERSION = $(shell cat version.txt) all: jqs-gzip jqs-min-gzip Changelog.txt cp Changelog.txt dist/ jqs: ${SRC_FILES} cat ${SRC_FILES} | sed 's/@VERSION@/${VERSION}/' >${DIST_DIR}/jquery.sparkline.js jqs-min: jqs cat minheader.txt | sed 's/@VERSION@/${VERSION}/' >dist/jquery.sparkline.min.js ${COMPILER} dist/jquery.sparkline.js >>dist/jquery.sparkline.min.js jqs-gzip: jqs gzip -9 < dist/jquery.sparkline.js >dist/jquery.sparkline.js.gz jqs-min-gzip: jqs-min gzip -9 < dist/jquery.sparkline.min.js >dist/jquery.sparkline.min.js.gz jquery.sparkline-2.1.2/README.md 0000664 0000000 0000000 00000001056 12157227240 0016305 0 ustar 00root root 0000000 0000000 jQuery Sparklines ================= This jQuery plugin makes it easy to generate a number of different types of sparklines directly in the browser, using online a line of two of HTML and Javascript. The plugin has no dependencies other than jQuery and works with all modern browsers and also Internet Explorer 6 and later (excanvas is not required for IE support). See the [jQuery Sparkline project page](http://omnipotent.net/jquery.sparkline/) for live examples and documentation. ## License Released under the New BSD License (c) Splunk, Inc 2012 jquery.sparkline-2.1.2/dist/ 0000775 0000000 0000000 00000000000 12157227240 0015767 5 ustar 00root root 0000000 0000000 jquery.sparkline-2.1.2/dist/.gitignore 0000664 0000000 0000000 00000000016 12157227240 0017754 0 ustar 00root root 0000000 0000000 * !.gitignore jquery.sparkline-2.1.2/minheader.txt 0000664 0000000 0000000 00000000220 12157227240 0017513 0 ustar 00root root 0000000 0000000 /* jquery.sparkline @VERSION@ - http://omnipotent.net/jquery.sparkline/ ** Licensed under the New BSD License - see above site for details */ jquery.sparkline-2.1.2/sparkline.jquery.json 0000664 0000000 0000000 00000001670 12157227240 0021231 0 ustar 00root root 0000000 0000000 { "name": "sparkline", "title": "jQuery Sparkline", "description": "Easily generate small, inline sparkline charts directly in the browser", "keywords": [ "canvas", "charts", "graphics", "graphing", "graphs", "sparklines", "ui", "vml" ], "version": "2.1.2", "author": { "name": "Gareth Watts", "url": "http://gwatts.com/" }, "licenses": [ { "type": "BSD-3-Clause", "url": "http://opensource.org/licenses/BSD-3-Clause" } ], "bugs": "https://github.com/gwatts/jquery.sparkline/issues", "homepage": "http://omnipotent.net/jquery.sparkline/", "demo": "http://omnipotent.net/jquery.sparkline/", "docs": "http://omnipotent.net/jquery.sparkline/#s-docs", "download": "http://omnipotent.net/jquery.sparkline/#s-download", "dependencies": { "jquery": ">=1.4.3" } } jquery.sparkline-2.1.2/src/ 0000775 0000000 0000000 00000000000 12157227240 0015613 5 ustar 00root root 0000000 0000000 jquery.sparkline-2.1.2/src/base.js 0000664 0000000 0000000 00000036373 12157227240 0017077 0 ustar 00root root 0000000 0000000 initStyles = function() { addCSS(defaultStyles); }; $(initStyles); pending = []; $.fn.sparkline = function (userValues, userOptions) { return this.each(function () { var options = new $.fn.sparkline.options(this, userOptions), $this = $(this), render, i; render = function () { var values, width, height, tmp, mhandler, sp, vals; if (userValues === 'html' || userValues === undefined) { vals = this.getAttribute(options.get('tagValuesAttribute')); if (vals === undefined || vals === null) { vals = $this.html(); } values = vals.replace(/(^\s*\s*$)|\s+/g, '').split(','); } else { values = userValues; } width = options.get('width') === 'auto' ? values.length * options.get('defaultPixelsPerValue') : options.get('width'); if (options.get('height') === 'auto') { if (!options.get('composite') || !$.data(this, '_jqs_vcanvas')) { // must be a better way to get the line height tmp = document.createElement('span'); tmp.innerHTML = 'a'; $this.html(tmp); height = $(tmp).innerHeight() || $(tmp).height(); $(tmp).remove(); tmp = null; } } else { height = options.get('height'); } if (!options.get('disableInteraction')) { mhandler = $.data(this, '_jqs_mhandler'); if (!mhandler) { mhandler = new MouseHandler(this, options); $.data(this, '_jqs_mhandler', mhandler); } else if (!options.get('composite')) { mhandler.reset(); } } else { mhandler = false; } if (options.get('composite') && !$.data(this, '_jqs_vcanvas')) { if (!$.data(this, '_jqs_errnotify')) { alert('Attempted to attach a composite sparkline to an element with no existing sparkline'); $.data(this, '_jqs_errnotify', true); } return; } sp = new $.fn.sparkline[options.get('type')](this, values, options, width, height); sp.render(); if (mhandler) { mhandler.registerSparkline(sp); } }; if (($(this).html() && !options.get('disableHiddenCheck') && $(this).is(':hidden')) || !$(this).parents('body').length) { if (!options.get('composite') && $.data(this, '_jqs_pending')) { // remove any existing references to the element for (i = pending.length; i; i--) { if (pending[i - 1][0] == this) { pending.splice(i - 1, 1); } } } pending.push([this, render]); $.data(this, '_jqs_pending', true); } else { render.call(this); } }); }; $.fn.sparkline.defaults = getDefaults(); $.sparkline_display_visible = function () { var el, i, pl; var done = []; for (i = 0, pl = pending.length; i < pl; i++) { el = pending[i][0]; if ($(el).is(':visible') && !$(el).parents().is(':hidden')) { pending[i][1].call(el); $.data(pending[i][0], '_jqs_pending', false); done.push(i); } else if (!$(el).closest('html').length && !$.data(el, '_jqs_pending')) { // element has been inserted and removed from the DOM // If it was not yet inserted into the dom then the .data request // will return true. // removing from the dom causes the data to be removed. $.data(pending[i][0], '_jqs_pending', false); done.push(i); } } for (i = done.length; i; i--) { pending.splice(done[i - 1], 1); } }; /** * User option handler */ $.fn.sparkline.options = createClass({ init: function (tag, userOptions) { var extendedOptions, defaults, base, tagOptionType; this.userOptions = userOptions = userOptions || {}; this.tag = tag; this.tagValCache = {}; defaults = $.fn.sparkline.defaults; base = defaults.common; this.tagOptionsPrefix = userOptions.enableTagOptions && (userOptions.tagOptionsPrefix || base.tagOptionsPrefix); tagOptionType = this.getTagSetting('type'); if (tagOptionType === UNSET_OPTION) { extendedOptions = defaults[userOptions.type || base.type]; } else { extendedOptions = defaults[tagOptionType]; } this.mergedOptions = $.extend({}, base, extendedOptions, userOptions); }, getTagSetting: function (key) { var prefix = this.tagOptionsPrefix, val, i, pairs, keyval; if (prefix === false || prefix === undefined) { return UNSET_OPTION; } if (this.tagValCache.hasOwnProperty(key)) { val = this.tagValCache.key; } else { val = this.tag.getAttribute(prefix + key); if (val === undefined || val === null) { val = UNSET_OPTION; } else if (val.substr(0, 1) === '[') { val = val.substr(1, val.length - 2).split(','); for (i = val.length; i--;) { val[i] = normalizeValue(val[i].replace(/(^\s*)|(\s*$)/g, '')); } } else if (val.substr(0, 1) === '{') { pairs = val.substr(1, val.length - 2).split(','); val = {}; for (i = pairs.length; i--;) { keyval = pairs[i].split(':', 2); val[keyval[0].replace(/(^\s*)|(\s*$)/g, '')] = normalizeValue(keyval[1].replace(/(^\s*)|(\s*$)/g, '')); } } else { val = normalizeValue(val); } this.tagValCache.key = val; } return val; }, get: function (key, defaultval) { var tagOption = this.getTagSetting(key), result; if (tagOption !== UNSET_OPTION) { return tagOption; } return (result = this.mergedOptions[key]) === undefined ? defaultval : result; } }); $.fn.sparkline._base = createClass({ disabled: false, init: function (el, values, options, width, height) { this.el = el; this.$el = $(el); this.values = values; this.options = options; this.width = width; this.height = height; this.currentRegion = undefined; }, /** * Setup the canvas */ initTarget: function () { var interactive = !this.options.get('disableInteraction'); if (!(this.target = this.$el.simpledraw(this.width, this.height, this.options.get('composite'), interactive))) { this.disabled = true; } else { this.canvasWidth = this.target.pixelWidth; this.canvasHeight = this.target.pixelHeight; } }, /** * Actually render the chart to the canvas */ render: function () { if (this.disabled) { this.el.innerHTML = ''; return false; } return true; }, /** * Return a region id for a given x/y co-ordinate */ getRegion: function (x, y) { }, /** * Highlight an item based on the moused-over x,y co-ordinate */ setRegionHighlight: function (el, x, y) { var currentRegion = this.currentRegion, highlightEnabled = !this.options.get('disableHighlight'), newRegion; if (x > this.canvasWidth || y > this.canvasHeight || x < 0 || y < 0) { return null; } newRegion = this.getRegion(el, x, y); if (currentRegion !== newRegion) { if (currentRegion !== undefined && highlightEnabled) { this.removeHighlight(); } this.currentRegion = newRegion; if (newRegion !== undefined && highlightEnabled) { this.renderHighlight(); } return true; } return false; }, /** * Reset any currently highlighted item */ clearRegionHighlight: function () { if (this.currentRegion !== undefined) { this.removeHighlight(); this.currentRegion = undefined; return true; } return false; }, renderHighlight: function () { this.changeHighlight(true); }, removeHighlight: function () { this.changeHighlight(false); }, changeHighlight: function (highlight) {}, /** * Fetch the HTML to display as a tooltip */ getCurrentRegionTooltip: function () { var options = this.options, header = '', entries = [], fields, formats, formatlen, fclass, text, i, showFields, showFieldsKey, newFields, fv, formatter, format, fieldlen, j; if (this.currentRegion === undefined) { return ''; } fields = this.getCurrentRegionFields(); formatter = options.get('tooltipFormatter'); if (formatter) { return formatter(this, options, fields); } if (options.get('tooltipChartTitle')) { header += '
Sparkline: 1,4,6,6,8,5,3,5
* $('.sparkline').sparkline(); * There must be no spaces in the enclosed data set * * Otherwise values must be an array of numbers or null values *Sparkline: This text replaced if the browser is compatible
* $('#sparkline1').sparkline([1,4,6,6,8,5,3,5]) * $('#sparkline2').sparkline([1,4,6,null,null,5,3,5]) * * Values can also be specified in an HTML comment, or as a values attribute: *Sparkline:
*Sparkline:
* $('.sparkline').sparkline(); * * For line charts, x values can also be specified: *Sparkline: 1:1,2.7:4,3.4:6,5:6,6:8,8.7:5,9:3,10:5
* $('#sparkline1').sparkline([ [1,1], [2.7,4], [3.4,6], [5,6], [6,8], [8.7,5], [9,3], [10,5] ]) * * By default, options should be passed in as teh second argument to the sparkline function: * $('.sparkline').sparkline([1,2,3,4], {type: 'bar'}) * * Options can also be set by passing them on the tag itself. This feature is disabled by default though * as there's a slight performance overhead: * $('.sparkline').sparkline([1,2,3,4], {enableTagOptions: true}) *Sparkline: loading
* Prefix all options supplied as tag attribute with "spark" (configurable by setting tagOptionPrefix) * * Supported options: * lineColor - Color of the line used for the chart * fillColor - Color used to fill in the chart - Set to '' or false for a transparent chart * width - Width of the chart - Defaults to 3 times the number of values in pixels * height - Height of the chart - Defaults to the height of the containing element * chartRangeMin - Specify the minimum value to use for the Y range of the chart - Defaults to the minimum value supplied * chartRangeMax - Specify the maximum value to use for the Y range of the chart - Defaults to the maximum value supplied * chartRangeClip - Clip out of range values to the max/min specified by chartRangeMin and chartRangeMax * chartRangeMinX - Specify the minimum value to use for the X range of the chart - Defaults to the minimum value supplied * chartRangeMaxX - Specify the maximum value to use for the X range of the chart - Defaults to the maximum value supplied * composite - If true then don't erase any existing chart attached to the tag, but draw * another chart over the top - Note that width and height are ignored if an * existing chart is detected. * tagValuesAttribute - Name of tag attribute to check for data values - Defaults to 'values' * enableTagOptions - Whether to check tags for sparkline options * tagOptionPrefix - Prefix used for options supplied as tag attributes - Defaults to 'spark' * disableHiddenCheck - If set to true, then the plugin will assume that charts will never be drawn into a * hidden dom element, avoding a browser reflow * disableInteraction - If set to true then all mouseover/click interaction behaviour will be disabled, * making the plugin perform much like it did in 1.x * disableTooltips - If set to true then tooltips will be disabled - Defaults to false (tooltips enabled) * disableHighlight - If set to true then highlighting of selected chart elements on mouseover will be disabled * defaults to false (highlights enabled) * highlightLighten - Factor to lighten/darken highlighted chart values by - Defaults to 1.4 for a 40% increase * tooltipContainer - Specify which DOM element the tooltip should be rendered into - defaults to document.body * tooltipClassname - Optional CSS classname to apply to tooltips - If not specified then a default style will be applied * tooltipOffsetX - How many pixels away from the mouse pointer to render the tooltip on the X axis * tooltipOffsetY - How many pixels away from the mouse pointer to render the tooltip on the r axis * tooltipFormatter - Optional callback that allows you to override the HTML displayed in the tooltip * callback is given arguments of (sparkline, options, fields) * tooltipChartTitle - If specified then the tooltip uses the string specified by this setting as a title * tooltipFormat - A format string or SPFormat object (or an array thereof for multiple entries) * to control the format of the tooltip * tooltipPrefix - A string to prepend to each field displayed in a tooltip * tooltipSuffix - A string to append to each field displayed in a tooltip * tooltipSkipNull - If true then null values will not have a tooltip displayed (defaults to true) * tooltipValueLookups - An object or range map to map field values to tooltip strings * (eg. to map -1 to "Lost", 0 to "Draw", and 1 to "Win") * numberFormatter - Optional callback for formatting numbers in tooltips * numberDigitGroupSep - Character to use for group separator in numbers "1,234" - Defaults to "," * numberDecimalMark - Character to use for the decimal point when formatting numbers - Defaults to "." * numberDigitGroupCount - Number of digits between group separator - Defaults to 3 * * There are 7 types of sparkline, selected by supplying a "type" option of 'line' (default), * 'bar', 'tristate', 'bullet', 'discrete', 'pie' or 'box' * line - Line chart. Options: * spotColor - Set to '' to not end each line in a circular spot * minSpotColor - If set, color of spot at minimum value * maxSpotColor - If set, color of spot at maximum value * spotRadius - Radius in pixels * lineWidth - Width of line in pixels * normalRangeMin * normalRangeMax - If set draws a filled horizontal bar between these two values marking the "normal" * or expected range of values * normalRangeColor - Color to use for the above bar * drawNormalOnTop - Draw the normal range above the chart fill color if true * defaultPixelsPerValue - Defaults to 3 pixels of width for each value in the chart * highlightSpotColor - The color to use for drawing a highlight spot on mouseover - Set to null to disable * highlightLineColor - The color to use for drawing a highlight line on mouseover - Set to null to disable * valueSpots - Specify which points to draw spots on, and in which color. Accepts a range map * * bar - Bar chart. Options: * barColor - Color of bars for postive values * negBarColor - Color of bars for negative values * zeroColor - Color of bars with zero values * nullColor - Color of bars with null values - Defaults to omitting the bar entirely * barWidth - Width of bars in pixels * colorMap - Optional mappnig of values to colors to override the *BarColor values above * can be an Array of values to control the color of individual bars or a range map * to specify colors for individual ranges of values * barSpacing - Gap between bars in pixels * zeroAxis - Centers the y-axis around zero if true * * tristate - Charts values of win (>0), lose (<0) or draw (=0) * posBarColor - Color of win values * negBarColor - Color of lose values * zeroBarColor - Color of draw values * barWidth - Width of bars in pixels * barSpacing - Gap between bars in pixels * colorMap - Optional mappnig of values to colors to override the *BarColor values above * can be an Array of values to control the color of individual bars or a range map * to specify colors for individual ranges of values * * discrete - Options: * lineHeight - Height of each line in pixels - Defaults to 30% of the graph height * thesholdValue - Values less than this value will be drawn using thresholdColor instead of lineColor * thresholdColor * * bullet - Values for bullet graphs msut be in the order: target, performance, range1, range2, range3, ... * options: * targetColor - The color of the vertical target marker * targetWidth - The width of the target marker in pixels * performanceColor - The color of the performance measure horizontal bar * rangeColors - Colors to use for each qualitative range background color * * pie - Pie chart. Options: * sliceColors - An array of colors to use for pie slices * offset - Angle in degrees to offset the first slice - Try -90 or +90 * borderWidth - Width of border to draw around the pie chart, in pixels - Defaults to 0 (no border) * borderColor - Color to use for the pie chart border - Defaults to #000 * * box - Box plot. Options: * raw - Set to true to supply pre-computed plot points as values * values should be: low_outlier, low_whisker, q1, median, q3, high_whisker, high_outlier * When set to false you can supply any number of values and the box plot will * be computed for you. Default is false. * showOutliers - Set to true (default) to display outliers as circles * outlierIQR - Interquartile range used to determine outliers. Default 1.5 * boxLineColor - Outline color of the box * boxFillColor - Fill color for the box * whiskerColor - Line color used for whiskers * outlierLineColor - Outline color of outlier circles * outlierFillColor - Fill color of the outlier circles * spotRadius - Radius of outlier circles * medianColor - Line color of the median line * target - Draw a target cross hair at the supplied value (default undefined) * * * * Examples: * $('#sparkline1').sparkline(myvalues, { lineColor: '#f00', fillColor: false }); * $('.barsparks').sparkline('html', { type:'bar', height:'40px', barWidth:5 }); * $('#tristate').sparkline([1,1,-1,1,0,0,-1], { type:'tristate' }): * $('#discrete').sparkline([1,3,4,5,5,3,4,5], { type:'discrete' }); * $('#bullet').sparkline([10,12,12,9,7], { type:'bullet' }); * $('#pie').sparkline([1,1,2], { type:'pie' }); */ /*jslint regexp: true, browser: true, jquery: true, white: true, nomen: false, plusplus: false, maxerr: 500, indent: 4 */ (function(document, Math, undefined) { // performance/minified-size optimization (function(factory) { if(typeof define === 'function' && define.amd) { define(['jquery'], factory); } else if (jQuery && !jQuery.fn.sparkline) { factory(jQuery); } } (function($) { 'use strict'; var UNSET_OPTION = {}, getDefaults, createClass, SPFormat, clipval, quartile, normalizeValue, normalizeValues, remove, isNumber, all, sum, addCSS, ensureArray, formatNumber, RangeMap, MouseHandler, Tooltip, barHighlightMixin, line, bar, tristate, discrete, bullet, pie, box, defaultStyles, initStyles, VShape, VCanvas_base, VCanvas_canvas, VCanvas_vml, pending, shapeCount = 0; jquery.sparkline-2.1.2/src/interact.js 0000664 0000000 0000000 00000020241 12157227240 0017761 0 ustar 00root root 0000000 0000000 MouseHandler = createClass({ init: function (el, options) { var $el = $(el); this.$el = $el; this.options = options; this.currentPageX = 0; this.currentPageY = 0; this.el = el; this.splist = []; this.tooltip = null; this.over = false; this.displayTooltips = !options.get('disableTooltips'); this.highlightEnabled = !options.get('disableHighlight'); }, registerSparkline: function (sp) { this.splist.push(sp); if (this.over) { this.updateDisplay(); } }, registerCanvas: function (canvas) { var $canvas = $(canvas.canvas); this.canvas = canvas; this.$canvas = $canvas; $canvas.mouseenter($.proxy(this.mouseenter, this)); $canvas.mouseleave($.proxy(this.mouseleave, this)); $canvas.click($.proxy(this.mouseclick, this)); }, reset: function (removeTooltip) { this.splist = []; if (this.tooltip && removeTooltip) { this.tooltip.remove(); this.tooltip = undefined; } }, mouseclick: function (e) { var clickEvent = $.Event('sparklineClick'); clickEvent.originalEvent = e; clickEvent.sparklines = this.splist; this.$el.trigger(clickEvent); }, mouseenter: function (e) { $(document.body).unbind('mousemove.jqs'); $(document.body).bind('mousemove.jqs', $.proxy(this.mousemove, this)); this.over = true; this.currentPageX = e.pageX; this.currentPageY = e.pageY; this.currentEl = e.target; if (!this.tooltip && this.displayTooltips) { this.tooltip = new Tooltip(this.options); this.tooltip.updatePosition(e.pageX, e.pageY); } this.updateDisplay(); }, mouseleave: function () { $(document.body).unbind('mousemove.jqs'); var splist = this.splist, spcount = splist.length, needsRefresh = false, sp, i; this.over = false; this.currentEl = null; if (this.tooltip) { this.tooltip.remove(); this.tooltip = null; } for (i = 0; i < spcount; i++) { sp = splist[i]; if (sp.clearRegionHighlight()) { needsRefresh = true; } } if (needsRefresh) { this.canvas.render(); } }, mousemove: function (e) { this.currentPageX = e.pageX; this.currentPageY = e.pageY; this.currentEl = e.target; if (this.tooltip) { this.tooltip.updatePosition(e.pageX, e.pageY); } this.updateDisplay(); }, updateDisplay: function () { var splist = this.splist, spcount = splist.length, needsRefresh = false, offset = this.$canvas.offset(), localX = this.currentPageX - offset.left, localY = this.currentPageY - offset.top, tooltiphtml, sp, i, result, changeEvent; if (!this.over) { return; } for (i = 0; i < spcount; i++) { sp = splist[i]; result = sp.setRegionHighlight(this.currentEl, localX, localY); if (result) { needsRefresh = true; } } if (needsRefresh) { changeEvent = $.Event('sparklineRegionChange'); changeEvent.sparklines = this.splist; this.$el.trigger(changeEvent); if (this.tooltip) { tooltiphtml = ''; for (i = 0; i < spcount; i++) { sp = splist[i]; tooltiphtml += sp.getCurrentRegionTooltip(); } this.tooltip.setContent(tooltiphtml); } if (!this.disableHighlight) { this.canvas.render(); } } if (result === null) { this.mouseleave(); } } }); Tooltip = createClass({ sizeStyle: 'position: static !important;' + 'display: block !important;' + 'visibility: hidden !important;' + 'float: left !important;', init: function (options) { var tooltipClassname = options.get('tooltipClassname', 'jqstooltip'), sizetipStyle = this.sizeStyle, offset; this.container = options.get('tooltipContainer') || document.body; this.tooltipOffsetX = options.get('tooltipOffsetX', 10); this.tooltipOffsetY = options.get('tooltipOffsetY', 12); // remove any previous lingering tooltip $('#jqssizetip').remove(); $('#jqstooltip').remove(); this.sizetip = $('', { id: 'jqssizetip', style: sizetipStyle, 'class': tooltipClassname }); this.tooltip = $('', { id: 'jqstooltip', 'class': tooltipClassname }).appendTo(this.container); // account for the container's location offset = this.tooltip.offset(); this.offsetLeft = offset.left; this.offsetTop = offset.top; this.hidden = true; $(window).unbind('resize.jqs scroll.jqs'); $(window).bind('resize.jqs scroll.jqs', $.proxy(this.updateWindowDims, this)); this.updateWindowDims(); }, updateWindowDims: function () { this.scrollTop = $(window).scrollTop(); this.scrollLeft = $(window).scrollLeft(); this.scrollRight = this.scrollLeft + $(window).width(); this.updatePosition(); }, getSize: function (content) { this.sizetip.html(content).appendTo(this.container); this.width = this.sizetip.width() + 1; this.height = this.sizetip.height(); this.sizetip.remove(); }, setContent: function (content) { if (!content) { this.tooltip.css('visibility', 'hidden'); this.hidden = true; return; } this.getSize(content); this.tooltip.html(content) .css({ 'width': this.width, 'height': this.height, 'visibility': 'visible' }); if (this.hidden) { this.hidden = false; this.updatePosition(); } }, updatePosition: function (x, y) { if (x === undefined) { if (this.mousex === undefined) { return; } x = this.mousex - this.offsetLeft; y = this.mousey - this.offsetTop; } else { this.mousex = x = x - this.offsetLeft; this.mousey = y = y - this.offsetTop; } if (!this.height || !this.width || this.hidden) { return; } y -= this.height + this.tooltipOffsetY; x += this.tooltipOffsetX; if (y < this.scrollTop) { y = this.scrollTop; } if (x < this.scrollLeft) { x = this.scrollLeft; } else if (x + this.width > this.scrollRight) { x = this.scrollRight - this.width; } this.tooltip.css({ 'left': x, 'top': y }); }, remove: function () { this.tooltip.remove(); this.sizetip.remove(); this.sizetip = this.tooltip = undefined; $(window).unbind('resize.jqs scroll.jqs'); } }); jquery.sparkline-2.1.2/src/rangemap.js 0000664 0000000 0000000 00000002461 12157227240 0017746 0 ustar 00root root 0000000 0000000 $.RangeMapClass = RangeMap = createClass({ init: function (map) { var key, range, rangelist = []; for (key in map) { if (map.hasOwnProperty(key) && typeof key === 'string' && key.indexOf(':') > -1) { range = key.split(':'); range[0] = range[0].length === 0 ? -Infinity : parseFloat(range[0]); range[1] = range[1].length === 0 ? Infinity : parseFloat(range[1]); range[2] = map[key]; rangelist.push(range); } } this.map = map; this.rangelist = rangelist || false; }, get: function (value) { var rangelist = this.rangelist, i, range, result; if ((result = this.map[value]) !== undefined) { return result; } if (rangelist) { for (i = rangelist.length; i--;) { range = rangelist[i]; if (range[0] <= value && range[1] >= value) { return range[2]; } } } return undefined; } }); // Convenience function $.range_map = function(map) { return new RangeMap(map); }; jquery.sparkline-2.1.2/src/simpledraw.js 0000664 0000000 0000000 00000003755 12157227240 0020332 0 ustar 00root root 0000000 0000000 // Provide a cross-browser interface to a few simple drawing primitives $.fn.simpledraw = function (width, height, useExisting, interact) { var target, mhandler; if (useExisting && (target = this.data('_jqs_vcanvas'))) { return target; } if ($.fn.sparkline.canvas === false) { // We've already determined that neither Canvas nor VML are available return false; } else if ($.fn.sparkline.canvas === undefined) { // No function defined yet -- need to see if we support Canvas or VML var el = document.createElement('canvas'); if (!!(el.getContext && el.getContext('2d'))) { // Canvas is available $.fn.sparkline.canvas = function(width, height, target, interact) { return new VCanvas_canvas(width, height, target, interact); }; } else if (document.namespaces && !document.namespaces.v) { // VML is available document.namespaces.add('v', 'urn:schemas-microsoft-com:vml', '#default#VML'); $.fn.sparkline.canvas = function(width, height, target, interact) { return new VCanvas_vml(width, height, target); }; } else { // Neither Canvas nor VML are available $.fn.sparkline.canvas = false; return false; } } if (width === undefined) { width = $(this).innerWidth(); } if (height === undefined) { height = $(this).innerHeight(); } target = $.fn.sparkline.canvas(width, height, this, interact); mhandler = $(this).data('_jqs_mhandler'); if (mhandler) { mhandler.registerCanvas(target); } return target; }; $.fn.cleardraw = function () { var target = this.data('_jqs_vcanvas'); if (target) { target.reset(); } }; jquery.sparkline-2.1.2/src/utils.js 0000664 0000000 0000000 00000015207 12157227240 0017316 0 ustar 00root root 0000000 0000000 /** * Utilities */ createClass = function (/* [baseclass, [mixin, ...]], definition */) { var Class, args; Class = function () { this.init.apply(this, arguments); }; if (arguments.length > 1) { if (arguments[0]) { Class.prototype = $.extend(new arguments[0](), arguments[arguments.length - 1]); Class._super = arguments[0].prototype; } else { Class.prototype = arguments[arguments.length - 1]; } if (arguments.length > 2) { args = Array.prototype.slice.call(arguments, 1, -1); args.unshift(Class.prototype); $.extend.apply($, args); } } else { Class.prototype = arguments[0]; } Class.prototype.cls = Class; return Class; }; /** * Wraps a format string for tooltips * {{x}} * {{x.2} * {{x:months}} */ $.SPFormatClass = SPFormat = createClass({ fre: /\{\{([\w.]+?)(:(.+?))?\}\}/g, precre: /(\w+)\.(\d+)/, init: function (format, fclass) { this.format = format; this.fclass = fclass; }, render: function (fieldset, lookups, options) { var self = this, fields = fieldset, match, token, lookupkey, fieldvalue, prec; return this.format.replace(this.fre, function () { var lookup; token = arguments[1]; lookupkey = arguments[3]; match = self.precre.exec(token); if (match) { prec = match[2]; token = match[1]; } else { prec = false; } fieldvalue = fields[token]; if (fieldvalue === undefined) { return ''; } if (lookupkey && lookups && lookups[lookupkey]) { lookup = lookups[lookupkey]; if (lookup.get) { // RangeMap return lookups[lookupkey].get(fieldvalue) || fieldvalue; } else { return lookups[lookupkey][fieldvalue] || fieldvalue; } } if (isNumber(fieldvalue)) { if (options.get('numberFormatter')) { fieldvalue = options.get('numberFormatter')(fieldvalue); } else { fieldvalue = formatNumber(fieldvalue, prec, options.get('numberDigitGroupCount'), options.get('numberDigitGroupSep'), options.get('numberDecimalMark')); } } return fieldvalue; }); } }); // convience method to avoid needing the new operator $.spformat = function(format, fclass) { return new SPFormat(format, fclass); }; clipval = function (val, min, max) { if (val < min) { return min; } if (val > max) { return max; } return val; }; quartile = function (values, q) { var vl; if (q === 2) { vl = Math.floor(values.length / 2); return values.length % 2 ? values[vl] : (values[vl-1] + values[vl]) / 2; } else { if (values.length % 2 ) { // odd vl = (values.length * q + q) / 4; return vl % 1 ? (values[Math.floor(vl)] + values[Math.floor(vl) - 1]) / 2 : values[vl-1]; } else { //even vl = (values.length * q + 2) / 4; return vl % 1 ? (values[Math.floor(vl)] + values[Math.floor(vl) - 1]) / 2 : values[vl-1]; } } }; normalizeValue = function (val) { var nf; switch (val) { case 'undefined': val = undefined; break; case 'null': val = null; break; case 'true': val = true; break; case 'false': val = false; break; default: nf = parseFloat(val); if (val == nf) { val = nf; } } return val; }; normalizeValues = function (vals) { var i, result = []; for (i = vals.length; i--;) { result[i] = normalizeValue(vals[i]); } return result; }; remove = function (vals, filter) { var i, vl, result = []; for (i = 0, vl = vals.length; i < vl; i++) { if (vals[i] !== filter) { result.push(vals[i]); } } return result; }; isNumber = function (num) { return !isNaN(parseFloat(num)) && isFinite(num); }; formatNumber = function (num, prec, groupsize, groupsep, decsep) { var p, i; num = (prec === false ? parseFloat(num).toString() : num.toFixed(prec)).split(''); p = (p = $.inArray('.', num)) < 0 ? num.length : p; if (p < num.length) { num[p] = decsep; } for (i = p - groupsize; i > 0; i -= groupsize) { num.splice(i, 0, groupsep); } return num.join(''); }; // determine if all values of an array match a value // returns true if the array is empty all = function (val, arr, ignoreNull) { var i; for (i = arr.length; i--; ) { if (ignoreNull && arr[i] === null) continue; if (arr[i] !== val) { return false; } } return true; }; // sums the numeric values in an array, ignoring other values sum = function (vals) { var total = 0, i; for (i = vals.length; i--;) { total += typeof vals[i] === 'number' ? vals[i] : 0; } return total; }; ensureArray = function (val) { return $.isArray(val) ? val : [val]; }; // http://paulirish.com/2008/bookmarklet-inject-new-css-rules/ addCSS = function(css) { var tag; //if ('\v' == 'v') /* ie only */ { if (document.createStyleSheet) { document.createStyleSheet().cssText = css; } else { tag = document.createElement('style'); tag.type = 'text/css'; document.getElementsByTagName('head')[0].appendChild(tag); tag[(typeof document.body.style.WebkitAppearance == 'string') /* webkit only */ ? 'innerText' : 'innerHTML'] = css; } }; jquery.sparkline-2.1.2/src/vcanvas-base.js 0000664 0000000 0000000 00000010363 12157227240 0020525 0 ustar 00root root 0000000 0000000 // Setup a very simple "virtual canvas" to make drawing the few shapes we need easier // This is accessible as $(foo).simpledraw() VShape = createClass({ init: function (target, id, type, args) { this.target = target; this.id = id; this.type = type; this.args = args; }, append: function () { this.target.appendShape(this); return this; } }); VCanvas_base = createClass({ _pxregex: /(\d+)(px)?\s*$/i, init: function (width, height, target) { if (!width) { return; } this.width = width; this.height = height; this.target = target; this.lastShapeId = null; if (target[0]) { target = target[0]; } $.data(target, '_jqs_vcanvas', this); }, drawLine: function (x1, y1, x2, y2, lineColor, lineWidth) { return this.drawShape([[x1, y1], [x2, y2]], lineColor, lineWidth); }, drawShape: function (path, lineColor, fillColor, lineWidth) { return this._genShape('Shape', [path, lineColor, fillColor, lineWidth]); }, drawCircle: function (x, y, radius, lineColor, fillColor, lineWidth) { return this._genShape('Circle', [x, y, radius, lineColor, fillColor, lineWidth]); }, drawPieSlice: function (x, y, radius, startAngle, endAngle, lineColor, fillColor) { return this._genShape('PieSlice', [x, y, radius, startAngle, endAngle, lineColor, fillColor]); }, drawRect: function (x, y, width, height, lineColor, fillColor) { return this._genShape('Rect', [x, y, width, height, lineColor, fillColor]); }, getElement: function () { return this.canvas; }, /** * Return the most recently inserted shape id */ getLastShapeId: function () { return this.lastShapeId; }, /** * Clear and reset the canvas */ reset: function () { alert('reset not implemented'); }, _insert: function (el, target) { $(target).html(el); }, /** * Calculate the pixel dimensions of the canvas */ _calculatePixelDims: function (width, height, canvas) { // XXX This should probably be a configurable option var match; match = this._pxregex.exec(height); if (match) { this.pixelHeight = match[1]; } else { this.pixelHeight = $(canvas).height(); } match = this._pxregex.exec(width); if (match) { this.pixelWidth = match[1]; } else { this.pixelWidth = $(canvas).width(); } }, /** * Generate a shape object and id for later rendering */ _genShape: function (shapetype, shapeargs) { var id = shapeCount++; shapeargs.unshift(id); return new VShape(this, id, shapetype, shapeargs); }, /** * Add a shape to the end of the render queue */ appendShape: function (shape) { alert('appendShape not implemented'); }, /** * Replace one shape with another */ replaceWithShape: function (shapeid, shape) { alert('replaceWithShape not implemented'); }, /** * Insert one shape after another in the render queue */ insertAfterShape: function (shapeid, shape) { alert('insertAfterShape not implemented'); }, /** * Remove a shape from the queue */ removeShapeId: function (shapeid) { alert('removeShapeId not implemented'); }, /** * Find a shape at the specified x/y co-ordinates */ getShapeAt: function (el, x, y) { alert('getShapeAt not implemented'); }, /** * Render all queued shapes onto the canvas */ render: function () { alert('render not implemented'); } }); jquery.sparkline-2.1.2/src/vcanvas-canvas.js 0000664 0000000 0000000 00000015772 12157227240 0021077 0 ustar 00root root 0000000 0000000 VCanvas_canvas = createClass(VCanvas_base, { init: function (width, height, target, interact) { VCanvas_canvas._super.init.call(this, width, height, target); this.canvas = document.createElement('canvas'); if (target[0]) { target = target[0]; } $.data(target, '_jqs_vcanvas', this); $(this.canvas).css({ display: 'inline-block', width: width, height: height, verticalAlign: 'top' }); this._insert(this.canvas, target); this._calculatePixelDims(width, height, this.canvas); this.canvas.width = this.pixelWidth; this.canvas.height = this.pixelHeight; this.interact = interact; this.shapes = {}; this.shapeseq = []; this.currentTargetShapeId = undefined; $(this.canvas).css({width: this.pixelWidth, height: this.pixelHeight}); }, _getContext: function (lineColor, fillColor, lineWidth) { var context = this.canvas.getContext('2d'); if (lineColor !== undefined) { context.strokeStyle = lineColor; } context.lineWidth = lineWidth === undefined ? 1 : lineWidth; if (fillColor !== undefined) { context.fillStyle = fillColor; } return context; }, reset: function () { var context = this._getContext(); context.clearRect(0, 0, this.pixelWidth, this.pixelHeight); this.shapes = {}; this.shapeseq = []; this.currentTargetShapeId = undefined; }, _drawShape: function (shapeid, path, lineColor, fillColor, lineWidth) { var context = this._getContext(lineColor, fillColor, lineWidth), i, plen; context.beginPath(); context.moveTo(path[0][0] + 0.5, path[0][1] + 0.5); for (i = 1, plen = path.length; i < plen; i++) { context.lineTo(path[i][0] + 0.5, path[i][1] + 0.5); // the 0.5 offset gives us crisp pixel-width lines } if (lineColor !== undefined) { context.stroke(); } if (fillColor !== undefined) { context.fill(); } if (this.targetX !== undefined && this.targetY !== undefined && context.isPointInPath(this.targetX, this.targetY)) { this.currentTargetShapeId = shapeid; } }, _drawCircle: function (shapeid, x, y, radius, lineColor, fillColor, lineWidth) { var context = this._getContext(lineColor, fillColor, lineWidth); context.beginPath(); context.arc(x, y, radius, 0, 2 * Math.PI, false); if (this.targetX !== undefined && this.targetY !== undefined && context.isPointInPath(this.targetX, this.targetY)) { this.currentTargetShapeId = shapeid; } if (lineColor !== undefined) { context.stroke(); } if (fillColor !== undefined) { context.fill(); } }, _drawPieSlice: function (shapeid, x, y, radius, startAngle, endAngle, lineColor, fillColor) { var context = this._getContext(lineColor, fillColor); context.beginPath(); context.moveTo(x, y); context.arc(x, y, radius, startAngle, endAngle, false); context.lineTo(x, y); context.closePath(); if (lineColor !== undefined) { context.stroke(); } if (fillColor) { context.fill(); } if (this.targetX !== undefined && this.targetY !== undefined && context.isPointInPath(this.targetX, this.targetY)) { this.currentTargetShapeId = shapeid; } }, _drawRect: function (shapeid, x, y, width, height, lineColor, fillColor) { return this._drawShape(shapeid, [[x, y], [x + width, y], [x + width, y + height], [x, y + height], [x, y]], lineColor, fillColor); }, appendShape: function (shape) { this.shapes[shape.id] = shape; this.shapeseq.push(shape.id); this.lastShapeId = shape.id; return shape.id; }, replaceWithShape: function (shapeid, shape) { var shapeseq = this.shapeseq, i; this.shapes[shape.id] = shape; for (i = shapeseq.length; i--;) { if (shapeseq[i] == shapeid) { shapeseq[i] = shape.id; } } delete this.shapes[shapeid]; }, replaceWithShapes: function (shapeids, shapes) { var shapeseq = this.shapeseq, shapemap = {}, sid, i, first; for (i = shapeids.length; i--;) { shapemap[shapeids[i]] = true; } for (i = shapeseq.length; i--;) { sid = shapeseq[i]; if (shapemap[sid]) { shapeseq.splice(i, 1); delete this.shapes[sid]; first = i; } } for (i = shapes.length; i--;) { shapeseq.splice(first, 0, shapes[i].id); this.shapes[shapes[i].id] = shapes[i]; } }, insertAfterShape: function (shapeid, shape) { var shapeseq = this.shapeseq, i; for (i = shapeseq.length; i--;) { if (shapeseq[i] === shapeid) { shapeseq.splice(i + 1, 0, shape.id); this.shapes[shape.id] = shape; return; } } }, removeShapeId: function (shapeid) { var shapeseq = this.shapeseq, i; for (i = shapeseq.length; i--;) { if (shapeseq[i] === shapeid) { shapeseq.splice(i, 1); break; } } delete this.shapes[shapeid]; }, getShapeAt: function (el, x, y) { this.targetX = x; this.targetY = y; this.render(); return this.currentTargetShapeId; }, render: function () { var shapeseq = this.shapeseq, shapes = this.shapes, shapeCount = shapeseq.length, context = this._getContext(), shapeid, shape, i; context.clearRect(0, 0, this.pixelWidth, this.pixelHeight); for (i = 0; i < shapeCount; i++) { shapeid = shapeseq[i]; shape = shapes[shapeid]; this['_draw' + shape.type].apply(this, shape.args); } if (!this.interact) { // not interactive so no need to keep the shapes array this.shapes = {}; this.shapeseq = []; } } }); jquery.sparkline-2.1.2/src/vcanvas-vml.js 0000664 0000000 0000000 00000017203 12157227240 0020411 0 ustar 00root root 0000000 0000000 VCanvas_vml = createClass(VCanvas_base, { init: function (width, height, target) { var groupel; VCanvas_vml._super.init.call(this, width, height, target); if (target[0]) { target = target[0]; } $.data(target, '_jqs_vcanvas', this); this.canvas = document.createElement('span'); $(this.canvas).css({ display: 'inline-block', position: 'relative', overflow: 'hidden', width: width, height: height, margin: '0px', padding: '0px', verticalAlign: 'top'}); this._insert(this.canvas, target); this._calculatePixelDims(width, height, this.canvas); this.canvas.width = this.pixelWidth; this.canvas.height = this.pixelHeight; groupel = '