ChartBase.js revision 82d0cf8c731b23f6a2fbb31e3e696e629444363e
/**
* The ChartBase class is an abstract class used to create charts.
*
* @class ChartBase
* @constructor
*/
function ChartBase() {}
/**
* Reference to the default tooltip available for the chart.
* <p>Contains the following properties:</p>
* <ul>
* <li>node: reference to the actual dom node</li>
* <li>labelFunction: reference to the function used to format the tooltip's text</li>
* <li>showEvent: event that should trigger the tooltip</li>
* <li>hideEvent: event that should trigger the removal of a tooltip (can be an event or an array of events)</li>
* <li>styles: hash of style properties that will be applied to the tooltip node</li>
* <li>show: indicates whether or not to show the tooltip</li>
* <li>markerEventHandler: displays and hides tooltip based on marker events</li>
* <li>planarEventHandler: displays and hides tooltip based on planar events</li>
* </ul>
* @attribute tooltip
* @type Object
*/
tooltip: {
valueFn: "_getTooltip",
{
return this._updateTooltip(val);
}
},
/**
* The key value used for the chart's category axis.
*
* @attribute categoryKey
* @type String
*/
categoryKey: {
value: "category"
},
/**
* Indicates the type of axis to use for the category axis.
*
* <ul>
* <li>category</li>
* <li>time</li>
* </ul>
*
* @attribute categoryType
* @type String
*/
value:"category"
},
/**
* Indicates the the type of interactions that will fire events.
*
* <ul>
* <li>marker</li>
* <li>planar</li>
* <li>none</li>
* </ul>
*
* @attribute interactionType
* @type String
*/
value: "marker"
},
/**
* Data used to generate the chart.
*
* @attribute dataProvider
* @type Array
*/
dataProvider: {
{
return this._setDataValues(val);
}
},
/**
* A collection of keys that map to the series axes. If no keys are set,
* they will be generated automatically depending on the data structure passed into
* the chart.
*
* @attribute seriesKeys
* @type Array
*/
seriesKeys: {},
/**
* Reference to all the axes in the chart.
*
* @attribute axesCollection
* @type Array
*/
axesCollection: {},
/**
* Reference to graph instance.
*
* @attribute graph
* @type Graph
*/
graph: {
valueFn: "_getGraph"
}
};
/**
* @private
* @description Default value function for the <code>graph</code> attribute.
*/
_getGraph: function()
{
this.fire("chartRendered");
}, this));
return graph;
},
/**
* Returns a series instance by index or key value.
*
* @method getSeries
* @param val
*/
{
var series = null,
if(graph)
{
{
}
else
{
}
}
return series;
},
/**
* Returns axis by key reference
*
* @method getAxisByKey
* @param {String} val Key reference used to look up the axis.
*/
getAxisByKey: function(val)
{
var axis,
{
}
return axis;
},
/**
* Returns the category axis for the chart.
*
* @method getCategoryAxis
*/
getCategoryAxis: function()
{
var axis,
{
}
return axis;
},
/**
* @private
*/
_direction: "horizontal",
/**
* @private
*/
_dataProvider: null,
/**
* @private
*/
_setDataValues: function(val)
{
{
var hash,
dp = [],
i = 0,
n,
for(; i < l; ++i)
{
for(n = 1; n < sl; ++n)
{
}
}
return dp;
}
return val;
},
/**
* @private
*/
_seriesCollection: null,
/**
* @private
*/
_setSeriesCollection: function(val)
{
this._seriesCollection = val;
},
/**
* @private
*/
_getAxisClass: function(t)
{
return this._axisClass[t];
},
/**
* @private
*/
_axisClass: {
stacked: Y.StackedAxis,
numeric: Y.NumericAxis,
category: Y.CategoryAxis,
},
/**
* @private
*/
_axes: null,
/**
* @private
*/
renderUI: function()
{
//move the position = absolute logic to a class file
this._addAxes();
this._addSeries();
{
this._addTooltip();
}
this._redraw();
},
/**
* @private
*/
bindUI: function()
{
hideEvent = "mouseout",
showEvent = "mouseover",
i = 0,
len;
if(interactionType == "marker")
{
}
else if(interactionType == "planar")
{
}
if(tt)
{
{
}
else
{
if(showEvent)
{
}
if(hideEvent)
{
{
for(; i < len; ++i)
{
}
}
}
}
}
},
/**
* @private
*/
_markerEventDispatcher: function(e)
{
markerNode = e.currentTarget,
if(type == "mouseenter")
{
type = "mouseover";
}
else if(type == "mouseleave")
{
type = "mouseout";
}
e.halt();
this.fire("markerEvent:" + type, {categoryItem:items.category, valueItem:items.value, node:markerNode, x:x, y:y, series:series, index:index, seriesIndex:seriesIndex});
},
/**
* @private
*/
_dataProviderChangeHandler: function(e)
{
i,
axis;
for(i in axes)
{
if(axes.hasOwnProperty(i))
{
{
}
}
}
},
/**
* Event listener for toggling the tooltip. If a tooltip is visible, hide it. If not, it
* will create and show a tooltip based on the event object.
*
* @method toggleTooltip
*/
toggleTooltip: function(e)
{
{
this.hideTooltip();
}
else
{
}
},
/**
* @private
*/
_showTooltip: function(msg, x, y)
{
if(msg)
{
}
},
/**
* @private
*/
_positionTooltip: function(e)
{
if(node)
{
}
},
/**
* Hides the default tooltip
*/
hideTooltip: function()
{
},
/**
* @private
*/
_addTooltip: function()
{
},
/**
* @private
*/
_updateTooltip: function(val)
{
i,
props = {
labelFunction:"labelFunction",
showEvent:"showEvent",
hideEvent:"hideEvent",
markerEventHandler:"markerEventHandler",
planarEventHandler:"planarEventHandler"
};
if(styles)
{
for(i in styles)
{
if(styles.hasOwnProperty(i))
{
}
}
}
for(i in props)
{
if(val.hasOwnProperty(i))
{
}
}
return tt;
},
/**
* @private
*/
_getTooltip: function()
{
tt = {
show: true,
hideEvent: "mouseout",
showEvent: "mouseover",
markerEventHandler: function(e)
{
msg = tt.labelFunction.apply(this, [e.categoryItem, e.valueItem, e.index, e.series, e.seriesIndex]);
},
planarEventHandler: function(e)
{
i = 0,
msg = "",
axis,
if(categoryAxis)
{
msg = categoryAxis.get("labelFunction").apply(this, [categoryAxis.getKeyValueAt(this.get("categoryKey"), index), categoryAxis.get("labelFormat")]);
}
for(; i < len; ++i)
{
{
msg += "<br/><span>" + valueItem.displayName + " " + axis.get("labelFunction").apply(this, [axis.getKeyValueAt(valueItem.key, index), axis.get("labelFormat")]) + "</span>";
}
}
}
};
return tt;
},
/**
* @private
*/
{
": " + categoryItem.axis.get("labelFunction").apply(this, [categoryItem.value, categoryItem.axis.get("labelFormat")]) +
": " + valueItem.axis.get("labelFunction").apply(this, [valueItem.value, valueItem.axis.get("labelFormat")]);
return msg;
},
/**
* @private
*/
_tooltipChangeHandler: function(e)
{
if(this.get("tooltip"))
{
{
{
this._addTooltip();
}
}
}
}
};