ChartBase.js revision f69d245bb21be88752420e834a6b6be37e9b525f
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * The ChartBase class is an abstract class used to create charts.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @class ChartBase
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @constructor
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippfunction ChartBase() {}
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Reference to the default tooltip available for the chart.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * <p>Contains the following properties:</p>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * <li>node: reference to the actual dom node</li>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * <li>showEvent: event that should trigger the tooltip</li>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * <li>hideEvent: event that should trigger the removal of a tooltip (can be an event or an array of events)</li>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * <li>styles: hash of style properties that will be applied to the tooltip node</li>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * <li>show: indicates whether or not to show the tooltip</li>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * <li>markerEventHandler: displays and hides tooltip based on marker events</li>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * <li>planarEventHandler: displays and hides tooltip based on planar events</li>
16178708ecddc36b034aea99e129ceffa009ac05Tripp * <li>markerLabelFunction: reference to the function used to format a marker event triggered tooltip's text</li>
16178708ecddc36b034aea99e129ceffa009ac05Tripp * <li>planarLabelFunction: reference to the function used to format a planar event triggered tooltip's text</li>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute tooltip
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type Object
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * The key value used for the chart's category axis.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute categoryKey
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type String
f69d245bb21be88752420e834a6b6be37e9b525fTripp * @default category
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Indicates the type of axis to use for the category axis.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * <li>category</li>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * <li>time</li>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute categoryType
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type String
f69d245bb21be88752420e834a6b6be37e9b525fTripp * @default category
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Indicates the the type of interactions that will fire events.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * <li>marker</li>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * <li>planar</li>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * <li>none</li>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute interactionType
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type String
f69d245bb21be88752420e834a6b6be37e9b525fTripp * @default marker
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Data used to generate the chart.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute dataProvider
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type Array
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 * @attribute seriesKeys
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type Array
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Reference to all the axes in the chart.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute axesCollection
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type Array
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Reference to graph instance.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute graph
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @type Graph
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @description Default value function for the <code>graph</code> attribute.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Returns a series instance by index or key value.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method getSeries
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @param val
f69d245bb21be88752420e834a6b6be37e9b525fTripp * @return CartesianSeries
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var series = null,
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>.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method getAxisByKey
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @param {String} val Key reference used to look up the axis.
f69d245bb21be88752420e834a6b6be37e9b525fTripp * @return Axis
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Returns the category axis for the chart.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @method getCategoryAxis
f69d245bb21be88752420e834a6b6be37e9b525fTripp * @return Axis
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp for(; i < l; ++i)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return this._axisClass[t];
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 bindUI: function()
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this.after("tooltipChange", Y.bind(this._tooltipChangeHandler, this));
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this.after("dataProviderChange", this._dataProviderChangeHandler);
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");
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this._overlay.on("mousemove", Y.bind(this._planarEventDispatcher, this));
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this.on(interactionType + "Event:" + hideEvent, this.toggleTooltip);
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this.on(interactionType + "Event:" + showEvent, tt[interactionType + "EventHandler"]);
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp for(; i < len; ++i)
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this.on(interactionType + "Event:" + hideEvent[i], this.hideTooltip);
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this.on(interactionType + "Event:" + hideEvent, this.hideTooltip);
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this.fire("markerEvent:" + type, {categoryItem:items.category, valueItem:items.value, node:markerNode, x:x, y:y, series:series, index:index, seriesIndex:seriesIndex});
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 * @method toggleTooltip
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Hides the default tooltip
16178708ecddc36b034aea99e129ceffa009ac05Tripp msg = tt.markerLabelFunction.apply(this, [e.categoryItem, e.valueItem, e.index, e.series, e.seriesIndex]);
16178708ecddc36b034aea99e129ceffa009ac05Tripp msg = tt.planarLabelFunction.apply(this, [categoryAxis, e.valueItem, e.index, e.items, e.seriesIndex]);
16178708ecddc36b034aea99e129ceffa009ac05Tripp _planarLabelFunction: function(categoryAxis, valueItems, index, seriesArray, seriesIndex)
16178708ecddc36b034aea99e129ceffa009ac05Tripp msg += categoryAxis.get("labelFunction").apply(this, [categoryAxis.getKeyValueAt(this.get("categoryKey"), index), categoryAxis.get("labelFormat")]);
16178708ecddc36b034aea99e129ceffa009ac05Tripp for(; i < len; ++i)
16178708ecddc36b034aea99e129ceffa009ac05Tripp msg += "<br/><span>" + valueItem.displayName + ": " + axis.get("labelFunction").apply(this, [axis.getKeyValueAt(valueItem.key, index), axis.get("labelFormat")]) + "</span>";
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _tooltipLabelFunction: function(categoryItem, valueItem, itemIndex, series, seriesIndex)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp ": " + categoryItem.axis.get("labelFunction").apply(this, [categoryItem.value, categoryItem.axis.get("labelFormat")]) +