82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * The PieChart class creates a pie chart
a75ebc38c1de401b679953a9b87bd323f0f48d02Tripp * @module charts
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @class PieChart
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @extends ChartBase
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @constructor
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTrippY.PieChart = Y.Base.create("pieChart", Y.Widget, [Y.ChartBase], {
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Calculates and returns a `seriesCollection`.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _getSeriesCollection
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @return Array
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp for(; i < l; ++i)
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Creates `Axis` instances.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _parseAxes
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Object} val Object containing `Axis` instances or objects in which to construct `Axis` instances.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @return Object
8215dd9a19d775d6391d4f44be2ca8268952e048Tripp axis.on("axisRendered", Y.bind(this._itemRendered, this));
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Adds axes to the chart.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _addAxes
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Renders the Graph.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _addSeries
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp this._seriesCollection = graph.get("seriesCollection");
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Parse and sets the axes for the chart.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _parseSeriesAxes
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Array} c A collection `PieSeries` instance.
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp for(; i < len; ++i)
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp //If series is an actual series instance,
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp //replace axes attribute string ids with axes
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp if(s instanceof Y.PieSeries)
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Generates and returns a key-indexed object containing `Axis` instances or objects used to create `Axis` instances.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _getDefaultAxes
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @return Object
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Returns an object literal containing a categoryItem and a valueItem for a given series index.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @method getSeriesItem
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @param series Reference to a series.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @param index Index of the specified item within a series.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @return Object
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp categoryItem.value = categoryItem.axis.getKeyValueAt(categoryItem.key, index);
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp valueItem.value = valueItem.axis.getKeyValueAt(valueItem.key, index);
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Handler for sizeChanged event.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _sizeChanged
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @param {Object} e Event object.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * Redraws the chart instance.
8209f3939e32e0e5bde64192267fdaf9db6f4fbcTripp * @method _redraw
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp _redraw: function()
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp * Formats tooltip text for a pie chart.
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp * @method _tooltipLabelFunction
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp * @param {Object} categoryItem An object containing the following:
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp * <dt>axis</dt><dd>The axis to which the category is bound.</dd>
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp * <dt>displayName</dt><dd>The display name set to the category (defaults to key if not provided)</dd>
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp * <dt>key</dt><dd>The key of the category.</dd>
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp * <dt>value</dt><dd>The value of the category</dd>
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp * @param {Object} valueItem An object containing the following:
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp * <dt>axis</dt><dd>The axis to which the item's series is bound.</dd>
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp * <dt>displayName</dt><dd>The display name of the series. (defaults to key if not provided)</dd>
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp * <dt>key</dt><dd>The key for the series.</dd>
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp * <dt>value</dt><dd>The value for the series item.</dd>
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp * @param {Number} itemIndex The index of the item within the series.
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp * @param {CartesianSeries} series The `PieSeries` instance of the item.
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp * @param {Number} seriesIndex The index of the series in the `seriesCollection`.
d79066bfa31eec6909a20ccabb5227cc1e1ea2d0Tripp * @return {HTML}
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp _tooltipLabelFunction: function(categoryItem, valueItem, itemIndex, series, seriesIndex)
5c85869b71e935c40b7f7fbcdc2a7977348f786aTripp pct = Math.round((valueItem.value / total) * 10000)/100;
d79066bfa31eec6909a20ccabb5227cc1e1ea2d0Tripp msg.appendChild(DOCUMENT.createTextNode(categoryItem.displayName +
d79066bfa31eec6909a20ccabb5227cc1e1ea2d0Tripp ": " + categoryItem.axis.get("labelFunction").apply(this, [categoryItem.value, categoryItem.axis.get("labelFormat")])));
d79066bfa31eec6909a20ccabb5227cc1e1ea2d0Tripp msg.appendChild(DOCUMENT.createTextNode(valueItem.displayName +
d79066bfa31eec6909a20ccabb5227cc1e1ea2d0Tripp ": " + valueItem.axis.get("labelFunction").apply(this, [valueItem.value, valueItem.axis.get("labelFormat")])));
e03e2775537690229fec4bc156e946f851d2cdfdTripp * Returns the appropriate message based on the key press.
e03e2775537690229fec4bc156e946f851d2cdfdTripp * @method _getAriaMessage
e03e2775537690229fec4bc156e946f851d2cdfdTripp * @param {Number} key The keycode that was pressed.
e03e2775537690229fec4bc156e946f851d2cdfdTripp * @return String
e03e2775537690229fec4bc156e946f851d2cdfdTripp pct = Math.round((valueItem.value / total) * 10000)/100;
a0bc19798c6a993799cde08b90c1aa2f54147792Tripp msg += categoryItem.displayName + ": " + categoryItem.axis.formatLabel.apply(this, [categoryItem.value, categoryItem.axis.get("labelFormat")]) + ", ";
a0bc19798c6a993799cde08b90c1aa2f54147792Tripp msg += valueItem.displayName + ": " + valueItem.axis.formatLabel.apply(this, [valueItem.value, valueItem.axis.get("labelFormat")]) + ", ";
a0bc19798c6a993799cde08b90c1aa2f54147792Tripp msg += "Percent of total " + valueItem.displayName + ": " + pct + "%,";
4e6fa831be0e594628556cb4a51e1cede308701cTripp * Sets the aria description for the chart.
4e6fa831be0e594628556cb4a51e1cede308701cTripp * @attribute ariaDescription
4e6fa831be0e594628556cb4a51e1cede308701cTripp * @type String
a0bc19798c6a993799cde08b90c1aa2f54147792Tripp value: "Use the left and right keys to navigate through items.",
4e6fa831be0e594628556cb4a51e1cede308701cTripp this._description.appendChild(DOCUMENT.createTextNode(val));
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Axes to appear in the chart.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute axes
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type Object
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp getter: function()
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp return this._axes;
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * Collection of series to appear on the chart. This can be an array of Series instances or object literals
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp * used to describe a Series instance.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute seriesCollection
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type Array
e393eced613f9b4a5fb6bdd461d0e0bf5064d5ecTripp getter: function()
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * Type of chart when there is no series collection specified.
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @attribute type
82d0cf8c731b23f6a2fbb31e3e696e629444363eTripp * @type String