ChartBase.js revision 91d40744967aabc3e1c105820a22e279fdecc689
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp/**
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * The ChartBase class is an abstract class used to create charts.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp *
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @class ChartBase
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @constructor
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippfunction ChartBase() {}
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippChartBase.ATTRS = {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp /**
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Reference to the default tooltip available for the chart.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * <p>Contains the following properties:</p>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dl>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dt>node</dt><dd>Reference to the actual dom node</dd>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dt>showEvent</dt><dd>Event that should trigger the tooltip</dd>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dt>hideEvent</dt><dd>Event that should trigger the removal of a tooltip (can be an event or an array of events)</dd>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dt>styles</dt><dd>A hash of style properties that will be applied to the tooltip node</dd>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dt>show</dt><dd>Indicates whether or not to show the tooltip</dd>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dt>markerEventHandler</dt><dd>Displays and hides tooltip based on marker events</dd>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dt>planarEventHandler</dt><dd>Displays and hides tooltip based on planar events</dd>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dt>markerLabelFunction</dt><dd>Reference to the function used to format a marker event triggered tooltip's text</dd>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dt>planarLabelFunction</dt><dd>Reference to the function used to format a planar event triggered tooltip's text</dd>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * </dl>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute tooltip
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type Object
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp tooltip: {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp valueFn: "_getTooltip",
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp setter: function(val)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return this._updateTooltip(val);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp /**
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * The key value used for the chart's category axis.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp *
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute categoryKey
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type String
f69d245bb21be88752420e834a6b6be37e9b525fTripp * @default category
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp */
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp categoryKey: {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp value: "category"
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp },
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp /**
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Indicates the type of axis to use for the category axis.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp *
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dl>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dt>category</dt><dd>Specifies a <code>CategoryAxis</code>.</dd>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dt>time</dt><dd>Specifies a <code>TimeAxis</dd>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * </dl>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp *
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute categoryType
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type String
f69d245bb21be88752420e834a6b6be37e9b525fTripp * @default category
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp */
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp categoryType:{
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp value:"category"
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp },
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Indicates the the type of interactions that will fire events.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp *
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dl>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dt>marker</dt><dd>Events will be broadcasted when the mouse interacts with individual markers.</dd>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dt>planar</dt><dd>Events will be broadcasted when the mouse intersects the plane of any markers on the chart.</dd>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * <dt>none</dt><dd>No events will be broadcasted.</dd>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * </dl>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp *
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute interactionType
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type String
f69d245bb21be88752420e834a6b6be37e9b525fTripp * @default marker
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp interactionType: {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp value: "marker"
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Data used to generate the chart.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp *
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute dataProvider
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type Array
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp dataProvider: {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp setter: function(val)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return this._setDataValues(val);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp /**
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * A collection of keys that map to the series axes. If no keys are set,
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * they will be generated automatically depending on the data structure passed into
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * the chart.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp *
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute seriesKeys
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type Array
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp */
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp seriesKeys: {},
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Reference to all the axes in the chart.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp *
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute axesCollection
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type Array
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp */
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp axesCollection: {},
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp /**
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Reference to graph instance.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp *
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute graph
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 /**
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Returns a series instance by index or key value.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp *
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method getSeries
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @param val
f69d245bb21be88752420e834a6b6be37e9b525fTripp * @return CartesianSeries
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 /**
f69d245bb21be88752420e834a6b6be37e9b525fTripp * Returns an <code>Axis</code> instance by key reference. If the axis was explicitly set through the <code>axes</code> attribute,
f69d245bb21be88752420e834a6b6be37e9b525fTripp * the key will be the same as the key used in the <code>axes</code> object. For default axes, the key for
f69d245bb21be88752420e834a6b6be37e9b525fTripp * the category axis is the value of the <code>categoryKey</code> (<code>category</code>). For the value axis, the default
f69d245bb21be88752420e834a6b6be37e9b525fTripp * key is <code>values</code>.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp *
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method getAxisByKey
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @param {String} val Key reference used to look up the axis.
f69d245bb21be88752420e834a6b6be37e9b525fTripp * @return Axis
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.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp *
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method getCategoryAxis
f69d245bb21be88752420e834a6b6be37e9b525fTripp * @return Axis
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 },
f69d245bb21be88752420e834a6b6be37e9b525fTripp
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 {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp var tt = this.get("tooltip");
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();
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp if(tt && tt.show)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this._addTooltip();
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this._redraw();
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp bindUI: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this.after("tooltipChange", Y.bind(this._tooltipChangeHandler, this));
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this.after("widthChange", this._sizeChanged);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this.after("heightChange", this._sizeChanged);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this.after("dataProviderChange", this._dataProviderChangeHandler);
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp var tt = this.get("tooltip"),
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp hideEvent = "mouseout",
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp showEvent = "mouseover",
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp cb = this.get("contentBox"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp interactionType = this.get("interactionType"),
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp i = 0,
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp len;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(interactionType == "marker")
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp hideEvent = tt.hideEvent;
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp showEvent = tt.showEvent;
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp Y.delegate("mouseenter", Y.bind(this._markerEventDispatcher, this), cb, ".yui3-seriesmarker");
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp Y.delegate("mousedown", Y.bind(this._markerEventDispatcher, this), cb, ".yui3-seriesmarker");
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp Y.delegate("mouseup", Y.bind(this._markerEventDispatcher, this), cb, ".yui3-seriesmarker");
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp Y.delegate("mouseleave", Y.bind(this._markerEventDispatcher, this), cb, ".yui3-seriesmarker");
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp Y.delegate("click", Y.bind(this._markerEventDispatcher, this), cb, ".yui3-seriesmarker");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp Y.delegate("mousemove", Y.bind(this._positionTooltip, this), cb, ".yui3-seriesmarker");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp else if(interactionType == "planar")
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this._overlay.on("mousemove", Y.bind(this._planarEventDispatcher, this));
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this.on("mouseout", this.hideTooltip);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp if(tt)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp if(hideEvent && showEvent && hideEvent == showEvent)
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this.on(interactionType + "Event:" + hideEvent, this.toggleTooltip);
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp }
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp else
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp if(showEvent)
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this.on(interactionType + "Event:" + showEvent, tt[interactionType + "EventHandler"]);
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp }
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp if(hideEvent)
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp if(Y.Lang.isArray(hideEvent))
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp len = hideEvent.length;
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp for(; i < len; ++i)
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this.on(interactionType + "Event:" + hideEvent[i], this.hideTooltip);
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp }
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp }
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this.on(interactionType + "Event:" + hideEvent, this.hideTooltip);
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp }
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp _markerEventDispatcher: function(e)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var type = e.type,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp cb = this.get("contentBox"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp markerNode = e.currentTarget,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp strArr = markerNode.getAttribute("id").split("_"),
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp seriesIndex = strArr[1],
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp series = this.getSeries(parseInt(seriesIndex, 10)),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp index = strArr[2],
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp items = this.getSeriesItems(series, index),
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);
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp e.halt();
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp /**
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * Broadcasts when <code>interactionType</code> is set to <code>marker</code> and a series marker has received a mouseover event.
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp *
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp *
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * @event markerEvent:mouseover
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * @preventable false
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * @param {EventFacade} e Event facade with the following additional
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * properties:
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dl>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>categoryItem</dt><dd>Hash containing information about the category <code>Axis</code>.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>valueItem</dt><dd>Hash containing information about the value <code>Axis</code>.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>node</dt><dd>The dom node of the marker.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>x</dt><dd>The x-coordinate of the mouse in relation to the Chart.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>y</dt><dd>The y-coordinate of the mouse in relation to the Chart.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>series</dt><dd>Reference to the series of the marker.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>index</dt><dd>Index of the marker in the series.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>seriesIndex</dt><dd>The <code>order</code> of the marker's series.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * </dl>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp */
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp /**
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * Broadcasts when <code>interactionType</code> is set to <code>marker</code> and a series marker has received a mouseout event.
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp *
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * @event markerEvent:mouseout
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * @preventable false
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * @param {EventFacade} e Event facade with the following additional
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * properties:
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dl>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>categoryItem</dt><dd>Hash containing information about the category <code>Axis</code>.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>valueItem</dt><dd>Hash containing information about the value <code>Axis</code>.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>node</dt><dd>The dom node of the marker.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>x</dt><dd>The x-coordinate of the mouse in relation to the Chart.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>y</dt><dd>The y-coordinate of the mouse in relation to the Chart.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>series</dt><dd>Reference to the series of the marker.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>index</dt><dd>Index of the marker in the series.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>seriesIndex</dt><dd>The <code>order</code> of the marker's series.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * </dl>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp */
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp /**
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * Broadcasts when <code>interactionType</code> is set to <code>marker</code> and a series marker has received a mousedown event.
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp *
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * @event markerEvent:mousedown
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * @preventable false
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * @param {EventFacade} e Event facade with the following additional
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * properties:
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dl>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>categoryItem</dt><dd>Hash containing information about the category <code>Axis</code>.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>valueItem</dt><dd>Hash containing information about the value <code>Axis</code>.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>node</dt><dd>The dom node of the marker.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>x</dt><dd>The x-coordinate of the mouse in relation to the Chart.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>y</dt><dd>The y-coordinate of the mouse in relation to the Chart.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>series</dt><dd>Reference to the series of the marker.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>index</dt><dd>Index of the marker in the series.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>seriesIndex</dt><dd>The <code>order</code> of the marker's series.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * </dl>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp */
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp /**
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * Broadcasts when <code>interactionType</code> is set to <code>marker</code> and a series marker has received a mouseup event.
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp *
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * @event markerEvent:mouseup
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * @preventable false
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * @param {EventFacade} e Event facade with the following additional
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * properties:
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dl>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>categoryItem</dt><dd>Hash containing information about the category <code>Axis</code>.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>valueItem</dt><dd>Hash containing information about the value <code>Axis</code>.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>node</dt><dd>The dom node of the marker.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>x</dt><dd>The x-coordinate of the mouse in relation to the Chart.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>y</dt><dd>The y-coordinate of the mouse in relation to the Chart.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>series</dt><dd>Reference to the series of the marker.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>index</dt><dd>Index of the marker in the series.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>seriesIndex</dt><dd>The <code>order</code> of the marker's series.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * </dl>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp */
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp /**
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * Broadcasts when <code>interactionType</code> is set to <code>marker</code> and a series marker has received a click event.
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp *
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * @event markerEvent:click
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * @preventable false
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * @param {EventFacade} e Event facade with the following additional
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * properties:
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dl>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>categoryItem</dt><dd>Hash containing information about the category <code>Axis</code>.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>valueItem</dt><dd>Hash containing information about the value <code>Axis</code>.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>node</dt><dd>The dom node of the marker.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>x</dt><dd>The x-coordinate of the mouse in relation to the Chart.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>y</dt><dd>The y-coordinate of the mouse in relation to the Chart.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>series</dt><dd>Reference to the series of the marker.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>index</dt><dd>Index of the marker in the series.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * <dt>seriesIndex</dt><dd>The <code>order</code> of the marker's series.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * </dl>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp */
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this.fire("markerEvent:" + type, {categoryItem:items.category, valueItem:items.value, node:markerNode, x:x, y:y, series:series, index:index, seriesIndex:seriesIndex});
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp /**
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @private
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp */
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];
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp if(axis instanceof Y.Axis)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp axis.set("dataProvider", dataProvider);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp /**
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Event listener for toggling the tooltip. If a tooltip is visible, hide it. If not, it
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * will create and show a tooltip based on the event object.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp *
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @method toggleTooltip
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp */
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp toggleTooltip: function(e)
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp var tt = this.get("tooltip");
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp if(tt.visible)
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this.hideTooltip();
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp }
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp else
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp tt.markerEventHandler.apply(this, [e]);
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp }
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp },
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 {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp tt.visible = true;
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 /**
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Hides the default tooltip
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp hideTooltip: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var tt = this.get("tooltip"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node = tt.node;
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp tt.visible = false;
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,
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp styles = val.styles,
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp props = {
1941f59d88c42b5449ef1353ec4336805bff6ac9Tripp markerLabelFunction:"markerLabelFunction",
1941f59d88c42b5449ef1353ec4336805bff6ac9Tripp planarLabelFunction:"planarLabelFunction",
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp showEvent:"showEvent",
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp hideEvent:"hideEvent",
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp markerEventHandler:"markerEventHandler",
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp planarEventHandler:"planarEventHandler"
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp };
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 }
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp for(i in props)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp if(val.hasOwnProperty(i))
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp tt[i] = val[i];
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return tt;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _getTooltip: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var node = document.createElement("div"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp tt = {
16178708ecddc36b034aea99e129ceffa009ac05Tripp markerLabelFunction: this._tooltipLabelFunction,
16178708ecddc36b034aea99e129ceffa009ac05Tripp planarLabelFunction: this._planarLabelFunction,
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp show: true,
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp hideEvent: "mouseout",
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp showEvent: "mouseover",
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp markerEventHandler: function(e)
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp var tt = this.get("tooltip"),
16178708ecddc36b034aea99e129ceffa009ac05Tripp msg = tt.markerLabelFunction.apply(this, [e.categoryItem, e.valueItem, e.index, e.series, e.seriesIndex]);
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this._showTooltip(msg, e.x + 10, e.y + 10);
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp },
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp planarEventHandler: function(e)
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp {
16178708ecddc36b034aea99e129ceffa009ac05Tripp var tt = this.get("tooltip"),
16178708ecddc36b034aea99e129ceffa009ac05Tripp msg ,
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp categoryAxis = this.get("categoryAxis");
16178708ecddc36b034aea99e129ceffa009ac05Tripp msg = tt.planarLabelFunction.apply(this, [categoryAxis, e.valueItem, e.index, e.items, e.seriesIndex]);
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this._showTooltip(msg, e.x + 10, e.y + 10);
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp };
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp node.setAttribute("id", this.get("id") + "_tooltip");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node = Y.one(node);
c8497af565e3869417da55c16f0afc9fafb7d79aTripp node.setStyle("fontSize", "85%");
c8497af565e3869417da55c16f0afc9fafb7d79aTripp node.setStyle("opacity", "0.83");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("position", "absolute");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("paddingTop", "2px");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("paddingRight", "5px");
c8497af565e3869417da55c16f0afc9fafb7d79aTripp node.setStyle("paddingBottom", "4px");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("paddingLeft", "2px");
c8497af565e3869417da55c16f0afc9fafb7d79aTripp node.setStyle("backgroundColor", "#fff");
c8497af565e3869417da55c16f0afc9fafb7d79aTripp node.setStyle("border", "1px solid #dbdccc");
91d40744967aabc3e1c105820a22e279fdecc689Tripp node.setStyle("pointerEvents", "none");
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
16178708ecddc36b034aea99e129ceffa009ac05Tripp /**
16178708ecddc36b034aea99e129ceffa009ac05Tripp * @private
16178708ecddc36b034aea99e129ceffa009ac05Tripp */
16178708ecddc36b034aea99e129ceffa009ac05Tripp _planarLabelFunction: function(categoryAxis, valueItems, index, seriesArray, seriesIndex)
16178708ecddc36b034aea99e129ceffa009ac05Tripp {
16178708ecddc36b034aea99e129ceffa009ac05Tripp var msg = "",
16178708ecddc36b034aea99e129ceffa009ac05Tripp valueItem,
16178708ecddc36b034aea99e129ceffa009ac05Tripp i = 0,
16178708ecddc36b034aea99e129ceffa009ac05Tripp len = seriesArray.length,
16178708ecddc36b034aea99e129ceffa009ac05Tripp axis,
16178708ecddc36b034aea99e129ceffa009ac05Tripp series;
16178708ecddc36b034aea99e129ceffa009ac05Tripp if(categoryAxis)
16178708ecddc36b034aea99e129ceffa009ac05Tripp {
16178708ecddc36b034aea99e129ceffa009ac05Tripp msg += categoryAxis.get("labelFunction").apply(this, [categoryAxis.getKeyValueAt(this.get("categoryKey"), index), categoryAxis.get("labelFormat")]);
16178708ecddc36b034aea99e129ceffa009ac05Tripp }
16178708ecddc36b034aea99e129ceffa009ac05Tripp
16178708ecddc36b034aea99e129ceffa009ac05Tripp for(; i < len; ++i)
16178708ecddc36b034aea99e129ceffa009ac05Tripp {
16178708ecddc36b034aea99e129ceffa009ac05Tripp series = seriesArray[i];
16178708ecddc36b034aea99e129ceffa009ac05Tripp if(series.get("visible"))
16178708ecddc36b034aea99e129ceffa009ac05Tripp {
16178708ecddc36b034aea99e129ceffa009ac05Tripp valueItem = valueItems[i];
16178708ecddc36b034aea99e129ceffa009ac05Tripp axis = valueItem.axis;
16178708ecddc36b034aea99e129ceffa009ac05Tripp msg += "<br/><span>" + valueItem.displayName + ": " + axis.get("labelFunction").apply(this, [axis.getKeyValueAt(valueItem.key, index), axis.get("labelFormat")]) + "</span>";
16178708ecddc36b034aea99e129ceffa009ac05Tripp }
16178708ecddc36b034aea99e129ceffa009ac05Tripp }
16178708ecddc36b034aea99e129ceffa009ac05Tripp return msg;
16178708ecddc36b034aea99e129ceffa009ac05Tripp },
16178708ecddc36b034aea99e129ceffa009ac05Tripp
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 */
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp _tooltipChangeHandler: function(e)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp if(this.get("tooltip"))
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp var tt = this.get("tooltip"),
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp node = tt.node,
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp show = tt.show,
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp cb = this.get("contentBox");
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp if(node && show)
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp if(!cb.containes(node))
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this._addTooltip();
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp }
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp};
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippY.ChartBase = ChartBase;