(function() { const __d3_formatLocaleCache = new Map(); const __d3_timeFormatLocaleCache = new Map(); var Billboard = zul.billboard.Billboard = zk.$extends(zk.Widget, { _title : '', _type : 'line', _cursor : false, _highlighter : true, _dataClickTS : 0, _locale: null, $define : { title: null, type: null, width: null, height: null, model : null, series : null, seriesData : null, seriesDefaults : null, seriesColors: null, axes : null, ticks : null, tickAxisLabel: null, valueAxisLabel: null, orient : null, rendererOptions: null, legend: null, timeSeries: null, timeSeriesInterval: null, timeSeriesFormat: null, xAxisAngle: null, chart: null, locale: null }, _loadFormatLocale: async function(url) { try { const definition = await d3.json(url); d3.formatDefaultLocale(definition); __d3_formatLocaleCache.set(url, definition); } catch (error) { __d3_formatLocaleCache.set(url, null); } }, _loadTimeFormatLocale: async function(url) { try { const definition = await d3.json(url); d3.timeFormatDefaultLocale(definition); __d3_timeFormatLocaleCache.set(url, definition); } catch (error) { __d3_timeFormatLocaleCache.set(url, null); } }, _dataPrepare : function() { //load locale if (this.getLocale() != null) { const formatURL = "https://unpkg.com/d3-format@3.1.0/locale/"+this.getLocale()+".json"; if (__d3_formatLocaleCache.has(formatURL)) { const definition = __d3_formatLocaleCache.get(formatURL); if (definition != null) d3.formatDefaultLocale(definition); } else { this._loadFormatLocale(formatURL); } const timeFormatURL = "https://unpkg.com/d3-time-format@4.1.0/locale/"+this.getLocale()+".json"; if (__d3_timeFormatLocaleCache.has(timeFormatURL)) { const definition = __d3_timeFormatLocaleCache.get(timeFormatURL); if (definition != null) d3.timeFormatDefaultLocale(definition); } else { this._loadTimeFormatLocale(timeFormatURL); } } var dataModel = this.getModel(); var data = []; try { data = jq.evalJSON(dataModel); } catch (error) { console.log(error); } if (typeof data == "undefined") { data = []; } // In this phase, we need to decide following variables var seriesData = []; var ticks = []; // Start data prepare if( this.getType() == 'gauge') { seriesData.push("data"); for ( var i = 0, len = data.length; i < len; i++) { seriesData.push(data[i]['value']); } } else if( this.getType() == 'pie' || this.getType() == 'donut') { for ( var i = 0, len = data.length; i < len; i++) { seriesData.push([data[i]['category'], data[i]['value']]); } seriesData = [ seriesData ]; } else { var seriesMap = new Array(); for ( var i = 0, len = data.length; i < len; i++) { var current = data[i]; var seriesIndex = -1; var seriesLabel = current['series']; var categoryLabel = current['category']; var categoryValue = current['value']; var seriesIndex = seriesMap.indexOf(seriesLabel); if (seriesIndex < 0) { seriesMap.push(seriesLabel); seriesIndex = seriesMap.length-1; } // Initial Array if(!seriesData[seriesIndex]) { seriesData[seriesIndex] = new Array(); } if (seriesData[seriesIndex].length == 0) seriesData[seriesIndex].push(seriesLabel); seriesData[seriesIndex].push({category: categoryLabel, value: categoryValue}); } var seriesLabel = new Array(); for (var i=0; i 500) this.$supers(Billboard, 'doClick_', arguments); }, isBarType : function() { return this._type == 'bar' || this._type == 'stacked_bar' || this._type == 'waterfall'; }, getCursor : function() { if(this._cursor) { return { show: true, followMouse: true, showTooltip: true, tooltipLocation:'sw', style: 'pointer'}; } else { return { show: false }; } }, setCursor : function(val) { this._cursor = val; }, getZclass : function() { return this._zclass != null ? this._zclass : "z-billboard"; } }, {_renderers : {}}); })();