RGraph.fuel.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741
  1. /**
  2. * o------------------------------------------------------------------------------o
  3. * | This file is part of the RGraph package - you can learn more at: |
  4. * | |
  5. * | http://www.rgraph.net |
  6. * | |
  7. * | This package is licensed under the RGraph license. For all kinds of business |
  8. * | purposes there is a small one-time licensing fee to pay and for non |
  9. * | commercial purposes it is free to use. You can read the full license here: |
  10. * | |
  11. * | http://www.rgraph.net/license |
  12. * o------------------------------------------------------------------------------o
  13. */
  14. if (typeof(RGraph) == 'undefined') RGraph = {};
  15. /**
  16. * The Fuel widget constructor
  17. *
  18. * @param object canvas The canvas object
  19. * @param int min The minimum value
  20. * @param int max The maximum value
  21. * @param int value The indicated value
  22. */
  23. RGraph.Fuel = function (id, min, max, value)
  24. {
  25. // Get the canvas and context objects
  26. this.id = id;
  27. this.canvas = document.getElementById(typeof id === 'object' ? id.id : id);
  28. this.context = this.canvas.getContext ? this.canvas.getContext("2d") : null;
  29. this.canvas.__object__ = this;
  30. this.type = 'fuel';
  31. this.isRGraph = true;
  32. this.min = min;
  33. this.max = max;
  34. this.value = value;
  35. this.angles = {};
  36. this.currentValue = null;
  37. this.uid = RGraph.CreateUID();
  38. this.canvas.uid = this.canvas.uid ? this.canvas.uid : RGraph.CreateUID();
  39. this.coordsText = [];
  40. /**
  41. * Compatibility with older browsers
  42. */
  43. RGraph.OldBrowserCompat(this.context);
  44. // Check for support
  45. if (!this.canvas) {
  46. alert('[FUEL] No canvas support');
  47. return;
  48. }
  49. /**
  50. * The funnel charts properties
  51. */
  52. this.properties =
  53. {
  54. 'chart.colors': ['Gradient(white:red)'],
  55. 'chart.needle.color': 'red',
  56. 'chart.gutter.left': 5,
  57. 'chart.gutter.right': 5,
  58. 'chart.gutter.top': 5,
  59. 'chart.gutter.bottom': 5,
  60. 'chart.text.size': 10,
  61. 'chart.text.color': 'black', // Does not support gradients
  62. 'chart.text.font': 'Arial',
  63. 'chart.contextmenu': null,
  64. 'chart.annotatable': false,
  65. 'chart.annotate.color': 'black',
  66. 'chart.zoom.factor': 1.5,
  67. 'chart.zoom.fade.in': true,
  68. 'chart.zoom.fade.out': true,
  69. 'chart.zoom.factor': 1.5,
  70. 'chart.zoom.fade.in': true,
  71. 'chart.zoom.fade.out': true,
  72. 'chart.zoom.hdir': 'right',
  73. 'chart.zoom.vdir': 'down',
  74. 'chart.zoom.frames': 25,
  75. 'chart.zoom.delay': 16.666,
  76. 'chart.zoom.shadow': true,
  77. 'chart.zoom.background': true,
  78. 'chart.zoom.action': 'zoom',
  79. 'chart.adjustable': false,
  80. 'chart.resizable': false,
  81. 'chart.resize.handle.background': null,
  82. 'chart.icon': 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAfCAYAAAD0ma06AAAEGElEQVRIS7VXSyhtYRT+jnfe5FEMjAwUBiQGHikzRWIkkgy8YyDK+xnJK5JCeZSUGKBMiAyYkMxMJAMpSfJ+2/d8695/33NunSPnHqt2Z5+91/9/' + '/' + '/et9a/1b8Pn56dmMBhg/IWDgwNoNzc38PHxkXtN0+Tiexp9eH18fIDj1Bj63N/fw8vLS/wsmcHoqKmXT09PuL29RVFREU5OTvTJ6UIAgioQ+vLe09MTb29v8PX1RWBgICYnJ+XXIqDRWXN0dJT3nIDsWlpadP+lpSWZlD4KmL/8/' + '/7+Ls/S09N1/7y8PISHh+sK/QssDJWcHEyGCnB1dRUDAwPIzMzUx5GpAnZ1dcXy8jK2trbM5j06OsLc3JzISx8q4OzsLOOsAq6treHg4AAeHh4WJbq7u0Nzc7P+PiYmBnt7ezg9PcXExAQCAgLg5OSEx8dHuLu7Wwfc3t7G/v6+yEcjO8rIROGKaWdnZ+jr6zMDjI6OxvT0tDzr6uqS2KtksspwZ2cHjY2NuqSUhnHmilUCraysmElaWloKJpQCjI2NRX5+Pl5eXr6WlCv08/MTEMVOZDH+Zzw4CdlfX1/rDHt7ezE1NQXGkcYEKi4ulkVKYlpLGouBs/JiaGgIZL25uSlecXFxohAz/ccAz8/P4e/vj7q6Ojw8PMje5DNRy94MQ0JCUFtbK2wqKipE+sHBQbi4uPwMQ86ak5ODxMREVFdXIywsDCUlJRJDXnZlmJqaip6eHuTm5kqikGlycjIyMjL+ZrY9JSUgMzQiIgINDQ2ypaqqqkCZWXHsnjQEHB8fR0pKigAxabq7uyWOlJNxtLukTJDs7GxUVlZKDNl5oqKi8Pr6+jOAIyMjiI+Pl5JGQG4F1Qy+LN7f3fiUdGZmBsHBwRgbG8Pw8LD01ba2NmlX0rTtnTQLCwvSjEdHR3FxcSExLCwsRGRkpBR9vePzeMDyw3bT1NT0XXLiT4a7u7s4Pj4GGzd7K8GCgoKEsRR8I4Cm6hwHXV5eiv62GAE5npMTmFuBTCkzmzT7qs5Q9TlW/o6ODlvwhCHPM5SVPZIxYzNeXFxEa2srvL29YTC2GI3aMm3Zeq6urv4LMC0tDRsbG1K8k5KS9DgS0IwhKVFjSsJA22r9/f0oKCgQdvPz83JEmZ2dlcpD9maSshow0KZnlO8Csx9yK3BLKCMJPpf2xGMigdi9WXooaWdn53dxdP+amhrZh4eHh1hfX5cTW319vZyBnp+ffzNkBWBmhYaGysB/j322oCckJCArK0uGMlsJ5ubmBoPxRiMzFlomjr2MGdne3i5ANILRJEtJt6ysTG8h9gDl4am8vFwSUWron1O9LulXIOqk9pWftfdSS40yyj5Uh101wPRryuR7R1ZMX/U1pfy5IF40xcgUnGAc9wsGYxsFhy87kwAAAABJRU5ErkJggg==',
  83. 'chart.icon.redraw': true,
  84. 'chart.background.image.stretch': false,
  85. 'chart.background.image.x': null,
  86. 'chart.background.image.y': null,
  87. 'chart.labels.full': 'F',
  88. 'chart.labels.empty': 'E',
  89. 'chart.labels.count': 5,
  90. 'chart.centerx': null,
  91. 'chart.centery': null,
  92. 'chart.radius': null,
  93. 'chart.scale.visible': false,
  94. 'chart.scale.decimals': 0,
  95. 'chart.units.pre': '',
  96. 'chart.units.post': ''
  97. }
  98. /**
  99. * Bounds checking - if the value is outside the scale
  100. */
  101. if (this.value > this.max) this.value = this.max;
  102. if (this.value < this.min) this.value = this.min;
  103. /*
  104. * Translate half a pixel for antialiasing purposes - but only if it hasn't beeen
  105. * done already
  106. */
  107. if (!this.canvas.__rgraph_aa_translated__) {
  108. this.context.translate(0.5,0.5);
  109. this.canvas.__rgraph_aa_translated__ = true;
  110. }
  111. ///////////////////////////////// SHORT PROPERTIES /////////////////////////////////
  112. var RG = RGraph;
  113. var ca = this.canvas;
  114. var co = ca.getContext('2d');
  115. var prop = this.properties;
  116. //////////////////////////////////// METHODS ///////////////////////////////////////
  117. /**
  118. * A setter
  119. *
  120. * @param name string The name of the property to set
  121. * @param value mixed The value of the property
  122. */
  123. this.Set = function (name, value)
  124. {
  125. name = name.toLowerCase();
  126. /**
  127. * This should be done first - prepend the propertyy name with "chart." if necessary
  128. */
  129. if (name.substr(0,6) != 'chart.') {
  130. name = 'chart.' + name;
  131. }
  132. prop[name] = value;
  133. return this;
  134. }
  135. /**
  136. * A getter
  137. *
  138. * @param name string The name of the property to get
  139. */
  140. this.Get = function (name)
  141. {
  142. /**
  143. * This should be done first - prepend the property name with "chart." if necessary
  144. */
  145. if (name.substr(0,6) != 'chart.') {
  146. name = 'chart.' + name;
  147. }
  148. return prop[name.toLowerCase()];
  149. }
  150. /**
  151. * The function you call to draw the bar chart
  152. */
  153. this.Draw = function ()
  154. {
  155. /**
  156. * Fire the onbeforedraw event
  157. */
  158. RG.FireCustomEvent(this, 'onbeforedraw');
  159. /**
  160. * Set the current value
  161. */
  162. this.currentValue = this.value;
  163. /**
  164. * This is new in May 2011 and facilitates indiviual gutter settings,
  165. * eg chart.gutter.left
  166. */
  167. this.gutterLeft = prop['chart.gutter.left'];
  168. this.gutterRight = prop['chart.gutter.right'];
  169. this.gutterTop = prop['chart.gutter.top'];
  170. this.gutterBottom = prop['chart.gutter.bottom'];
  171. /**
  172. * Get the center X and Y of the chart. This is the center of the needle bulb
  173. */
  174. this.centerx = ((ca.width - this.gutterLeft - this.gutterRight) / 2) + this.gutterLeft;
  175. this.centery = ca.height - 20 - this.gutterBottom
  176. /**
  177. * Work out the radius of the chart
  178. */
  179. this.radius = ca.height - this.gutterTop - this.gutterBottom - 20;
  180. /**
  181. * You can now specify chart.centerx, chart.centery and chart.radius
  182. */
  183. if (typeof(prop['chart.centerx']) == 'number') this.centerx = prop['chart.centerx'];
  184. if (typeof(prop['chart.centery']) == 'number') this.centery = prop['chart.centery'];
  185. if (typeof(prop['chart.radius']) == 'number') this.radius = prop['chart.radius'];
  186. /**
  187. * Parse the colors. This allows for simple gradient syntax
  188. */
  189. if (!this.colorsParsed) {
  190. this.parseColors();
  191. // Don't want to do this again
  192. this.colorsParsed = true;
  193. }
  194. /**
  195. * The start and end angles of the chart
  196. */
  197. this.angles.start = (PI + HALFPI) - 0.5;
  198. this.angles.end = (PI + HALFPI) + 0.5;
  199. this.angles.needle = this.getAngle(this.value);
  200. /**
  201. * Draw the labels on the chart
  202. */
  203. this.DrawLabels();
  204. /**
  205. * Draw the fuel guage
  206. */
  207. this.DrawChart();
  208. /**
  209. * Setup the context menu if required
  210. */
  211. if (prop['chart.contextmenu']) {
  212. RG.ShowContext(this);
  213. }
  214. /**
  215. * This function enables resizing
  216. */
  217. if (prop['chart.resizable']) {
  218. RG.AllowResizing(this);
  219. }
  220. /**
  221. * This installs the event listeners
  222. */
  223. RG.InstallEventListeners(this);
  224. /**
  225. * Fire the RGraph ondraw event
  226. */
  227. RG.FireCustomEvent(this, 'ondraw');
  228. return this;
  229. }
  230. /**
  231. * This function actually draws the chart
  232. */
  233. this.DrawChart = function ()
  234. {
  235. /**
  236. * Draw the "Scale"
  237. */
  238. this.DrawScale();
  239. /**
  240. * Place the icon on the canvas
  241. */
  242. if (!ISOLD) {
  243. this.DrawIcon();
  244. }
  245. /**
  246. * Draw the needle
  247. */
  248. this.DrawNeedle();
  249. }
  250. /**
  251. * Draws the labels
  252. */
  253. this.DrawLabels = function ()
  254. {
  255. if (!prop['chart.scale.visible']) {
  256. var radius = (this.radius - 20);
  257. co.fillStyle = prop['chart.text.color'];
  258. // Draw the left label
  259. var y = this.centery - Math.sin(this.angles.start - PI) * (this.radius - 25);
  260. var x = this.centerx - Math.cos(this.angles.start - PI) * (this.radius - 25);
  261. RG.Text2(this, {'font':prop['chart.text.font'],
  262. 'size':prop['chart.text.size'],
  263. 'x':x,
  264. 'y':y,
  265. 'text':prop['chart.labels.empty'],
  266. 'halign': 'center',
  267. 'valign':'center',
  268. 'tag': 'labels'
  269. });
  270. // Draw the right label
  271. var y = this.centery - Math.sin(this.angles.start - PI) * (this.radius - 25);
  272. var x = this.centerx + Math.cos(this.angles.start - PI) * (this.radius - 25);
  273. RG.Text2(this, {'font':prop['chart.text.font'],
  274. 'size':prop['chart.text.size'],
  275. 'x':x,
  276. 'y':y,
  277. 'text':prop['chart.labels.full'],
  278. 'halign': 'center',
  279. 'valign':'center',
  280. 'tag': 'labels'
  281. });
  282. }
  283. }
  284. /**
  285. * Draws the needle
  286. */
  287. this.DrawNeedle = function ()
  288. {
  289. // Draw the actual needle
  290. co.beginPath();
  291. co.lineWidth = 5;
  292. co.lineCap = 'round';
  293. co.strokeStyle = prop['chart.needle.color'];
  294. /**
  295. * The angle for the needle
  296. */
  297. var angle = this.angles.needle;
  298. co.arc(this.centerx, this.centery, this.radius - 30, angle, angle + 0.0001, false);
  299. co.lineTo(this.centerx, this.centery);
  300. co.stroke();
  301. co.lineWidth = 1;
  302. // Create the gradient for the bulb
  303. var cx = this.centerx + 10;
  304. var cy = this.centery - 10
  305. var grad = co.createRadialGradient(cx, cy, 35, cx, cy, 0);
  306. grad.addColorStop(0, 'black');
  307. grad.addColorStop(1, '#eee');
  308. if (navigator.userAgent.indexOf('Firefox/6.0') > 0) {
  309. grad = co.createLinearGradient(cx + 10, cy - 10, cx - 10, cy + 10);
  310. grad.addColorStop(1, '#666');
  311. grad.addColorStop(0.5, '#ccc');
  312. }
  313. // Draw the bulb
  314. co.beginPath();
  315. co.fillStyle = grad;
  316. co.moveTo(this.centerx, this.centery);
  317. co.arc(this.centerx, this.centery, 20, 0, TWOPI, 0);
  318. co.fill();
  319. }
  320. /**
  321. * Draws the "scale"
  322. */
  323. this.DrawScale = function ()
  324. {
  325. var a, x, y;
  326. //First draw the fill background
  327. co.beginPath();
  328. co.strokeStyle = 'black';
  329. co.fillStyle = 'white';
  330. co.arc(this.centerx, this.centery, this.radius, this.angles.start, this.angles.end, false);
  331. co.arc(this.centerx, this.centery, this.radius - 10, this.angles.end, this.angles.start, true);
  332. co.closePath();
  333. co.stroke();
  334. co.fill();
  335. //First draw the fill itself
  336. var start = this.angles.start;
  337. var end = this.angles.needle;
  338. co.beginPath();
  339. co.fillStyle = prop['chart.colors'][0];
  340. co.arc(this.centerx, this.centery, this.radius, start, end, false);
  341. co.arc(this.centerx, this.centery, this.radius - 10, end, start, true);
  342. co.closePath();
  343. //co.stroke();
  344. co.fill();
  345. // This draws the tickmarks
  346. for (a = this.angles.start; a<=this.angles.end+0.01; a+=((this.angles.end - this.angles.start) / 5)) {
  347. co.beginPath();
  348. co.arc(this.centerx, this.centery, this.radius - 10, a, a + 0.0001, false);
  349. co.arc(this.centerx, this.centery, this.radius - 15, a + 0.0001, a, true);
  350. co.stroke();
  351. }
  352. /**
  353. * If chart.scale.visible is specified draw the textual scale
  354. */
  355. if (prop['chart.scale.visible']) {
  356. co.fillStyle = prop['chart.text.color'];
  357. // The labels
  358. var numLabels = prop['chart.labels.count'];
  359. var decimals = prop['chart.scale.decimals'];
  360. var font = prop['chart.text.font'];
  361. var size = prop['chart.text.size'];
  362. var units_post = prop['chart.units.post'];
  363. var units_pre = prop['chart.units.pre'];
  364. for (var i=0; i<=numLabels; ++i) {
  365. a = ((this.angles.end - this.angles.start) * (i/numLabels)) + this.angles.start;
  366. y = this.centery - Math.sin(a - PI) * (this.radius - 25);
  367. x = this.centerx - Math.cos(a - PI) * (this.radius - 25);
  368. RG.Text2(this, {'font':font,
  369. 'size':size,
  370. 'x':x,
  371. 'y':y,
  372. 'text': RG.number_format(this, (this.min + ((this.max - this.min) * (i/numLabels))).toFixed(decimals),units_pre,units_post),
  373. 'halign': 'center',
  374. 'valign':'center',
  375. 'tag': 'scale'
  376. });
  377. }
  378. }
  379. }
  380. /**
  381. * A placeholder function that is here to prevent errors
  382. */
  383. this.getShape = function (e)
  384. {
  385. }
  386. /**
  387. * This function returns the pertinent value based on a click
  388. *
  389. * @param object e An event object
  390. * @return number The relevant value at the point of click
  391. */
  392. this.getValue = function (e)
  393. {
  394. var mouseXY = RG.getMouseXY(e);
  395. var angle = RG.getAngleByXY(this.centerx, this.centery, mouseXY[0], mouseXY[1]);
  396. /**
  397. * Boundary checking
  398. */
  399. if (angle >= this.angles.end) {
  400. return this.max;
  401. } else if (angle <= this.angles.start) {
  402. return this.min;
  403. }
  404. var value = (angle - this.angles.start) / (this.angles.end - this.angles.start);
  405. value = value * (this.max - this.min);
  406. value = value + this.min;
  407. return value;
  408. }
  409. /**
  410. * The getObjectByXY() worker method. Don't call this call:
  411. *
  412. * RG.ObjectRegistry.getObjectByXY(e)
  413. *
  414. * @param object e The event object
  415. */
  416. this.getObjectByXY = function (e)
  417. {
  418. var mouseXY = RG.getMouseXY(e);
  419. var angle = RG.getAngleByXY(this.centerx, this.centery, mouseXY[0], mouseXY[1]);
  420. var accuracy = 15;
  421. var leftMin = this.centerx - this.radius;
  422. var rightMax = this.centerx + this.radius;
  423. var topMin = this.centery - this.radius;
  424. var bottomMax = this.centery + this.radius;
  425. if (
  426. mouseXY[0] > leftMin
  427. && mouseXY[0] < rightMax
  428. && mouseXY[1] > topMin
  429. && mouseXY[1] < bottomMax
  430. ) {
  431. return this;
  432. }
  433. }
  434. /**
  435. * Draws the icon
  436. */
  437. this.DrawIcon = function ()
  438. {
  439. if (!ISOLD) {
  440. if (!this.__icon__ || !this.__icon__.__loaded__) {
  441. var img = new Image();
  442. img.src = prop['chart.icon'];
  443. img.__object__ = this;
  444. this.__icon__ = img;
  445. img.onload = function (e)
  446. {
  447. img.__loaded__ = true;
  448. var obj = img.__object__;
  449. //var co = obj.context;
  450. //var prop = obj.properties;
  451. co.drawImage(img,obj.centerx - (img.width / 2), obj.centery - obj.radius + 35);
  452. obj.DrawNeedle();
  453. if (prop['chart.icon.redraw']) {
  454. obj.Set('chart.icon.redraw', false);
  455. RG.Clear(obj.canvas);
  456. RG.RedrawCanvas(ca);
  457. }
  458. }
  459. } else {
  460. var img = this.__icon__;
  461. co.drawImage(img,this.centerx - (img.width / 2), this.centery - this.radius + 35);
  462. }
  463. }
  464. this.DrawNeedle();
  465. }
  466. /**
  467. * This method handles the adjusting calculation for when the mouse is moved
  468. *
  469. * @param object e The event object
  470. */
  471. this.Adjusting_mousemove = function (e)
  472. {
  473. /**
  474. * Handle adjusting for the Fuel gauge
  475. */
  476. if (prop['chart.adjustable'] && RG.Registry.Get('chart.adjusting') && RG.Registry.Get('chart.adjusting').uid == this.uid) {
  477. this.value = this.getValue(e);
  478. RG.Clear(ca);
  479. RG.RedrawCanvas(ca);
  480. RG.FireCustomEvent(this, 'onadjust');
  481. }
  482. }
  483. /**
  484. * This method gives you the relevant angle (in radians) that a particular value is
  485. *
  486. * @param number value The relevant angle
  487. */
  488. this.getAngle = function (value)
  489. {
  490. // Range checking
  491. if (value < this.min || value > this.max) {
  492. return null;
  493. }
  494. var angle = (((value - this.min) / (this.max - this.min)) * (this.angles.end - this.angles.start)) + this.angles.start;
  495. return angle;
  496. }
  497. /**
  498. * This allows for easy specification of gradients
  499. */
  500. this.parseColors = function ()
  501. {
  502. var props = this.properties;
  503. var colors = props['chart.colors'];
  504. for (var i=0; i<colors.length; ++i) {
  505. colors[i] = this.parseSingleColorForLinearGradient(colors[i]);
  506. }
  507. props['chart.needle.color'] = this.parseSingleColorForRadialGradient(props['chart.needle.color']);
  508. }
  509. /**
  510. * This parses a single color value
  511. */
  512. this.parseSingleColorForLinearGradient = function (color)
  513. {
  514. if (!color || typeof(color) != 'string') {
  515. return color;
  516. }
  517. if (color.match(/^gradient\((.*)\)$/i)) {
  518. var parts = RegExp.$1.split(':');
  519. // Create the gradient
  520. var grad = co.createLinearGradient(prop['chart.gutter.left'],0,ca.width - prop['chart.gutter.right'],0);
  521. var diff = 1 / (parts.length - 1);
  522. grad.addColorStop(0, RG.trim(parts[0]));
  523. for (var j=1; j<parts.length; ++j) {
  524. grad.addColorStop(j * diff, RG.trim(parts[j]));
  525. }
  526. }
  527. return grad ? grad : color;
  528. }
  529. /**
  530. * This parses a single color value
  531. */
  532. this.parseSingleColorForRadialGradient = function (color)
  533. {
  534. if (!color || typeof(color) != 'string') {
  535. return color;
  536. }
  537. if (color.match(/^gradient\((.*)\)$/i)) {
  538. var parts = RegExp.$1.split(':');
  539. // Create the gradient
  540. var grad = co.createRadialGradient(this.centerx, this.centery, 0, this.centerx, this.centery, this.radius);
  541. var diff = 1 / (parts.length - 1);
  542. grad.addColorStop(0, RG.trim(parts[0]));
  543. for (var j=1; j<parts.length; ++j) {
  544. grad.addColorStop(j * diff, RG.trim(parts[j]));
  545. }
  546. }
  547. return grad ? grad : color;
  548. }
  549. /**
  550. * Now need to register all chart types. MUST be after the setters/getters are defined
  551. *
  552. * *** MUST BE LAST IN THE CONSTRUCTOR ***
  553. */
  554. RG.Register(this);
  555. }