123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221 |
- define("dojox/charting/action2d/MouseIndicator", ["dojo/_base/lang", "dojo/_base/declare", "dojo/_base/connect", "dojo/_base/window", "dojo/_base/sniff",
- "./ChartAction", "./_IndicatorElement", "dojox/lang/utils", "dojo/_base/event","dojo/_base/array"],
- function(lang, declare, hub, win, has, ChartAction, IndicatorElement, du, eventUtil, arr){
-
- return declare("dojox.charting.action2d.MouseIndicator", ChartAction, {
-
-
-
- defaultParams: {
- series: "",
- vertical: true,
- autoScroll: true,
- fixed: true,
- precision: 0
- },
- optionalParams: {
- lineStroke: {},
- outlineStroke: {},
- shadowStroke: {},
- stroke: {},
- outline: {},
- shadow: {},
- fill: {},
- fillFunc: null,
- labelFunc: null,
- font: "",
- fontColor: "",
- markerStroke: {},
- markerOutline: {},
- markerShadow: {},
- markerFill: {},
- markerSymbol: ""
- },
- constructor: function(chart, plot, kwArgs){
-
-
-
-
-
-
- this._listeners = [{eventName: "onmousedown", methodName: "onMouseDown"}];
- this.opt = lang.clone(this.defaultParams);
- du.updateWithObject(this.opt, kwArgs);
- du.updateWithPattern(this.opt, kwArgs, this.optionalParams);
- this._uName = "mouseIndicator"+this.opt.series;
- this._handles = [];
- this.connect();
- },
-
- _disconnectHandles: function(){
- if(has("ie")){
- this.chart.node.releaseCapture();
- }
- arr.forEach(this._handles, hub.disconnect);
- this._handles = [];
- },
- connect: function(){
-
-
-
- this.inherited(arguments);
-
- this.chart.addPlot(this._uName, {type: IndicatorElement, inter: this});
- },
- disconnect: function(){
-
-
- if(this._isMouseDown){
- this.onMouseUp();
- }
- this.chart.removePlot(this._uName);
- this.inherited(arguments);
- this._disconnectHandles();
- },
- onMouseDown: function(event){
-
-
- this._isMouseDown = true;
-
-
-
- if(has("ie")){
- this._handles.push(hub.connect(this.chart.node, "onmousemove", this, "onMouseMove"));
- this._handles.push(hub.connect(this.chart.node, "onmouseup", this, "onMouseUp"));
- this.chart.node.setCapture();
- }else{
- this._handles.push(hub.connect(win.doc, "onmousemove", this, "onMouseMove"));
- this._handles.push(hub.connect(win.doc, "onmouseup", this, "onMouseUp"));
- }
-
- this._onMouseSingle(event);
- },
- onMouseMove: function(event){
-
-
- if(this._isMouseDown){
- this._onMouseSingle(event);
- }
- },
- _onMouseSingle: function(event){
- var plot = this.chart.getPlot(this._uName);
- plot.pageCoord = {x: event.pageX, y: event.pageY};
- plot.dirty = true;
- this.chart.render();
- eventUtil.stop(event);
- },
- onMouseUp: function(event){
-
-
- var plot = this.chart.getPlot(this._uName);
- plot.stopTrack();
- this._isMouseDown = false;
- this._disconnectHandles();
- plot.pageCoord = null;
- plot.dirty = true;
- this.chart.render();
- }
- });
- });
|