PieSeries.js revision 2a322140e93579c14e2037ff2eb3e62eaa86c9df
/**
* PieSeries visualizes data as a circular chart divided into wedges which represent data as a
* percentage of a whole.
*
* @module charts
* @class PieSeries
* @constructor
* @extends MarkerSeries
*/
/**
* Image map used for interactivity when rendered with canvas.
*
* @property _map
* @type HTMLElement
* @private
*/
_map: null,
/**
* Image used for image map when rendered with canvas.
*
* @property _image
* @type HTMLElement
* @private
*/
_image: null,
/**
* Creates or updates the image map when rendered with canvas.
*
* @method _setMap
* @private
*/
_setMap: function()
{
if(this._image)
{
{
}
}
this._image.src = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAYAAAABCAYAAAD9yd/wAAAAGXRFWHRTb2Z0d2FyZQBBZG9iZSBJbWFnZVJlYWR5ccllPAAAABJJREFUeNpiZGBgSGPAAgACDAAIkABoFyloZQAAAABJRU5ErkJggg==";
this._areaNodes = [];
},
/**
* Storage for `categoryDisplayName` attribute.
*
* @property _categoryDisplayName
* @private
*/
_categoryDisplayName: null,
/**
* Storage for `valueDisplayName` attribute.
*
* @property _valueDisplayName
* @private
*/
_valueDisplayName: null,
/**
* Adds event listeners.
*
* @method addListeners
* @private
*/
addListeners: function()
{
if(categoryAxis)
{
}
if(valueAxis)
{
}
},
/**
* Draws the series.
*
* @method validate
* @private
*/
validate: function()
{
this.draw();
this._renderered = true;
},
/**
* Event handler for the categoryAxisChange event.
*
* @method _categoryAxisChangeHandler
* @param {Object} e Event object.
* @private
*/
_categoryAxisChangeHandler: function(e)
{
},
/**
* Event handler for the valueAxisChange event.
*
* @method _valueAxisChangeHandler
* @param {Object} e Event object.
* @private
*/
_valueAxisChangeHandler: function(e)
{
},
/**
* Constant used to generate unique id.
*
* @property GUID
* @type String
* @private
*/
GUID: "pieseries",
/**
* Event handler for categoryDataChange event.
*
* @method _categoryDataChangeHandler
* @param {Object} event Event object.
* @private
*/
_categoryDataChangeHandler: function(event)
{
{
this.draw();
}
},
/**
* Event handler for valueDataChange event.
*
* @method _valueDataChangeHandler
* @param {Object} event Event object.
* @private
*/
_valueDataChangeHandler: function(event)
{
{
this.draw();
}
},
/**
* Draws the series. Overrides the base implementation.
*
* @method draw
* @protected
*/
draw: function()
{
{
this._rendered = true;
this.drawSeries();
this.fire("drawingComplete");
}
},
/**
* Draws the markers
*
* @method drawPlots
* @protected
*/
drawPlots: function()
{
totalValue = 0,
tfc,
tfa,
startAngle = -90,
halfWidth = w / 2,
halfHeight = h / 2,
i = 0,
angle = 0,
lc,
la,
lw,
for(; i < itemCount; ++i)
{
{
totalValue += value;
}
}
this._createMarkerCache();
if(isCanvas)
{
this._setMap();
}
for(i = 0; i < itemCount; i++)
{
if(totalValue === 0)
{
}
else
{
}
{
}
{
}
{
}
{
}
{
}
startAngle += angle;
wedgeStyle = {
border: {
},
fill: {
},
type: "pieslice",
cy: halfHeight,
width: w,
height: h
};
if(isCanvas)
{
}
}
this._clearMarkerCache();
},
/**
* Adds an interactive map when rendering in canvas.
*
* @method _addHotspot
* @param {Object} cfg Object containing data used to draw the hotspot
* @param {Number} seriesIndex Index of series in the `seriesCollection`.
* @param {Number} index Index of the marker using the hotspot.
* @private
*/
{
i = 1,
for(i = 1; i <= numPoints; ++i)
{
multDivAng = divAngle * i;
if(startAngle <= 90)
{
}
else
{
}
}
},
/**
* Resizes and positions markers based on a mouse interaction.
*
* @method updateMarkerState
* @param {String} type state of the marker
* @param {Number} i index of the marker
* @protected
*/
updateMarkerState: function(type, i)
{
if(this._markers[i])
{
}
},
/**
* Creates a shape to be used as a marker.
*
* @method _createMarker
* @param {Object} styles Hash of style properties.
* @param {Number} order Order of the series.
* @param {Number} index Index within the series associated with the marker.
* @return Shape
* @private
*/
{
return marker;
},
/**
* Creates a cache of markers for reuse.
*
* @method _createMarkerCache
* @private
*/
_clearMarkerCache: function()
{
i = 0,
for(; i < len; ++i)
{
marker = this._markerCache[i];
if(marker)
{
}
}
this._markerCache = [];
},
/**
* Gets the default style values for the markers.
*
* @method _getPlotDefaults
* @return Object
* @private
*/
_getPlotDefaults: function()
{
var defs = {
padding:{
top: 0,
left: 0,
right: 0,
bottom: 0
},
fill:{
alphas:["1"]
},
border: {
weight: 0,
alpha: 1
}
};
return defs;
},
/**
* Collection of default colors used for lines in a series when not specified by user.
*
* @property _defaultLineColors
* @type Array
* @protected
*/
_defaultLineColors:["#426ab3", "#d09b2c", "#000000", "#b82837", "#b384b5", "#ff7200", "#779de3", "#cbc8ba", "#7ed7a6", "#007a6c"],
/**
* Collection of default colors used for marker fills in a series when not specified by user.
*
* @property _defaultFillColors
* @type Array
* @protected
*/
_defaultFillColors:["#6084d0", "#eeb647", "#6c6b5f", "#d6484f", "#ce9ed1", "#ff9f3b", "#93b7ff", "#e0ddd0", "#94ecba", "#309687"],
/**
* Collection of default colors used for marker borders in a series when not specified by user.
*
* @property _defaultBorderColors
* @type Array
* @protected
*/
_defaultBorderColors:["#205096", "#b38206", "#000000", "#94001e", "#9d6fa0", "#e55b00", "#5e85c9", "#adab9e", "#6ac291", "#006457"],
/**
* Collection of default colors used for area fills, histogram fills and pie fills in a series when not specified by user.
*
* @property _defaultSliceColors
* @type Array
* @protected
*/
_defaultSliceColors: ["#66007f", "#a86f41", "#295454", "#996ab2", "#e8cdb7", "#90bdbd","#000000","#c3b8ca", "#968373", "#678585"],
/**
* Colors used if style colors are not specified
*
* @method _getDefaultColor
* @param {Number} index Index indicating the series order.
* @param {String} type Indicates which type of object needs the color.
* @return String
* @protected
*/
{
var colors = {
line: this._defaultLineColors,
fill: this._defaultFillColors,
border: this._defaultBorderColors,
slice: this._defaultSliceColors
},
if(index >= l)
{
}
}
}, {
ATTRS: {
/**
* Read-only attribute indicating the type of series.
*
* @attribute type
* @type String
* @default pie
*/
type: {
value: "pie"
},
/**
* Order of this instance of this `type`.
*
* @attribute order
* @type Number
*/
order: {},
/**
* Reference to the `Graph` in which the series is drawn into.
*
* @attribute graph
* @type Graph
*/
graph: {},
/**
* Reference to the `Axis` instance used for assigning
* category values to the graph.
*
* @attribute categoryAxis
* @type Axis
*/
categoryAxis: {
value: null,
{
}
},
/**
* Reference to the `Axis` instance used for assigning
* series values to the graph.
*
* @attribute categoryAxis
* @type Axis
*/
valueAxis: {
value: null,
{
}
},
/**
* Indicates which array to from the hash of value arrays in
* the category `Axis` instance.
*
* @attribute categoryKey
* @type String
*/
categoryKey: {
value: null,
{
}
},
/**
* Indicates which array to from the hash of value arrays in
* the value `Axis` instance.
*
* @attribute valueKey
* @type String
*/
valueKey: {
value: null,
{
}
},
/**
* Name used for for displaying category data
*
* @attribute categoryDisplayName
* @type String
*/
{
this._categoryDisplayName = val;
return val;
},
getter: function()
{
}
},
/**
* Name used for for displaying value data
*
* @attribute valueDisplayName
* @type String
*/
{
this._valueDisplayName = val;
return val;
},
getter: function()
{
}
},
/**
* @attribute slices
* @type Array
* @private
*/
slices: null
/**
* Style properties used for drawing markers. This attribute is inherited from `MarkerSeries`. Below are the default values:
* <dl>
* <dt>fill</dt><dd>A hash containing the following values:
* <dl>
* <dt>colors</dt><dd>An array of colors to be used for the marker fills. The color for each marker is retrieved from the
* array below:<br/>
* `["#66007f", "#a86f41", "#295454", "#996ab2", "#e8cdb7", "#90bdbd","#000000","#c3b8ca", "#968373", "#678585"]`
* </dd>
* <dt>alphas</dt><dd>An array of alpha references (Number from 0 to 1) indicating the opacity of each marker fill. The default value is [1].</dd>
* </dl>
* </dd>
* <dt>border</dt><dd>A hash containing the following values:
* <dl>
* <dt>color</dt><dd>An array of colors to be used for the marker borders. The color for each marker is retrieved from the
* array below:<br/>
* `["#205096", "#b38206", "#000000", "#94001e", "#9d6fa0", "#e55b00", "#5e85c9", "#adab9e", "#6ac291", "#006457"]`
* <dt>alpha</dt><dd>Number from 0 to 1 indicating the opacity of the marker border. The default value is 1.</dd>
* <dt>weight</dt><dd>Number indicating the width of the border. The default value is 1.</dd>
* </dl>
* </dd>
* <dt>over</dt><dd>hash containing styles for markers when highlighted by a `mouseover` event. The default
* values for each style is null. When an over style is not set, the non-over value will be used. For example,
* the default value for `marker.over.fill.color` is equivalent to `marker.fill.color`.</dd>
* </dl>
*
* @attribute styles
* @type Object
*/
}
});