@progress/kendo-ui
Version:
This package is part of the [Kendo UI for jQuery](http://www.telerik.com/kendo-ui) suite.
1 lines • 11.6 kB
JavaScript
module.exports=function(t){function e(s){if(i[s])return i[s].exports;var n=i[s]={exports:{},id:s,loaded:!1};return t[s].call(n.exports,n,n.exports,e),n.loaded=!0,n.exports}var i={};return e.m=t,e.c=i,e.p="",e(0)}({0:function(t,e,i){t.exports=i(913)},3:function(t,e){t.exports=function(){throw Error("define cannot be used indirect")}},910:function(t,e){t.exports=require("../../kendo.dataviz.chart")},913:function(t,e,i){var s,n,o;!function(a,define){n=[i(910)],s=a,o="function"==typeof s?s.apply(e,n):s,!(void 0!==o&&(t.exports=o))}(function(){!function(){function t(t,e){var i=document.createElement("div");return i.className=t,e&&(i.style.cssText=e),i}function e(){}function i(t){return e.prototype=t,new e}var s,n,o,a,r,l,h,c,d,p,u,f,m,v,g,_;window.kendo.dataviz=window.kendo.dataviz||{},s=kendo.dataviz,n=s.elementStyles,o=s.deepExtend,a=s.toTime,r=s.constants,l=s.Chart,h=kendo.drawing,c=h.Animation.extend({setup:function(){this._initialOpacity=parseFloat(n(this.element,"opacity").opacity)},step:function(t){n(this.element,{opacity:s.interpolateValue(this._initialOpacity,0,t)+""})},abort:function(){h.Animation.fn.abort.call(this),n(this.element,{display:"none",opacity:this._initialOpacity+""})},cancel:function(){h.Animation.fn.abort.call(this),n(this.element,{opacity:this._initialOpacity+""})}}),d=s.Class.extend({init:function(t,e,i){this.options=o({},this.options,i),this.container=t,this.chartService=e;var s=n(t,["paddingLeft","paddingTop"]);this.chartPadding={top:s.paddingTop,left:s.paddingLeft},this.createElements(),t.appendChild(this.element)},createElements:function(){var e=this.element=t("k-navigator-hint","display: none; position: absolute; top: 1px; left: 1px;"),i=this.tooltip=t("k-tooltip k-chart-tooltip"),s=this.scroll=t("k-scroll");i.innerHTML=" ",e.appendChild(i),e.appendChild(s)},show:function(t,e,i){var o,r=this,l=r.element,h=r.options,c=r.scroll,d=r.tooltip,p=s.toDate(a(t)+a(e-t)/2),u=.4*i.width(),f=i.center().x-u,m=i.center().x,v=m-f,g=h.max-h.min,_=v/g,x=p-h.min,b=this.chartService.intl.format(h.format,t,e),y=s.getTemplate(h);this.clearHideTimeout(),this._visible||(n(l,{visibility:"hidden",display:"block"}),this._visible=!0),y&&(b=y({from:t,to:e})),d.innerHTML=b,n(d,{left:i.center().x-d.offsetWidth/2,top:i.y1}),o=n(d,["marginTop","borderTopWidth","height"]),n(c,{width:u,left:f+x*_,top:i.y1+o.marginTop+o.borderTopWidth+o.height/2}),n(l,{visibility:"visible"})},clearHideTimeout:function(){this._hideTimeout&&clearTimeout(this._hideTimeout),this._hideAnimation&&this._hideAnimation.cancel()},hide:function(){var t=this;this.clearHideTimeout(),this._hideTimeout=setTimeout(function(){t._visible=!1,t._hideAnimation=new c(t.element),t._hideAnimation.setup(),t._hideAnimation.play()},this.options.hideDelay)},destroy:function(){this.clearHideTimeout(),this.container&&this.container.removeChild(this.element),delete this.container,delete this.chartService,delete this.element,delete this.tooltip,delete this.scroll}}),s.setDefaultOptions(d,{format:"{0:d} - {1:d}",hideDelay:500}),p="_navigator",u=p,f={NAVIGATOR_AXIS:u,NAVIGATOR_PANE:p},m=3,v=s.Class.extend({init:function(t){var e,i,n;this.chart=t,e=this.options=o({},this.options,t.options.navigator),i=e.select,i&&(i.from=this.parseDate(i.from),i.to=this.parseDate(i.to)),s.defined(e.hint.visible)||(e.hint.visible=e.visible),this.chartObserver=new s.InstanceObserver(this,(n={},n[r.DRAG]="_drag",n[r.DRAG_END]="_dragEnd",n[r.ZOOM]="_zoom",n[r.ZOOM_END]="_zoomEnd",n)),t.addObserver(this.chartObserver)},parseDate:function(t){return s.parseDate(this.chart.chartService.intl,t)},clean:function(){this.selection&&(this.selection.destroy(),this.selection=null),this.hint&&(this.hint.destroy(),this.hint=null)},destroy:function(){this.chart&&(this.chart.removeObserver(this.chartObserver),delete this.chart),this.clean()},redraw:function(){this._redrawSelf(),this.initSelection()},initSelection:function(){var t=this,e=t.chart,n=t.options,o=this.mainAxis(),a=o.roundedRange(),r=a.min,l=a.max,h=n.select,c=h.from,p=h.to,u=h.mousewheel,f=i(o);0!==o.categoriesCount()&&(this.clean(),f.box=o.box,this.selection=new s.Selection(e,f,{min:r,max:l,from:c||r,to:p||l,mousewheel:s.valueOrDefault(u,{zoom:"left"}),visible:n.visible},new s.InstanceObserver(this,{selectStart:"_selectStart",select:"_select",selectEnd:"_selectEnd"})),n.hint.visible&&(this.hint=new d(e.element,e.chartService,{min:r,max:l,template:s.getTemplate(n.hint),format:n.hint.format})))},setRange:function(){var t,e=this.chart._createPlotArea(!0),i=e.namedCategoryAxes[u],s=i.roundedRange(),n=s.min,a=s.max,r=this.options.select||{},l=r.from||n;l<n&&(l=n),t=r.to||a,t>a&&(t=a),this.options.select=o({},r,{from:l,to:t}),this.filterAxes()},_redrawSelf:function(t){var e=this.chart._plotArea;e&&e.redraw(s.last(e.panes),t)},redrawSlaves:function(){var t=this.chart,e=t._plotArea,i=e.panes.slice(0,-1);e.srcSeries=t.options.series,e.options.categoryAxis=t.options.categoryAxis,e.clearSeriesPointsCache(),e.redraw(i)},_drag:function(t){var e,i,n,o=this,r=o.chart,l=o.selection,h=r._eventCoordinates(t.originalEvent),c=this.mainAxis(),d=c.roundedRange(),p=c.pane.box.containsPoint(h),u=r._plotArea.categoryAxis,f=t.axisRanges[u.options.name],m=this.options.select;f&&!p&&l&&(e=m.from&&m.to?a(m.to)-a(m.from):a(l.options.to)-a(l.options.from),i=s.toDate(s.limitValue(a(f.min),d.min,a(d.max)-e)),n=s.toDate(s.limitValue(a(i)+e,a(d.min)+e,d.max)),this.options.select={from:i,to:n},this.options.liveDrag&&(this.filterAxes(),this.redrawSlaves()),l.set(i,n),this.showHint(i,n))},_dragEnd:function(){this.filterAxes(),this.filter(),this.redrawSlaves(),this.hint&&this.hint.hide()},readSelection:function(){var t=this,e=t.selection.options,i=e.from,s=e.to,n=t.options.select;n.from=i,n.to=s},filterAxes:function(){var t,e,i,s,n,o,a=this,r=a.options.select;for(void 0===r&&(r={}),t=a.chart,e=t.options.categoryAxis,i=r.from,s=r.to,n=0;n<e.length;n++)o=e[n],o.pane!==p&&(o.min=i,o.max=s)},filter:function(){var t,e,i,n=this,a=n.chart,r=n.options.select;a.requiresHandlers(["navigatorFilter"])&&(t=this.mainAxis(),e={from:r.from,to:r.to},"category"!==t.options.type&&(i=new s.DateCategoryAxis(o({baseUnit:"fit"},a.options.categoryAxis[0],{categories:[r.from,r.to]}),a.chartService).options,e.from=s.addDuration(i.min,-i.baseUnitStep,i.baseUnit),e.to=s.addDuration(i.max,i.baseUnitStep,i.baseUnit)),this.chart.trigger("navigatorFilter",e))},_zoom:function(t){var e,i,s=this,n=s.chart._plotArea.categoryAxis,o=s.selection,a=s.options,r=a.select,l=a.liveDrag,h=this.mainAxis(),c=t.delta;o&&(e=h.categoryIndex(o.options.from),i=h.categoryIndex(o.options.to),t.originalEvent.preventDefault(),Math.abs(c)>1&&(c*=m),i-e>1?(o.expand(c),this.readSelection()):(n.options.min=r.from,r.from=n.scaleRange(-t.delta).min),l&&(this.filterAxes(),this.redrawSlaves()),o.set(r.from,r.to),this.showHint(this.options.select.from,this.options.select.to))},_zoomEnd:function(t){this._dragEnd(t)},showHint:function(t,e){var i=this.chart._plotArea;this.hint&&this.hint.show(t,e,i.backgroundBox())},_selectStart:function(t){return this.chart._selectStart(t)},_select:function(t){return this.showHint(t.from,t.to),this.chart._select(t)},_selectEnd:function(t){return this.hint&&this.hint.hide(),this.readSelection(),this.filterAxes(),this.filter(),this.redrawSlaves(),this.chart._selectEnd(t)},mainAxis:function(){var t=this.chart._plotArea;if(t)return t.namedCategoryAxes[u]},select:function(t,e){var i=this.options.select;return t&&e&&(i.from=this.parseDate(t),i.to=this.parseDate(e),this.filterAxes(),this.filter(),this.redrawSlaves(),this.selection.set(t,e)),{from:i.from,to:i.to}}}),v.setup=function(t,e){var i,s,n;void 0===t&&(t={}),void 0===e&&(e={}),t.__navi||(t.__navi=!0,i=o({},e.navigator,t.navigator),s=t.panes=[].concat(t.panes),n=o({},i.pane,{name:p}),i.visible||(n.visible=!1,n.height=.1),s.push(n),v.attachAxes(t,i),v.attachSeries(t,i,e))},v.attachAxes=function(t,e){var i=e.series||[],n=t.categoryAxis=[].concat(t.categoryAxis),a=t.valueAxis=[].concat(t.valueAxis),l=s.filterSeriesByType(i,r.EQUALLY_SPACED_SERIES),h=0===l.length,c=o({type:"date",pane:p,roundToBaseUnit:!h,justified:h,_collapse:!1,majorTicks:{visible:!0},tooltip:{visible:!1},labels:{step:1},autoBind:e.autoBindElements,autoBaseUnitSteps:{minutes:[1],hours:[1,2],days:[1,2],weeks:[],months:[1],years:[1]}}),d=e.categoryAxis;n.push(o({},c,{maxDateGroups:200},d,{name:u,title:null,baseUnit:"fit",baseUnitStep:"auto",labels:{visible:!1},majorTicks:{visible:!1}}),o({},c,d,{name:u+"_labels",maxDateGroups:20,baseUnitStep:"auto",labels:{position:""},plotBands:[],autoBaseUnitSteps:{minutes:[]},_overlap:!0}),o({},c,d,{name:u+"_ticks",maxDateGroups:200,majorTicks:{width:.5},plotBands:[],title:null,labels:{visible:!1,mirror:!0},_overlap:!0})),a.push(o({name:u,pane:p,majorGridLines:{visible:!1},visible:!1},e.valueAxis))},v.attachSeries=function(t,e,i){var s,n=t.series=t.series||[],a=[].concat(e.series||[]),r=i.seriesColors,l=e.seriesDefaults;for(s=0;s<a.length;s++)n.push(o({color:r[s%r.length],categoryField:e.dateField,visibleInLegend:!1,tooltip:{visible:!1}},l,a[s],{axis:u,categoryAxis:u,autoBind:e.autoBindElements}))},g=28,_=l.extend({applyDefaults:function(t,e){var i=s.elementSize(this.element).width||r.DEFAULT_WIDTH,n=e,a={seriesDefaults:{categoryField:t.dateField},axisDefaults:{categoryAxis:{name:"default",majorGridLines:{visible:!1},labels:{step:2},majorTicks:{visible:!1},maxDateGroups:Math.floor(i/g)}}};n&&(n=o({},n,a)),v.setup(t,n),l.fn.applyDefaults.call(this,t,n)},_setElementClass:function(t){s.addClass(t,"k-chart k-stockchart")},setOptions:function(t){this.destroyNavigator(),l.fn.setOptions.call(this,t)},noTransitionsRedraw:function(){var t=this.options.transitions;this.options.transitions=!1,this._fullRedraw(),this.options.transitions=t},_resize:function(){this.noTransitionsRedraw()},_redraw:function(){var t=this.navigator;!this._dirty()&&t&&t.options.partialRedraw?t.redrawSlaves():this._fullRedraw()},_dirty:function(){var t=this.options,e=[].concat(t.series,t.navigator.series),i=s.grep(e,function(t){return t&&t.visible}).length,n=this._seriesCount!==i;return this._seriesCount=i,n},_fullRedraw:function(){var t=this.navigator;t||(t=this.navigator=new v(this),this.trigger("navigatorCreated",{navigator:t})),t.clean(),t.setRange(),l.fn._redraw.call(this),t.initSelection()},_trackSharedTooltip:function(t){var e=this._plotArea,i=e.paneByPoint(t);i&&i.options.name===p?this._unsetActivePoint():l.fn._trackSharedTooltip.call(this,t)},bindCategories:function(){l.fn.bindCategories.call(this),this.copyNavigatorCategories()},copyNavigatorCategories:function(){var t,e,i,s=[].concat(this.options.categoryAxis);for(e=0;e<s.length;e++)i=s[e],i.name===u?t=i.categories:t&&i.pane===p&&(i.categories=t)},destroyNavigator:function(){this.navigator&&(this.navigator.destroy(),this.navigator=null)},destroy:function(){this.destroyNavigator(),l.fn.destroy.call(this)},_stopChartHandlers:function(t){var e=this._eventCoordinates(t),i=this._plotArea.paneByPoint(e);return l.fn._stopChartHandlers.call(this,t)||i&&i.options.name===p},_toggleDragZoomEvents:function(){this._dragZoomEnabled||(this.element.style.touchAction="none",this._dragZoomEnabled=!0)}}),s.setDefaultOptions(_,{dateField:"date",axisDefaults:{categoryAxis:{type:"date",baseUnit:"fit",justified:!0},valueAxis:{narrowRange:!0,labels:{format:"C"}}},navigator:{select:{},seriesDefaults:{markers:{visible:!1},tooltip:{visible:!0},line:{width:2}},hint:{},visible:!0},tooltip:{visible:!0},legend:{visible:!1}}),kendo.deepExtend(kendo.dataviz,{constants:f,Navigator:v,NavigatorHint:d,StockChart:_})}()},i(3))}});