ChartBase.js revision e393eced613f9b4a5fb6bdd461d0e0bf5064d5ec
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippfunction ChartBase() {}
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippChartBase.ATTRS = {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp tooltip: {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp valueFn: "_getTooltip",
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp setter: function(val)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return this._updateTooltip(val);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @description Indicates the the type of interactions that will fire events.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * <ul>
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * <li>marker</li>
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * <li>all</li>
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * <li>none</li>
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp interactionType: {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp value: "marker"
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Data used to generate the chart.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp dataProvider: {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp setter: function(val)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return this._setDataValues(val);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Reference to graph instance
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @type Graph
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp graph: {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp valueFn: "_getGraph"
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp};
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippChartBase.prototype = {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @description Default value function for the <code>graph</code> attribute.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _getGraph: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var graph = new Y.Graph();
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp graph.after("chartRendered", Y.bind(function(e) {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this.fire("chartRendered");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }, this));
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return graph;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Returns a series instance
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method getSeries
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp getSeries: function(val)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var series = null,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp graph = this.get("graph");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(graph)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(Y.Lang.isNumber(val))
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp series = graph.getSeriesByIndex(val);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp else
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp series = graph.getSeriesByKey(val);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return series;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Returns axis by key reference
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method getAxisByKey
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp getAxisByKey: function(val)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var axis,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp axes = this.get("axes");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(axes.hasOwnProperty(val))
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp axis = axes[val];
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return axis;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Returns the category axis for the chart.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method getCategoryAxis
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp getCategoryAxis: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var axis,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp key = this.get("categoryKey"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp axes = this.get("axes");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(axes.hasOwnProperty(key))
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp axis = axes[key];
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return axis;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _direction: "horizontal",
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _dataProvider: null,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _setDataValues: function(val)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(Y.Lang.isArray(val[0]))
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var hash,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp dp = [],
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp cats = val[0],
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp i = 0,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp l = cats.length,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp n,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp sl = val.length;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp for(; i < l; ++i)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp hash = {category:cats[i]};
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp for(n = 1; n < sl; ++n)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp hash["series" + n] = val[n][i];
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp dp[i] = hash;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return dp;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return val;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _seriesCollection: null,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _setSeriesCollection: function(val)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this._seriesCollection = val;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _getAxisClass: function(t)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return this._axisClass[t];
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _axisClass: {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp stacked: Y.StackedAxis,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp numeric: Y.NumericAxis,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp category: Y.CategoryAxis,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp time: Y.TimeAxis
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _axes: null,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp renderUI: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp //move the position = absolute logic to a class file
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this.get("boundingBox").setStyle("position", "absolute");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this.get("contentBox").setStyle("position", "absolute");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this._addAxes();
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this._addSeries();
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(this.get("showTooltip"))
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this._addTooltip();
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this._redraw();
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp bindUI: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this.after("showTooltipChange", Y.bind(this._showTooltipChangeHandler, this));
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this.after("widthChange", this._sizeChanged);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this.after("heightChange", this._sizeChanged);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this.after("dataProviderChange", this._dataProviderChangeHandler);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var cb = this.get("contentBox"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp interactionType = this.get("interactionType"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp defaultTooltipFunction;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(interactionType == "marker")
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp Y.delegate("mouseenter", Y.bind(this._markerEventHandler, this), cb, ".yui3-seriesmarker");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp Y.delegate("mousedown", Y.bind(this._markerEventHandler, this), cb, ".yui3-seriesmarker");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp Y.delegate("mouseup", Y.bind(this._markerEventHandler, this), cb, ".yui3-seriesmarker");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp Y.delegate("mouseleave", Y.bind(this._markerEventHandler, this), cb, ".yui3-seriesmarker");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp Y.delegate("mousemove", Y.bind(this._positionTooltip, this), cb, ".yui3-seriesmarker");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp defaultTooltipFunction = this._displayTooltip;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp else if(interactionType == "all")
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this._overlay.on("mousemove", Y.bind(this._mouseMoveHandler, this));
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this.on("mouseout", this._hideTooltip);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp defaultTooltipFunction = this._displayMultiTooltip;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(this.get("tooltip"))
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this.on("markerEvent:mouseover", defaultTooltipFunction);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this.on("markerEvent:mouseout", this._hideTooltip);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _markerEventHandler: function(e)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var type = e.type,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp cb = this.get("contentBox"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp markerNode = e.currentTarget,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp strArr = markerNode.getAttribute("id").split("_"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp seriesIndex = strArr[0],
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp series = this.getSeries(parseInt(strArr[1], 10)),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp index = strArr[2],
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp x = e.pageX - cb.getX(),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp y = e.pageY - cb.getY();
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(type == "mouseenter")
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp type = "mouseover";
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp else if(type == "mouseleave")
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp type = "mouseout";
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp series.updateMarkerState(type, index);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this.fire("markerEvent:" + type, {node:markerNode, x:x, y:y, series:series, index:index, seriesIndex:seriesIndex});
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _dataProviderChangeHandler: function(e)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var dataProvider = this.get("dataProvider"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp axes = this.get("axes"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp i,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp axis;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp for(i in axes)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(axes.hasOwnProperty(i))
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp axis = axes[i];
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(axis instanceof Y.BaseAxis)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp axis.set("dataProvider", dataProvider);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _showTooltip: function(msg, x, y)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var tt = this.get("tooltip"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node = tt.node;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(msg)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.set("innerHTML", msg);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("top", y + "px");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("left", x + "px");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.removeClass("yui3-widget-hidden");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _positionTooltip: function(e)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var tt = this.get("tooltip"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node = tt.node,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp cb = this.get("contentBox"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp x = (e.pageX + 10) - cb.getX(),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp y = (e.pageY + 10) - cb.getY();
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(node)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("left", x + "px");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("top", y + "px");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _hideTooltip: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var tt = this.get("tooltip"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node = tt.node;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.set("innerHTML", "");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("left", -10000);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("top", -10000);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.addClass("yui3-widget-hidden");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _addTooltip: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var tt = this.get("tooltip");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this.get("contentBox").appendChild(tt.node);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _updateTooltip: function(val)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var tt = this._tooltip,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp i,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp styles = val.styles;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(styles)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp for(i in styles)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(styles.hasOwnProperty(i))
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp tt.node.setStyle(i, styles[i]);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(val.hasOwnProperty("labelFunction"))
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp tt.labelFunction = val.labelFunction;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return tt;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _getTooltip: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var node = document.createElement("div"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp tt = {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp labelFunction: this._tooltipLabelFunction
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp };
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node = Y.one(node);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("fontSize", "9px");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("fontWeight", "bold");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("position", "absolute");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("paddingTop", "2px");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("paddingRight", "5px");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("paddingBottom", "5px");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("paddingLeft", "2px");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("backgroundColor", "#edeeee");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("border", "1px solid #aeae9e");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("zIndex", 3);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("whiteSpace", "noWrap");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.addClass("yui3-widget-hidden");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp tt.node = Y.one(node);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this._tooltip = tt;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return tt;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _tooltipLabelFunction: function(categoryItem, valueItem, itemIndex, series, seriesIndex)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var msg = categoryItem.displayName +
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp ":&nbsp;" + categoryItem.axis.get("labelFunction").apply(this, [categoryItem.value, categoryItem.axis.get("labelFormat")]) +
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp "<br/>" + valueItem.displayName +
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp ":&nbsp;" + valueItem.axis.get("labelFunction").apply(this, [valueItem.value, valueItem.axis.get("labelFormat")]);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return msg;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _showTooltipChangeHandler: function(e)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(this.get("showTooltip"))
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this._addTooltip();
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp};
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippY.ChartBase = ChartBase;