3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * @class Ext.chart.Callout
17 * A mixin providing callout functionality for Ext.chart.series.Series.
19 Ext.define('Ext.chart.Callout', {
21 /* Begin Definitions */
25 constructor: function(config) {
26 if (config.callouts) {
27 config.callouts.styles = Ext.applyIf(config.callouts.styles || {}, {
29 font: "11px Helvetica, sans-serif"
31 this.callouts = Ext.apply(this.callouts || {}, config.callouts);
32 this.calloutsArray = [];
36 renderCallouts: function() {
43 animate = me.chart.animate,
45 styles = config.styles,
46 group = me.calloutsArray,
47 store = me.chart.store,
48 len = store.getCount(),
49 ratio = items.length / len,
50 previouslyPlacedCallouts = [],
56 for (i = 0, count = 0; i < len; i++) {
57 for (j = 0; j < ratio; j++) {
58 var item = items[count],
60 storeItem = store.getAt(i),
63 display = config.filter(storeItem);
65 if (!display && !label) {
71 group[count] = label = me.onCreateCallout(storeItem, item, i, display, j, count);
74 if (label[p] && label[p].setAttributes) {
75 label[p].setAttributes(styles, true);
81 if (label[p].setAttributes) {
82 label[p].setAttributes({
85 } else if(label[p].setVisible) {
86 label[p].setVisible(false);
91 config.renderer(label, storeItem);
92 me.onPlaceCallout(label, storeItem, item, i, display, animate,
93 j, count, previouslyPlacedCallouts);
94 previouslyPlacedCallouts.push(label);
98 this.hideCallouts(count);
101 onCreateCallout: function(storeItem, item, i, display) {
103 group = me.calloutsGroup,
104 config = me.callouts,
105 styles = config.styles,
106 width = styles.width,
107 height = styles.height,
109 surface = chart.surface,
116 calloutObj.lines = surface.add(Ext.apply({},
120 stroke: me.getLegendColor() || '#555'
125 calloutObj.panel = Ext.create('widget.panel', {
126 style: "position: absolute;",
137 hideCallouts: function(index) {
138 var calloutsArray = this.calloutsArray,
139 len = calloutsArray.length,
142 while (len-->index) {
143 co = calloutsArray[len];