/*!@license
 * Infragistics.Web.ClientUI Chart 21.2.20212.99
 *
 * Copyright (c) 2011-2022 Infragistics Inc.
 *
 * http://www.infragistics.com/
 *
 * Depends on:
 * jquery.js
 * jquery-ui.js
 * infragistics.util.js
 * infragistics.util.jquery.js
 * infragistics.ext_core.js
 * infragistics.ext_collections.js
 * infragistics.ext_ui.js
 * infragistics.dv_core.js
 * infragistics.dv_geometry.js
 * infragistics.dv_jquerydom.js
 * infragistics.legend.js
 * infragistics.datachart_core.js
 * infragistics.dvcommonwidget.js
 * infragistics.ui.widget.js
 */
(function(factory){if(typeof define==="function"&&define.amd){define(["jquery","jquery-ui","./infragistics.util","./infragistics.util.jquery","./infragistics.ui.widget","./infragistics.legend","./infragistics.dv_jquerydom","./infragistics.dvcommonwidget"],factory)}else{factory(jQuery)}})(function($){$.widget("ui.igChartLegend",$.ui.igWidget,{options:{type:"legend",width:null,height:null,theme:"c"},css:{legend:"ui-corner-all ui-widget-content ui-chart-legend",legendItemsList:"ui-chart-legend-items-list",legendItem:"ui-chart-legend-item",legendItemBadge:"ui-chart-legend-item-badge",legendItemText:"ui-chart-legend-item-text"},events:{legendItemMouseLeftButtonDown:null,legendItemMouseLeftButtonUp:null,legendItemMouseEnter:null,legendItemMouseLeave:null},_create:function(){var legend,o=this.options,elem=this.element;if(o.type==="item"){legend=new $.ig.ItemLegend;if(o.orientation=="horizontal")legend.orientation(0)}else if(o.type==="scale"){legend=new $.ig.ScaleLegend;if(!o.width){o.width="100px"}if(!o.height){o.height="150px"}}else{legend=new $.ig.Legend;if(o.orientation=="horizontal")legend.orientation(0)}if(o.owner){this._owner=o.owner;o.owner=this._owner.options}this.legend=legend;legend.name(this.id());legend.legendItemsListStyle(this.css.legendItemsList);legend.legendItemStyle(this.css.legendItem);legend.legendItemBadgeStyle(this.css.legendItemBadge);legend.legendItemTextStyle(this.css.legendItemText);if(o.width){this._oldWidth=elem[0].style.width;elem.css("width",o.width)}if(o.height){this._oldHeight=elem[0].style.width;elem.css("height",o.height)}this._cssLegend=this.css.legend.replace("{0}",o.theme);elem.addClass(this._cssLegend);this._bindLegendEvents(legend);var elemWrapper=new $.ig.JQueryDomWrapper(elem[0],elem);var renderer=new $.ig.JQueryDomRenderer(elemWrapper,$.proxy(this._getLocaleValue,this));this._renderer=renderer;legend.provideContainer(renderer)},_bindLegendEvents:function(legend){legend.legendItemMouseLeftButtonDown=$.ig.Delegate.prototype.combine(legend.legendItemMouseLeftButtonDown,$.proxy(this._fireLegendItemMouseLeftButtonDown,this));legend.legendItemMouseLeftButtonUp=$.ig.Delegate.prototype.combine(legend.legendItemMouseLeftButtonUp,$.proxy(this._fireLegendItemMouseLeftButtonUp,this));legend.legendItemMouseEnter=$.ig.Delegate.prototype.combine(legend.legendItemMouseEnter,$.proxy(this._fireLegendItemMouseEnter,this));legend.legendItemMouseLeave=$.ig.Delegate.prototype.combine(legend.legendItemMouseLeave,$.proxy(this._fireLegendItemMouseLeave,this))},_getLegendEvt:function(evtArgs){var e,brush,series=evtArgs.series?evtArgs.series():null,owner=this._owner;if(!owner){return null}e={legend:this.options,series:series!==null&&owner.dvWidget?owner.dvWidget._getSeriesOpt(evtArgs):owner.options,chart:owner,item:evtArgs._item};e[owner.dvWidget?owner.dvWidget._getWidgetName():owner.widgetName]=owner.options;brush=evtArgs.legendItem&&evtArgs.legendItem()!==null&&evtArgs.legendItem().content?evtArgs.legendItem().content():null;brush=brush&&brush.actualItemBrush?brush.actualItemBrush():null;if(brush===null){var intSeries=null;if(evtArgs.series&&evtArgs.series()!==null){intSeries=evtArgs.series()}if(intSeries!==null&&intSeries.hostedSeries&&intSeries.hostedSeries()!==null){intSeries=intSeries.hostedSeries()}if(intSeries!==null&&intSeries.actualMarkerBrush&&intSeries.actualMarkerBrush()!==null){brush=intSeries.actualMarkerBrush()}}e.actualItemBrush=brush?this._getValueFromBrush(brush):null;brush=series&&series.actualBrush?series.actualBrush():null;e.actualSeriesBrush=brush?this._getValueFromBrush(brush):null;return e},_getValueFromBrush:function(brush){var ret={},currStop,newStop;if(brush._isGradient){ret.type="linearGradient";if(brush._useCustomDirection){ret.startPoint={};ret.startPoint.x=brush._startX;ret.startPoint.y=brush._startY;ret.endPoint={};ret.endPoint.x=brush._endX;ret.endPoint.y=brush._endY}if(brush._gradientStops){ret.colorStops=[];for(var i=0;i<brush._gradientStops.length;i++){currStop=brush._gradientStops[i];newStop={};newStop.offset=currStop._offset;newStop.color=currStop.__fill;ret.colorStops.push(newStop)}}return ret}else{return brush.fill()}},_fireLegendItemMouseLeftButtonDown:function(sender,evtArgs){this._trigger("legendItemMouseLeftButtonDown",null,this._getLegendEvt(evtArgs))},_fireLegendItemMouseLeftButtonUp:function(sender,evtArgs){this._trigger("legendItemMouseLeftButtonUp",null,this._getLegendEvt(evtArgs))},_fireLegendItemMouseEnter:function(sender,evtArgs){this._trigger("legendItemMouseEnter",null,this._getLegendEvt(evtArgs))},_fireLegendItemMouseLeave:function(sender,evtArgs){this._trigger("legendItemMouseLeave",null,this._getLegendEvt(evtArgs))},_getLegend:function(){return this.legend},_setOption:function(key,value){switch(key){case"width":this.element.css("width",value);break;case"height":this.element.css("height",value);break}this._super(key,value)},exportVisualData:function(){if(this.legend===null){return null}return this.legend.exportVisualData()},destroy:function(){var elements,elem=this.element;this._superApply(arguments);if(this.legend){this.legend.provideContainer(null);this.legend=null}if(elem){elem.removeClass(this._cssLegend);if(this.options.width){elem[0].style.width=this._oldWidth||""}if(this.options.height){elem[0].style.height=this._oldHeight||""}if(elem.children("table").length>0){elements=elem.children("table").children("tr");$.each(elements,function(key,tr){$(tr).unbind("mouseleave").unbind("mouseup").unbind("mousedown").unbind("mousemove")})}elem.empty()}if(this._renderer!=null){this._renderer.destroy();this._renderer=null}return this},widget:function(){return this.element},id:function(){return this.element[0].id}});$.extend($.ui.igChartLegend,{version:"21.2.20212.99"});return $.ui.igChartLegend});