ChartBase.js revision 1aaa0b228035b36e6e3b9548aff15b91fcbaf1cf
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp/**
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * The ChartBase class is an abstract class used to create charts.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp *
a75ebc38c1de401b679953a9b87bd323f0f48d02Tripp * @module charts
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>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>markerLabelFunction</dt><dd>Reference to the function used to format a marker event triggered tooltip's text. The method contains
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * the following arguments:
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dl>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>categoryItem</dt><dd>An object containing the following:
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dl>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>axis</dt><dd>The axis to which the category is bound.</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>displayName</dt><dd>The display name set to the category (defaults to key if not provided).</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>key</dt><dd>The key of the category.</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>value</dt><dd>The value of the category.</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * </dl>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * </dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>valueItem</dt><dd>An object containing the following:
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dl>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>axis</dt><dd>The axis to which the item's series is bound.</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>displayName</dt><dd>The display name of the series. (defaults to key if not provided)</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>key</dt><dd>The key for the series.</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>value</dt><dd>The value for the series item.</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * </dl>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * </dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>itemIndex</dt><dd>The index of the item within the series.</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>series</dt><dd> The `CartesianSeries` instance of the item.</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>seriesIndex</dt><dd>The index of the series in the `seriesCollection`.</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * </dl>
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp * The method returns an `HTMLElement` which is written into the DOM using `appendChild`. If you override this method and choose to return an html string, you
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp * will also need to override the tooltip's `setTextFunction` method to accept an html string.
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * </dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>planarLabelFunction</dt><dd>Reference to the function used to format a planar event triggered tooltip's text
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dl>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>categoryAxis</dt><dd> `CategoryAxis` Reference to the categoryAxis of the chart.
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>valueItems</dt><dd>Array of objects for each series that has a data point in the coordinate plane of the event. Each object contains the following data:
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dl>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>axis</dt><dd>The value axis of the series.</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>key</dt><dd>The key for the series.</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>value</dt><dd>The value for the series item.</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>displayName</dt><dd>The display name of the series. (defaults to key if not provided)</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * </dl>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * </dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>index</dt><dd>The index of the item within its series.</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>seriesArray</dt><dd>Array of series instances for each value item.</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * <dt>seriesIndex</dt><dd>The index of the series in the `seriesCollection`.</dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * </dl>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * </dd>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * </dl>
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp * The method returns an `HTMLElement` which is written into the DOM using `appendChild`. If you override this method and choose to return an html string, you
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp * will also need to override the tooltip's `setTextFunction` method to accept an html string.
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp * </dd>
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp * <dt>setTextFunction</dt><dd>Method that writes content returned from `planarLabelFunction` or `markerLabelFunction` into the the tooltip node.
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp * has the following signature:
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp * <dl>
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp * <dt>label</dt><dd>The `HTMLElement` that the content is to be added.</dd>
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp * <dt>val</dt><dd>The content to be rendered into tooltip. This can be a `String` or `HTMLElement`. If an HTML string is used, it will be rendered as a
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp * string.</dd>
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp * </dl>
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * </dd>
87a49173dbc22a145cb87e605cca83fd42524377Tripp * </dl>
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute tooltip
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type Object
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp */
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>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>category</dt><dd>Specifies a `CategoryAxis`.</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>time</dt><dd>Specifies a `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"
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp },
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp /**
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp * Indicates whether or not markers for a series will be grouped and rendered in a single complex shape instance.
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp *
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp * @attribute groupMarkers
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp * @type Boolean
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp */
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp groupMarkers: {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp value: false,
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp setter: function(val)
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp if(this.get("graph"))
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp this.get("graph").set("groupMarkers", val);
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp }
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp return val;
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp }
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp};
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippChartBase.prototype = {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Default value function for the `Graph` attribute.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _getGraph
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @return Graph
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _getGraph: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp var graph = new Y.Graph({
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp chart:this,
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp groupMarkers: this.get("groupMarkers")
14bfa36e35102dbf271dcff98f773a01c75bd503Tripp });
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 {
2a322140e93579c14e2037ff2eb3e62eaa86c9dfTripp 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 /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Returns an `Axis` instance by key reference. If the axis was explicitly set through the `axes` attribute,
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * the key will be the same as the key used in the `axes` object. For default axes, the key for
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * the category axis is the value of the `categoryKey` (`category`). For the value axis, the default
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * key is `values`.
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");
f6b84101fdc31536da3815e81c6aa218a5057256Tripp if(axes && 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 /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Default direction of the chart.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @property _direction
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @type String
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @default horizontal
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _direction: "horizontal",
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Storage for the `dataProvider` attribute.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @property _dataProvider
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @type Array
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _dataProvider: null,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Setter method for `dataProvider` attribute.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _setDataValues
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Array} val Array to be set as `dataProvider`.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @return Array
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _setDataValues: function(val)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
2a322140e93579c14e2037ff2eb3e62eaa86c9dfTripp 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 /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Storage for `seriesCollection` attribute.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @property _seriesCollection
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @type Array
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _seriesCollection: null,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Setter method for `seriesCollection` attribute.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @property _setSeriesCollection
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Array} val Array of either `CartesianSeries` instances or objects containing series attribute key value pairs.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _setSeriesCollection: function(val)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this._seriesCollection = val;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Helper method that returns the axis class that a key references.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _getAxisClass
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {String} t The type of axis.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @return Axis
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _getAxisClass: function(t)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return this._axisClass[t];
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
f69d245bb21be88752420e834a6b6be37e9b525fTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Key value pairs of axis types.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @property _axisClass
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @type Object
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _axisClass: {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp stacked: Y.StackedAxis,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp numeric: Y.NumericAxis,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp category: Y.CategoryAxis,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp time: Y.TimeAxis
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Collection of axes.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @property _axes
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @type Array
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _axes: null,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
f6b84101fdc31536da3815e81c6aa218a5057256Tripp /**
f6b84101fdc31536da3815e81c6aa218a5057256Tripp * @method initializer
f6b84101fdc31536da3815e81c6aa218a5057256Tripp * @private
f6b84101fdc31536da3815e81c6aa218a5057256Tripp */
f6b84101fdc31536da3815e81c6aa218a5057256Tripp initializer: function()
f6b84101fdc31536da3815e81c6aa218a5057256Tripp {
f6b84101fdc31536da3815e81c6aa218a5057256Tripp this._axesRenderQueue = [];
f6b84101fdc31536da3815e81c6aa218a5057256Tripp this.after("dataProviderChange", this._dataProviderChangeHandler);
f6b84101fdc31536da3815e81c6aa218a5057256Tripp },
f6b84101fdc31536da3815e81c6aa218a5057256Tripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method renderUI
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 },
f6b84101fdc31536da3815e81c6aa218a5057256Tripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @property bindUI
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);
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,
8b594f23b40af0ed8368f49ee58370563d1ef0e0Tripp len,
8b594f23b40af0ed8368f49ee58370563d1ef0e0Tripp markerClassName = "." + SERIES_MARKER;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(interactionType == "marker")
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp hideEvent = tt.hideEvent;
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp showEvent = tt.showEvent;
8b594f23b40af0ed8368f49ee58370563d1ef0e0Tripp Y.delegate("mouseenter", Y.bind(this._markerEventDispatcher, this), cb, markerClassName);
8b594f23b40af0ed8368f49ee58370563d1ef0e0Tripp Y.delegate("mousedown", Y.bind(this._markerEventDispatcher, this), cb, markerClassName);
8b594f23b40af0ed8368f49ee58370563d1ef0e0Tripp Y.delegate("mouseup", Y.bind(this._markerEventDispatcher, this), cb, markerClassName);
8b594f23b40af0ed8368f49ee58370563d1ef0e0Tripp Y.delegate("mouseleave", Y.bind(this._markerEventDispatcher, this), cb, markerClassName);
8b594f23b40af0ed8368f49ee58370563d1ef0e0Tripp Y.delegate("click", Y.bind(this._markerEventDispatcher, this), cb, markerClassName);
8b594f23b40af0ed8368f49ee58370563d1ef0e0Tripp Y.delegate("mousemove", Y.bind(this._positionTooltip, this), cb, markerClassName);
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 {
2a322140e93579c14e2037ff2eb3e62eaa86c9dfTripp 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 /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Event handler for marker events.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _markerEventDispatcher
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Object} e Event object.
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("_"),
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp index = strArr.pop(),
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp seriesIndex = strArr.pop(),
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp series = this.getSeries(parseInt(seriesIndex, 10)),
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp items = this.getSeriesItems(series, index),
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp pageX = e.pageX,
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp pageY = e.pageY,
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp x = pageX - cb.getX(),
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp y = 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 /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Broadcasts when `interactionType` is set to `marker` 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>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>categoryItem</dt><dd>Hash containing information about the category `Axis`.</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>valueItem</dt><dd>Hash containing information about the value `Axis`.</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>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>seriesIndex</dt><dd>The `order` of the marker's series.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * </dl>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp */
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Broadcasts when `interactionType` is set to `marker` 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>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>categoryItem</dt><dd>Hash containing information about the category `Axis`.</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>valueItem</dt><dd>Hash containing information about the value `Axis`.</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>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>seriesIndex</dt><dd>The `order` of the marker's series.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * </dl>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp */
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Broadcasts when `interactionType` is set to `marker` 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>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>categoryItem</dt><dd>Hash containing information about the category `Axis`.</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>valueItem</dt><dd>Hash containing information about the value `Axis`.</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>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>seriesIndex</dt><dd>The `order` of the marker's series.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * </dl>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp */
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Broadcasts when `interactionType` is set to `marker` 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>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>categoryItem</dt><dd>Hash containing information about the category `Axis`.</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>valueItem</dt><dd>Hash containing information about the value `Axis`.</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>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>seriesIndex</dt><dd>The `order` of the marker's series.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * </dl>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp */
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Broadcasts when `interactionType` is set to `marker` 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>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>categoryItem</dt><dd>Hash containing information about the category `Axis`.</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>valueItem</dt><dd>Hash containing information about the value `Axis`.</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>
3534a81072e8770e29c90e09015e57e28b644dbcTripp * <dt>pageX</dt><dd>The x location of the event on the page (including scroll)</dd>
3534a81072e8770e29c90e09015e57e28b644dbcTripp * <dt>pageY</dt><dd>The y location of the event on the page (including scroll)</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>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>seriesIndex</dt><dd>The `order` of the marker's series.</dd>
3534a81072e8770e29c90e09015e57e28b644dbcTripp * <dt>originEvent</dt><dd>Underlying dom event.</dd>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp * </dl>
1dc743f5ebb81123e0c921f2d70392f1d160ddbfTripp */
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp this.fire("markerEvent:" + type, {
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp originEvent: e,
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp pageX:pageX,
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp pageY:pageY,
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp categoryItem:items.category,
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp valueItem:items.value,
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp node:markerNode,
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp x:x,
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp y:y,
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp series:series,
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp index:index,
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp seriesIndex:seriesIndex
4f6209ded4da421d5e804d9b6740c640e801b0aaTripp });
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Event handler for dataProviderChange.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _dataProviderChangeHandler
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Object} e Event object.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @private
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _dataProviderChangeHandler: function(e)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var dataProvider = this.get("dataProvider"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp axes = this.get("axes"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp i,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp axis;
f6b84101fdc31536da3815e81c6aa218a5057256Tripp if(axes)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
f6b84101fdc31536da3815e81c6aa218a5057256Tripp for(i in axes)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
f6b84101fdc31536da3815e81c6aa218a5057256Tripp if(axes.hasOwnProperty(i))
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
f6b84101fdc31536da3815e81c6aa218a5057256Tripp axis = axes[i];
f6b84101fdc31536da3815e81c6aa218a5057256Tripp if(axis instanceof Y.Axis)
f6b84101fdc31536da3815e81c6aa218a5057256Tripp {
f6b84101fdc31536da3815e81c6aa218a5057256Tripp axis.set("dataProvider", dataProvider);
f6b84101fdc31536da3815e81c6aa218a5057256Tripp }
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
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Object} e Event object.
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 /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Shows a tooltip
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _showTooltip
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {String} msg Message to dispaly in the tooltip.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Number} x x-coordinate
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Number} y y-coordinate
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;
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp tt.setTextFunction(node, msg);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("top", y + "px");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp node.setStyle("left", x + "px");
6f23a314f0a0a46e307de6a01966481ec961e4daTripp node.setStyle("visibility", "visible");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Positions the tooltip
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _positionTooltip
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Object} e Event object.
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
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method hideTooltip
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);
6f23a314f0a0a46e307de6a01966481ec961e4daTripp node.setStyle("visibility", "hidden");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Adds a tooltip to the dom.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _addTooltip
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _addTooltip: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp var tt = this.get("tooltip"),
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp id = this.get("id") + "_tooltip",
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp cb = this.get("contentBox"),
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp oldNode = DOCUMENT.getElementById(id);
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp if(oldNode)
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp {
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp cb.removeChild(oldNode);
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp }
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp tt.node.setAttribute("id", id);
6f23a314f0a0a46e307de6a01966481ec961e4daTripp tt.node.setStyle("visibility", "hidden");
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp cb.appendChild(tt.node);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Updates the tooltip attribute.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _updateTooltip
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Object} val Object containing properties for the tooltip.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @return Object
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _updateTooltip: function(val)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp var tt = this._tooltip,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp i,
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp styles,
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp node,
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp props = {
1941f59d88c42b5449ef1353ec4336805bff6ac9Tripp markerLabelFunction:"markerLabelFunction",
1941f59d88c42b5449ef1353ec4336805bff6ac9Tripp planarLabelFunction:"planarLabelFunction",
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp setTextFunction:"setTextFunction",
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp showEvent:"showEvent",
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp hideEvent:"hideEvent",
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp markerEventHandler:"markerEventHandler",
7389f77f1b7fbad0e1cd77f75f8d1bda7aa703c0Pat Cavit planarEventHandler:"planarEventHandler",
7389f77f1b7fbad0e1cd77f75f8d1bda7aa703c0Pat Cavit show:"show"
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp };
2a322140e93579c14e2037ff2eb3e62eaa86c9dfTripp if(Y_Lang.isObject(val))
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp styles = val.styles;
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp node = Y.one(val.node) || tt.node;
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp if(styles)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp for(i in styles)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp if(styles.hasOwnProperty(i))
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp {
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp node.setStyle(i, styles[i]);
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp for(i in props)
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp {
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp if(val.hasOwnProperty(i))
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp {
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp tt[i] = val[i];
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp }
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp }
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp tt.node = node;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return tt;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Default getter for `tooltip` attribute.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _getTooltip
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @return Object
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _getTooltip: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
a5057260e5538ddf2faca20fa81271eeff2bf892Tripp var node = DOCUMENT.createElement("div"),
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp tt = {
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp setTextFunction: SETTEXT,
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");
6f23a314f0a0a46e307de6a01966481ec961e4daTripp node.setStyle("visibility", "hidden");
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp tt.node = Y.one(node);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this._tooltip = tt;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return tt;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
16178708ecddc36b034aea99e129ceffa009ac05Tripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Formats tooltip text when `interactionType` is `planar`.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _planarLabelFunction
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Axis} categoryAxis Reference to the categoryAxis of the chart.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Array} valueItems Array of objects for each series that has a data point in the coordinate plane of the event. Each object contains the following data:
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dl>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>axis</dt><dd>The value axis of the series.</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>key</dt><dd>The key for the series.</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>value</dt><dd>The value for the series item.</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>displayName</dt><dd>The display name of the series. (defaults to key if not provided)</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * </dl>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Number} index The index of the item within its series.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Array} seriesArray Array of series instances for each value item.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Number} seriesIndex The index of the series in the `seriesCollection`.
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * @return {String | HTML}
16178708ecddc36b034aea99e129ceffa009ac05Tripp * @private
16178708ecddc36b034aea99e129ceffa009ac05Tripp */
16178708ecddc36b034aea99e129ceffa009ac05Tripp _planarLabelFunction: function(categoryAxis, valueItems, index, seriesArray, seriesIndex)
16178708ecddc36b034aea99e129ceffa009ac05Tripp {
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp var msg = DOCUMENT.createElement("div"),
16178708ecddc36b034aea99e129ceffa009ac05Tripp valueItem,
16178708ecddc36b034aea99e129ceffa009ac05Tripp i = 0,
16178708ecddc36b034aea99e129ceffa009ac05Tripp len = seriesArray.length,
16178708ecddc36b034aea99e129ceffa009ac05Tripp axis,
16178708ecddc36b034aea99e129ceffa009ac05Tripp series;
16178708ecddc36b034aea99e129ceffa009ac05Tripp if(categoryAxis)
16178708ecddc36b034aea99e129ceffa009ac05Tripp {
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp msg.appendChild(DOCUMENT.createTextNode(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;
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp msg.appendChild(DOCUMENT.createElement("br"));
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp msg.appendChild(DOCUMENT.createTextNode(valueItem.displayName + ": " + axis.get("labelFunction").apply(this, [axis.getKeyValueAt(valueItem.key, index), axis.get("labelFormat")])));
16178708ecddc36b034aea99e129ceffa009ac05Tripp }
16178708ecddc36b034aea99e129ceffa009ac05Tripp }
16178708ecddc36b034aea99e129ceffa009ac05Tripp return msg;
16178708ecddc36b034aea99e129ceffa009ac05Tripp },
16178708ecddc36b034aea99e129ceffa009ac05Tripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Formats tooltip text when `interactionType` is `marker`.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _tooltipLabelFunction
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Object} categoryItem An object containing the following:
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dl>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>axis</dt><dd>The axis to which the category is bound.</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>displayName</dt><dd>The display name set to the category (defaults to key if not provided)</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>key</dt><dd>The key of the category.</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>value</dt><dd>The value of the category</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * </dl>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Object} valueItem An object containing the following:
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dl>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>axis</dt><dd>The axis to which the item's series is bound.</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>displayName</dt><dd>The display name of the series. (defaults to key if not provided)</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>key</dt><dd>The key for the series.</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * <dt>value</dt><dd>The value for the series item.</dd>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * </dl>
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Number} itemIndex The index of the item within the series.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {CartesianSeries} series The `CartesianSeries` instance of the item.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Number} seriesIndex The index of the series in the `seriesCollection`.
2b02938d1550d7e1cea52d019c56997ff08d40c3Tripp * @return {String | HTML}
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * @private
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp */
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _tooltipLabelFunction: function(categoryItem, valueItem, itemIndex, series, seriesIndex)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp {
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp var msg = DOCUMENT.createElement("div");
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp msg.appendChild(DOCUMENT.createTextNode(categoryItem.displayName +
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp ": " + categoryItem.axis.get("labelFunction").apply(this, [categoryItem.value, categoryItem.axis.get("labelFormat")])));
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp msg.appendChild(DOCUMENT.createElement("br"));
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp msg.appendChild(DOCUMENT.createTextNode(valueItem.displayName +
1aaa0b228035b36e6e3b9548aff15b91fcbaf1cfTripp ": " + valueItem.axis.get("labelFunction").apply(this, [valueItem.value, valueItem.axis.get("labelFormat")])));
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return msg;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp },
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp /**
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Event handler for the tooltipChange.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp *
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _tooltipChangeHandler
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Object} e Event object.
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 {
9b6be22e7870d13bda894c78f45b0646fe27d356Tripp if(!cb.contains(node))
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp {
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp this._addTooltip();
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp }
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp }
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp};
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippY.ChartBase = ChartBase;