<commit_before>define(["dojo/_base/lang", "dojo/_base/array", "dojo/_base/declare", "../plot2d/Indicator", "../plot2d/common",
    "../axis2d/common", "dojox/gfx"], 
	function(lang, array, declare, Indicator){

	var getXYCoordinates = function(v, values, data){
		var c2, c1 = v?{ x: values[0], y : data[0][0] } :
					   { x : data[0][0], y : values[0] };
		if(values.length > 1){
			c2 = v?{ x: values[1], y : data[1][0] } :
				   { x : data[1][0], y : values[1] };
		}
		return [c1, c2];
	};

	return declare(Indicator, {
		// summary:
		//		Internal element used by indicator actions.
		// tags:
		//		private
		constructor: function(chart, kwArgs){
			if(!kwArgs){ kwArgs = {}; }
			this.inter = kwArgs.inter;
		},
		_updateVisibility: function(cp, limit, attr){
			var axis = attr=="x"?this._hAxis:this._vAxis;
			var scale = axis.getWindowScale();
			this.chart.setAxisWindow(axis.name, scale, axis.getWindowOffset() + (cp[attr] - limit[attr]) / scale);
			this._noDirty = true;
			this.chart.render();
			this._noDirty = false;
			this._initTrack();
		},
		_trackMove: function(){
			// let's update the selector
			this._updateIndicator(this.pageCoord);
			// if we reached that point once, then we don't stop until mouse up
 			// use a recursive setTimeout to avoid intervals that might get backed up
			this._tracker = setTimeout(lang.hitch(this, this._trackMove), 100);
		},
		_initTrack: function(){
			if(!this._tracker){
				this._tracker = setTimeout(lang.hitch(this, this._trackMove), 500);
			}
		},
		stopTrack: function(){
			if(this._tracker){
				clearTimeout(this._tracker);
				this._tracker = null;
			}
		},
		render: function(){
			if(!this.isDirty()){
				return;
			}

			var inter = this.inter, plot = inter.plot, v = inter.opt.vertical;

			this.opt.offset = inter.opt.offset || (v?{ x:0 , y: 5}: { x: 5, y: 0});

			if(inter.opt.labelFunc){
				// adapt to indicator labelFunc format
				this.opt.labelFunc = function(index, values, data, fixed, precision){
					var coords = getXYCoordinates(v, values, data);
					return inter.opt.labelFunc(coords[0], coords[1], fixed, precision);
				};
			}
			if(inter.opt.fillFunc){
				// adapt to indicator fillFunc format
				this.opt.fillFunc = function(index, values, data){
					var coords = getXYCoordinates(v, values, data);
					return inter.opt.fillFunc(coords[0], coords[1]);
				};
			}

			this.opt = lang.delegate(inter.opt, this.opt);

			if (!this.pageCoord){
				this.opt.values = null;
			}else{
				// let's create a fake coordinate to not block parent render method
				// actual coordinate will be computed in _updateCoordinates
				this.opt.values = [];
				this.opt.labels = inter.opt.labels && (this.secondCoord?"trend":"marker");
			}

			// take axis on the interactor plot and forward them onto the indicator plot
			this.hAxis = plot.hAxis;
			this.vAxis = plot.vAxis;

			this.inherited(arguments);
		},
		_updateIndicator: function(){
			var coordinates = this._updateCoordinates(this.pageCoord, this.secondCoord);
			if(coordinates.length > 1){
				var v = this.opt.vertical;
				this._data= [];
				this.opt.values = [];
				array.forEach(coordinates, function(value){
					if(value){
						this.opt.values.push(v?value.x:value.y);
						this._data.push([v?value.y:value.x]);
					}
				}, this);
			}else{
				this.inter.onChange({});
				return;
			}
			this.inherited(arguments);
		},
		_renderText: function(g, text, t, x, y, index, values, data){
			this.inherited(arguments);
			var coords = getXYCoordinates(this.opt.vertical, values, data);
			this.inter.onChange({
				start: coords[0],
				end: coords[1],
				label: text
			});
		},
		_updateCoordinates: function(cp1, cp2){
			var inter = this.inter, plot = inter.plot, v = inter.opt.vertical;
			var hAxis = this.chart.getAxis(plot.hAxis), vAxis = this.chart.getAxis(plot.vAxis);
			var hn = hAxis.name, vn = vAxis.name, hb = hAxis.getScaler().bounds, vb = vAxis.getScaler().bounds;
			var attr = v?"x":"y", n = v?hn:vn, bounds = v?hb:vb;<commit_msg>refs #15486. Make sure onChange is called even if text is not displayed in the indicator. !strict.<commit_after>define(["dojo/_base/lang", "dojo/_base/array", "dojo/_base/declare", "../plot2d/Indicator", "../plot2d/common",
    "../axis2d/common", "dojox/gfx"], 
	function(lang, array, declare, Indicator){

	var getXYCoordinates = function(v, values, data){
		var c2, c1 = v?{ x: values[0], y : data[0][0] } :
					   { x : data[0][0], y : values[0] };
		if(values.length > 1){
			c2 = v?{ x: values[1], y : data[1][0] } :
				   { x : data[1][0], y : values[1] };
		}
		return [c1, c2];
	};

	return declare(Indicator, {
		// summary:
		//		Internal element used by indicator actions.
		// tags:
		//		private
		constructor: function(chart, kwArgs){
			if(!kwArgs){ kwArgs = {}; }
			this.inter = kwArgs.inter;
		},
		_updateVisibility: function(cp, limit, attr){
			var axis = attr=="x"?this._hAxis:this._vAxis;
			var scale = axis.getWindowScale();
			this.chart.setAxisWindow(axis.name, scale, axis.getWindowOffset() + (cp[attr] - limit[attr]) / scale);
			this._noDirty = true;
			this.chart.render();
			this._noDirty = false;
			this._initTrack();
		},
		_trackMove: function(){
			// let's update the selector
			this._updateIndicator(this.pageCoord);
			// if we reached that point once, then we don't stop until mouse up
 			// use a recursive setTimeout to avoid intervals that might get backed up
			this._tracker = setTimeout(lang.hitch(this, this._trackMove), 100);
		},
		_initTrack: function(){
			if(!this._tracker){
				this._tracker = setTimeout(lang.hitch(this, this._trackMove), 500);
			}
		},
		stopTrack: function(){
			if(this._tracker){
				clearTimeout(this._tracker);
				this._tracker = null;
			}
		},
		render: function(){
			if(!this.isDirty()){
				return;
			}

			var inter = this.inter, plot = inter.plot, v = inter.opt.vertical;

			this.opt.offset = inter.opt.offset || (v?{ x:0 , y: 5}: { x: 5, y: 0});

			if(inter.opt.labelFunc){
				// adapt to indicator labelFunc format
				this.opt.labelFunc = function(index, values, data, fixed, precision){
					var coords = getXYCoordinates(v, values, data);
					return inter.opt.labelFunc(coords[0], coords[1], fixed, precision);
				};
			}
			if(inter.opt.fillFunc){
				// adapt to indicator fillFunc format
				this.opt.fillFunc = function(index, values, data){
					var coords = getXYCoordinates(v, values, data);
					return inter.opt.fillFunc(coords[0], coords[1]);
				};
			}

			this.opt = lang.delegate(inter.opt, this.opt);

			if (!this.pageCoord){
				this.opt.values = null;
				this.inter.onChange({});
			}else{
				// let's create a fake coordinate to not block parent render method
				// actual coordinate will be computed in _updateCoordinates
				this.opt.values = [];
				this.opt.labels = this.secondCoord?"trend":"marker";
			}

			// take axis on the interactor plot and forward them onto the indicator plot
			this.hAxis = plot.hAxis;
			this.vAxis = plot.vAxis;

			this.inherited(arguments);
		},
		_updateIndicator: function(){
			var coordinates = this._updateCoordinates(this.pageCoord, this.secondCoord);
			if(coordinates.length > 1){
				var v = this.opt.vertical;
				this._data= [];
				this.opt.values = [];
				array.forEach(coordinates, function(value){
					if(value){
						this.opt.values.push(v?value.x:value.y);
						this._data.push([v?value.y:value.x]);
					}
				}, this);
			}else{
				this.inter.onChange({});
				return;
			}
			this.inherited(arguments);
		},
		_renderText: function(g, text, t, x, y, index, values, data){
			// render only if labels is true
			if(this.inter.opt.labels){
				this.inherited(arguments);
			}
			// send the event in all cases
			var coords = getXYCoordinates(this.opt.vertical, values, data);
			this.inter.onChange({
				start: coords[0],
				end: coords[1],
				label: text
			});
		},
		_updateCoordinates: function(cp1, cp2){
			var inter = this.inter, plot = inter.plot, v = inter.opt.vertical;
			var hAxis = this.chart.getAxis(plot.hAxis), vAxis = this.chart.getAxis(plot.vAxis);
			var hn = hAxis.name, vn = vAxis.name, hb = hAxis.getScaler().bounds, vb = vAxis.getScaler().bounds;
			var attr = v?"x":"y", n = v?hn:vn, bounds = v?hb:vb;
{'fraction_non_alphanumeric': 0.16160757649344343, 'fraction_numerical': 0.010320543953375425, 'mean_word_length': 3.2089933571793563, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4213469', 'n_tokens_mistral': 3374, 'n_tokens_neox': 2841, 'n_words': 662}