4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-chart-Tip'>/**
19 </span> * @class Ext.chart.Tip
20 * Provides tips for Ext.chart.series.Series.
22 Ext.define('Ext.chart.Tip', {
24 /* Begin Definitions */
26 requires: ['Ext.tip.ToolTip', 'Ext.chart.TipSurface'],
30 constructor: function(config) {
37 me.tipConfig = Ext.apply({}, config.tips, {
38 renderer: Ext.emptyFn,
39 constrainPosition: false
41 me.tooltip = Ext.create('Ext.tip.ToolTip', me.tipConfig);
42 me.chart.surface.on('mousemove', me.tooltip.onMouseMove, me.tooltip);
43 me.chart.surface.on('mouseleave', function() {
46 if (me.tipConfig.surface) {
47 //initialize a surface
48 surface = me.tipConfig.surface;
49 sprites = surface.sprites;
50 tipSurface = Ext.create('Ext.chart.TipSurface', {
51 id: 'tipSurfaceComponent',
54 if (surface.width && surface.height) {
55 tipSurface.setSize(surface.width, surface.height);
57 me.tooltip.add(tipSurface);
58 me.spriteTip = tipSurface;
63 showTip: function(item) {
68 clearTimeout(me.tipTimeout);
69 var tooltip = me.tooltip,
70 spriteTip = me.spriteTip,
71 tipConfig = me.tipConfig,
72 trackMouse = tooltip.trackMouse,
73 sprite, surface, surfaceExt, pos, x, y;
75 tooltip.trackMouse = true;
77 surface = sprite.surface;
78 surfaceExt = Ext.get(surface.getId());
80 pos = surfaceExt.getXY();
81 x = pos[0] + (sprite.attr.x || 0) + (sprite.attr.translation && sprite.attr.translation.x || 0);
82 y = pos[1] + (sprite.attr.y || 0) + (sprite.attr.translation && sprite.attr.translation.y || 0);
83 tooltip.targetXY = [x, y];
87 tipConfig.renderer.call(tooltip, item.storeItem, item, spriteTip.surface);
89 tipConfig.renderer.call(tooltip, item.storeItem, item);
92 tooltip.trackMouse = trackMouse;
95 hideTip: function(item) {
96 var tooltip = this.tooltip;
100 clearTimeout(this.tipTimeout);
101 this.tipTimeout = setTimeout(function() {