PageRenderTime 93ms CodeModel.GetById 30ms RepoModel.GetById 6ms app.codeStats 0ms

/flex/src/boost/charts/RadarChart.as

http://gevu.googlecode.com/
ActionScript | 816 lines | 450 code | 121 blank | 245 comment | 57 complexity | a5ce7a6b857b2bbee444598110362013 MD5 | raw file
Possible License(s): MPL-2.0-no-copyleft-exception
  1. package boost.charts {
  2. import boost.common.ArrayExtension;
  3. import boost.common.ui.Util;
  4. import flash.display.Graphics;
  5. import flash.display.Sprite;
  6. import flash.events.MouseEvent;
  7. import flash.geom.Point;
  8. import mx.controls.Label;
  9. import mx.core.UIComponent;
  10. [Style(name="centerRadius",type="Number",format="Length",inherit="yes")]
  11. [Style(name="axisColor",type="uint",format="Color",inherit="yes")]
  12. [Style(name="axisThickness",type="Number",format="Length",inherit="yes")]
  13. [Style(name="axisAlpha",type="Number",inherit="yes")]
  14. [Style(name="tickColor",type="uint",format="Color",inherit="yes")]
  15. [Style(name="tickThickness",type="Number",format="Length",inherit="yes")]
  16. [Style(name="tickAlpha",type="Number",inherit="yes")]
  17. // [Style(name="tickLength",type="Number",format="Length",inherit="yes")]
  18. [Style(name="showTicks",type="Boolean",inherit="yes")]
  19. [Style(name="showTitles",type="Boolean",inherit="yes")]
  20. // [Style(name="showLabels",type="Boolean",inherit="yes")]
  21. [Style(name="seriesLineThickness",type="Number",format="Length",inherit="yes")]
  22. [Style(name="seriesLineAlpha",type="Number",inherit="yes")]
  23. [Style(name="seriesFillAlpha",type="Number",inherit="yes")]
  24. [Style(name="seriesPointSize",type="Number",format="Length",inherit="yes")]
  25. [Style(name="seriesPointAlpha",type="Number",inherit="yes")]
  26. [Style(name="colors",type="Array",format="Color",inherit="yes")]
  27. [Style(name="rotateText",type="Boolean",inherit="no")]
  28. [Event(name="series_roll_out", type="common.charts.RadarChartSeriesEvent")]
  29. [Event(name="series_roll_over", type="common.charts.RadarChartSeriesEvent")]
  30. [Event(name="series_roll_click", type="common.charts.RadarChartSeriesEvent")]
  31. /**
  32. * A radar (spider) chart implementation. This type of chart has multiple
  33. * axes arranged in a circle around the center point. Each series has a point
  34. * on each axes, connected with lines.
  35. *
  36. * @example Example use: <listing>
  37. * var chart:RadarChart = new RadarChart();
  38. * addChild(chart);
  39. *
  40. * chart.addAxis('bread');
  41. * chart.addAxis('cheese');
  42. * chart.addAxis('wine');
  43. * chart.addAxis('fish');
  44. * chart.addAxis('meat');
  45. *
  46. * chart.addSeries('Male', {bread: 3, cheese: 4, wine: 5, fish: 1, meat: 4});
  47. * chart.addSeries('Female', {bread: 4, cheese: 2, wine: 4, fish: 5, meat: 3});
  48. * </listing>
  49. *
  50. * @author jeremy
  51. * Severity and Description Path Resource Location Creation Time Id
  52. */
  53. public class RadarChart extends UIComponent
  54. {
  55. /**
  56. * Array of RadarAxis objects on this chart
  57. */
  58. private var _axes:Array;
  59. /**
  60. * Array of RadarSeries objects on this chart
  61. */
  62. private var _series:Array;
  63. /**
  64. * Center point of the chart
  65. */
  66. private var _center:Point;
  67. /**
  68. * Calculated radius of the axis lines
  69. */
  70. private var _radius:Number;
  71. /**
  72. * Calculated gap required for axis labels
  73. */
  74. private var _labelGap:Number;
  75. /**
  76. * Boolean indicating commitProperties has been called
  77. */
  78. private var propertiesCommitted:Boolean = false;
  79. /**
  80. * Boolean used to block series events from being dispatched while
  81. * series are being drawn
  82. */
  83. private var eventBlock:Boolean = false;
  84. // Define a static variable.
  85. private static var classConstructed:Boolean = classConstruct();
  86. // Define a static method.
  87. private static function classConstruct():Boolean {
  88. Util.generateDefaultCSS("RadarChart", function():void {
  89. this.centerRadius = 5;
  90. this.axisColor = 0;
  91. this.axisThickness = 1;
  92. this.axisAlpha = 1;
  93. this.tickColor = 0;
  94. this.tickThickness = 1;
  95. this.tickAlpha = 1;
  96. this.tickLength = 5;
  97. this.showTicks = true;
  98. this.showTitles = true;
  99. this.showLabels = true;
  100. this.seriesPointSize = 5;
  101. this.seriesPointAlpha = 1;
  102. this.seriesLineThickness = 2;
  103. this.seriesLineAlpha = 0.5;
  104. this.seriesFillAlpha = 0.1;
  105. this.seriesHighlightPointSize = 5;
  106. this.seriesHighlightPointAlpha = 1;
  107. this.seriesHighlightLineThickness = 2;
  108. this.seriesHighlightLineAlpha = 0.8;
  109. this.seriesHighlightFillAlpha = 0.5;
  110. this.seriesHighlightOtherPointSize = 5;
  111. this.seriesHighlightOtherPointAlpha = 0.5;
  112. this.seriesHighlightOtherFillAlpha = 0.1;
  113. this.seriesHighlightOtherLineAlpha = 0.2;
  114. this.seriesHighlightOtherLineThickness = 2;
  115. this.colors = [0x257BB6, 0xB7247C, 0xCCC012, 0x41C04F, 0x296997, 0x26B69B, 0xCF5F0B, 0xA041C1];
  116. this.rotateText = false;
  117. this.paddingLeft = 10;
  118. this.paddingRight = 10;
  119. this.paddingTop = 10;
  120. this.paddingBottom = 10;
  121. this.paddingMiddle = 20;
  122. this.backgroundColor = 0xECECEC;
  123. this.borderColor = 0x9d9d9d;
  124. this.borderThickness = 1;
  125. this.borderAlpha = 1;
  126. });
  127. return true;
  128. }
  129. function RadarChart() {
  130. super();
  131. // Initialize boost array extension
  132. ArrayExtension.extend();
  133. _axes = new Array();
  134. _series = new Array();
  135. }
  136. /**
  137. * Array of axes on this chart
  138. * @return
  139. *
  140. */
  141. private function get axes():Array {
  142. return _axes;
  143. }
  144. /**
  145. * Add an axis with a name and an optional label. The label will be set
  146. * to the name if not provided.
  147. *
  148. * @param name
  149. * @param label
  150. *
  151. */
  152. public function addAxis(name:String, label:String = null):void {
  153. _axes.push(new RadarAxis(this, name, label));
  154. invalidateAxes();
  155. }
  156. /**
  157. * Remove an axis by name.
  158. * @param name
  159. *
  160. */
  161. public function removeAxis(name:String):void {
  162. var axis:RadarAxis = _axes.find(function(o:RadarAxis):Boolean {
  163. return o.name == name;
  164. });
  165. if(axis.labels)
  166. for each(var oldLabel:Label in axis.labels)
  167. removeChild(oldLabel);
  168. if(axis.label)
  169. removeChild(axis.label);
  170. var index:int = _axes.indexOf(axis);
  171. _axes.splice(index, 1);
  172. invalidateAxes();
  173. }
  174. /**
  175. * Get a readonly array of series on the chart.
  176. * @return
  177. *
  178. */
  179. public function get series():Array {
  180. return _series.clone();
  181. }
  182. /**
  183. * Add a series. The name of the series should be unique. The data should
  184. * be an object with numerical values keyed to axes on this chart.
  185. *
  186. * @param name
  187. * @param data
  188. * @param color
  189. *
  190. */
  191. public function addSeries(name:String, data:Object, color:Object = null):void {
  192. var series:RadarSeries = new RadarSeries(name, data);
  193. if(color != null)
  194. series.color = uint(color);
  195. _series.push(series);
  196. invalidateAxes();
  197. }
  198. /**
  199. * Remove a series by name.
  200. * @param name
  201. *
  202. */
  203. public function removeSeries(name:String):void {
  204. for each(var serie:RadarSeries in _series) {
  205. if(serie.name == name && serie.sprite) removeChild(serie.sprite);
  206. }
  207. _series = _series.filter(function(o:RadarSeries, i:int, a:Array):Boolean {
  208. return o.name != name;
  209. });
  210. invalidateAxes();
  211. }
  212. /**
  213. * Invalidate everything required when changing an axis
  214. *
  215. */
  216. private function invalidateAxes():void {
  217. invalidateSize();
  218. invalidateProperties();
  219. invalidateDisplayList();
  220. }
  221. /**
  222. * Gather all series data for this axis. Returns an object in the form
  223. * { series_a: value, series_b: value, series_c: value }
  224. *
  225. * @param name
  226. * @return
  227. *
  228. */
  229. private function getAxisData(name:String):Object {
  230. var data:Object = {};
  231. for each(var serie:Object in series) {
  232. var value:Object = serie.data[name];
  233. data[serie.name] = Number(value);
  234. }
  235. return data;
  236. }
  237. /**
  238. * Convert an object (hash) into an array of the objects values. For
  239. * example, {a: 1, b: 2, c: 3} becomes [1, 2, 3].
  240. *
  241. * @param hash
  242. * @return
  243. *
  244. */
  245. private function hashToArray(hash:Object):Array {
  246. var arr:Array = [];
  247. for(var m:String in hash)
  248. arr.push(hash[m]);
  249. return arr;
  250. }
  251. /**
  252. * Get the maximum series value on an axis.
  253. * @param name
  254. * @return
  255. *
  256. */
  257. private function getAxisMax(name:String):Number {
  258. return hashToArray(getAxisData(name)).max();
  259. }
  260. /**
  261. * Get the minimum series value on an axis.
  262. * @param name
  263. * @return
  264. *
  265. */
  266. private function getAxisMin(name:String):Number {
  267. return hashToArray(getAxisData(name)).min();
  268. }
  269. /**
  270. * Collect any data required for each axis before drawing commences.
  271. *
  272. */
  273. private function updateAxes():void {
  274. var totalMax:Number = Math.ceil(axes.collect('name').map(function(name:String, i:int, a:Array):Number {
  275. return getAxisMax(name);
  276. }).max());
  277. for each(var axis:RadarAxis in axes) {
  278. updateAxis(axis, totalMax);
  279. }
  280. }
  281. /**
  282. * Create axis labels and update min and max data
  283. * @param axis
  284. * @param totalMax
  285. *
  286. */
  287. private function updateAxis(axis:RadarAxis, totalMax:Number):void {
  288. axis.max = totalMax; //Math.ceil(getAxisMax(axis.name));
  289. axis.min = Math.floor(getAxisMin(axis.name));
  290. if(axis.labels) {
  291. for each(var oldLabel:Label in axis.labels) {
  292. removeChild(oldLabel);
  293. }
  294. }
  295. axis.labels = new Array();
  296. //pas plus de x labels
  297. var x:int = 6
  298. if(axis.max<x){
  299. for(var i:Number = 1; i <= axis.max; i++) {
  300. var label:Label = new Label();
  301. label.data = i;
  302. label.text = i.toString();
  303. label.setStyle('textAlign', 'center');
  304. axis.labels.push(label);
  305. addChild(label);
  306. }
  307. }else{
  308. for(var j:Number = 1; j <= x; j++) {
  309. var lbl:Label = new Label();
  310. var nb:int = int(axis.max/x*j);
  311. lbl.data = nb
  312. lbl.text = nb.toString();
  313. lbl.setStyle('textAlign', 'center');
  314. axis.labels.push(lbl);
  315. addChild(lbl);
  316. }
  317. }
  318. if(axis.label)
  319. removeChild(axis.label);
  320. axis.label = new Label();
  321. axis.label.text = axis.text;
  322. axis.label.setStyle('textAlign', 'center');
  323. addChild(axis.label);
  324. axis.updated = true;
  325. }
  326. /**
  327. * @inheritDoc
  328. *
  329. */
  330. override protected function createChildren():void {
  331. super.createChildren();
  332. }
  333. /**
  334. * @inheritDoc
  335. *
  336. */
  337. override protected function commitProperties():void {
  338. super.commitProperties();
  339. updateAxes();
  340. propertiesCommitted = true;
  341. }
  342. /**
  343. * @inheritDoc
  344. *
  345. */
  346. override protected function measure():void {
  347. super.measure();
  348. }
  349. /**
  350. * @inheritDoc
  351. * @param unscaledWidth
  352. * @param unscaledHeight
  353. *
  354. */
  355. protected override function updateDisplayList(unscaledWidth:Number, unscaledHeight:Number):void {
  356. if(!propertiesCommitted) { invalidateProperties(); return; }
  357. var g:Graphics = graphics;
  358. g.clear();
  359. g.beginFill(getStyle('backgroundColor'), getStyle('backgroundAlpha'));
  360. g.lineStyle(
  361. getStyle('borderThickness'),
  362. getStyle('borderColor'),
  363. getStyle('borderAlpha')
  364. );
  365. g.drawRect(0, 0, unscaledWidth-getStyle('borderThickness'), unscaledHeight-getStyle('borderThickness'));
  366. g.endFill();
  367. _center = new Point(unscaledWidth/2, unscaledHeight/2);
  368. _radius = (Math.min(unscaledWidth, unscaledHeight)/2) - axes.collect('labels').flatten().compact().max('getExplicitOrMeasuredHeight');
  369. if(getStyle('showTitles'))
  370. _labelGap = axes.collect('label').max('textHeight');
  371. else
  372. _labelGap = 0;
  373. g.lineStyle(getStyle('axisThickness'), getStyle('axisColor'), getStyle('axisAlpha'));
  374. if(getStyle('centerRadius') > 0)
  375. g.drawCircle(_center.x, _center.y, getStyle('centerRadius'));
  376. drawAxes();
  377. drawSeries();
  378. }
  379. /**
  380. * Setup an axis for drawing by calculating its start and end points
  381. * @param axis
  382. * @param angle
  383. *
  384. */
  385. private function setupAxisForDrawing(axis:RadarAxis, angle:Number):void {
  386. axis.angle = angle;
  387. axis.start = new Point(
  388. _center.x + Math.cos(angle) * getStyle('centerRadius'),
  389. _center.y + Math.sin(angle) * getStyle('centerRadius')
  390. );
  391. axis.end = new Point(
  392. _center.x + Math.cos(angle) * (_radius - _labelGap),
  393. _center.y + Math.sin(angle) * (_radius - _labelGap)
  394. );
  395. axis.length = _radius - (getStyle('centerRadius') + _labelGap);
  396. }
  397. /**
  398. * Position the axis' label
  399. * @param axis
  400. *
  401. */
  402. private function positionAxisLabel(axis:RadarAxis):void {
  403. axis.label.visible = getStyle('showTitles');
  404. if(axis.label.visible) {
  405. axis.label.rotation = 0;
  406. Util.actualize(axis.label, true);
  407. if(getStyle('rotateText')) {
  408. var opposite:Number = axis.label.width/2;
  409. var adjacent:Number = _radius + _labelGap;
  410. var hypoenuse:Number = Math.sqrt(Math.pow(opposite,2) + Math.pow(adjacent, 2));
  411. var angle:Number = Math.atan(opposite / adjacent);
  412. axis.label.move(
  413. _center.x + Math.cos(axis.angle - angle) * hypoenuse,
  414. _center.y + Math.sin(axis.angle - angle) * hypoenuse
  415. );
  416. axis.label.rotation = axis.angle * 180/Math.PI + 90;
  417. var ta:Number = axis.label.rotation;
  418. if(ta < 0) ta += 360;
  419. if(ta > 135 && ta < 270) {
  420. axis.label.rotation += 180;
  421. axis.label.move(
  422. _center.x + Math.cos(axis.angle + angle) * (hypoenuse - axis.label.height),
  423. _center.y + Math.sin(axis.angle + angle) * (hypoenuse - axis.label.height)
  424. );
  425. }
  426. } else {
  427. axis.label.move(
  428. _center.x + Math.cos(axis.angle) * (_radius + _labelGap - axis.label.height),
  429. _center.y + Math.sin(axis.angle) * (_radius + _labelGap - axis.label.height)
  430. );
  431. if(axis.angle > Math.PI/2 && axis.angle < 1.5*Math.PI)
  432. axis.label.x -= axis.label.width;
  433. axis.label.y -= axis.label.height/2;
  434. }
  435. }
  436. }
  437. /**
  438. * Position the axis' scale labels
  439. * @param axis
  440. * @param label
  441. *
  442. */
  443. private function positionAxisLabels(axis:RadarAxis, label:Label):void {
  444. label.visible = getStyle('showLabels');
  445. // Calculate percent down the axis
  446. var percent:Number = Number(label.data) / axis.max;
  447. // Calculate position down the axis
  448. var radius:Number = (axis.length * percent) + getStyle('centerRadius');
  449. if(label.visible) {
  450. // Size the label
  451. Util.actualize(label, true);
  452. // Calculate an offset angle taking into account the labels width
  453. // so that it appears under the line instead of on it
  454. var opposite:Number = label.textWidth + getStyle('centerRadius');
  455. var adjacent:Number = radius;
  456. var hypotenuse:Number = Math.sqrt(Math.pow(opposite, 2) + Math.pow(adjacent, 2));
  457. var angle:Number = Math.atan(opposite / adjacent);
  458. var point:Point = new Point(
  459. _center.x + Math.cos(axis.angle + angle) * hypotenuse,
  460. _center.y + Math.sin(axis.angle + angle) * hypotenuse
  461. );
  462. point.x -= (label.width/2);
  463. point.y -= (label.height/2);
  464. label.move(point.x, point.y);
  465. }
  466. // Draw the tick
  467. drawTick(axis, radius);
  468. }
  469. /**
  470. * Draw a tick mark on an axis
  471. * @param axis
  472. * @param position
  473. *
  474. */
  475. private function drawTick(axis:RadarAxis, position:Number):void {
  476. var length:Number = getStyle('tickLength');
  477. var opposite:Number = length /2 ;
  478. var adjacent:Number = position;
  479. var hypotenuse:Number = Math.sqrt(Math.pow(opposite, 2) + Math.pow(adjacent, 2));
  480. var angle:Number = Math.atan(opposite / adjacent);
  481. graphics.lineStyle(
  482. getStyle('tickThickness'),
  483. getStyle('tickColor'),
  484. getStyle('tickAlpha')
  485. );
  486. graphics.moveTo(
  487. _center.x + Math.cos(axis.angle - angle) * hypotenuse,
  488. _center.y + Math.sin(axis.angle - angle) * hypotenuse
  489. );
  490. graphics.lineTo(
  491. _center.x + Math.cos(axis.angle + angle) * hypotenuse,
  492. _center.y + Math.sin(axis.angle + angle) * hypotenuse
  493. );
  494. }
  495. /**
  496. * Draw an axis
  497. * @param axis
  498. *
  499. */
  500. private function drawAxis(axis:RadarAxis):void {
  501. var g:Graphics = graphics;
  502. g.lineStyle(
  503. getStyle('axisThickness'),
  504. getStyle('axisColor'),
  505. getStyle('axisAlpha')
  506. );
  507. g.moveTo(axis.start.x, axis.start.y);
  508. g.lineTo(axis.end.x, axis.end.y);
  509. positionAxisLabel(axis);
  510. for each(var label:Label in axis.labels) {
  511. positionAxisLabels(axis, label);
  512. }
  513. }
  514. /**
  515. * Draw all the axes
  516. *
  517. */
  518. private function drawAxes():void {
  519. var axisAngle:Number = (2*Math.PI) / axes.length;
  520. var angle:Number = 0;
  521. for each(var axis:RadarAxis in axes) {
  522. if(!axis.updated) updateAxes();
  523. setupAxisForDrawing(axis, angle);
  524. drawAxis(axis);
  525. angle += axisAngle;
  526. }
  527. }
  528. /**
  529. * Work out the point on each axes for a series
  530. *
  531. */
  532. private function calculateSeriesPoints():void {
  533. for each(var serie:RadarSeries in series) {
  534. serie.points = new Array();
  535. for each(var axis:RadarAxis in axes) {
  536. var x:Number = serie.data[axis.name];
  537. var sar:Number = ((serie.data[axis.name] / axis.max) * axis.length) + getStyle('centerRadius');
  538. var point:Point = new Point(
  539. _center.x + Math.cos(axis.angle) * sar,
  540. _center.y + Math.sin(axis.angle) * sar
  541. );
  542. serie.points.push(point);
  543. }
  544. var area:Number = 0;
  545. var xDiff:Number = 0;
  546. var yDiff:Number = 0;
  547. for(var k:int = 0; k < serie.points.length-1; k++ ) {
  548. xDiff = serie.points[k+1].x - serie.points[k].x;
  549. yDiff = serie.points[k+1].y - serie.points[k].y;
  550. area += serie.points[k].x * yDiff - serie.points[k].y * xDiff;
  551. }
  552. serie.area = 0.5 * area;
  553. }
  554. }
  555. /**
  556. * Draw a series. The highlight can be "on", "off" or "other"
  557. * @param serie
  558. * @param highlight
  559. *
  560. */
  561. private function drawSerie(serie:RadarSeries, highlight:String = "off"):void {
  562. eventBlock = true;
  563. if(!serie.hasColor) {
  564. var colors:Array = getStyle('colors');
  565. serie.color = colors[series.indexOf(serie) % colors.length];
  566. }
  567. var style:String = highlight == 'on' ? 'Highlight' : highlight == 'other' ? 'HighlightOther' : '';
  568. // Create the series sprite if required
  569. if(!serie.sprite) {
  570. serie.sprite = new Sprite();
  571. serie.sprite.addEventListener(MouseEvent.MOUSE_OVER, mouseOverSeriesHandler);
  572. serie.sprite.addEventListener(MouseEvent.MOUSE_OUT, mouseOutSeriesHandler);
  573. serie.sprite.addEventListener(MouseEvent.CLICK, mouseClickSeriesHandler);
  574. }
  575. addChild(serie.sprite);
  576. var g:Graphics = serie.sprite.graphics;
  577. var point:Point;
  578. // Clear the series sprite
  579. g.clear();
  580. // Draw the circle points on the series
  581. for each(point in serie.points) {
  582. g.beginFill(serie.color, getStyle('series' + style + 'PointAlpha'));
  583. g.lineStyle(0, 0, 0);
  584. g.drawCircle(point.x, point.y, getStyle('series' + style + 'PointSize'));
  585. g.endFill();
  586. }
  587. // Draw the series line if there are any points to draw
  588. if(serie.points.length > 0) {
  589. g.lineStyle(getStyle('series' + style + 'LineThickness'), serie.color, getStyle('series' + style + 'LineAlpha'));
  590. g.moveTo(serie.points[0].x, serie.points[0].y);
  591. g.beginFill(serie.color, getStyle('series' + style + 'FillAlpha'));
  592. for each(point in serie.points) {
  593. g.lineTo(point.x, point.y);
  594. }
  595. }
  596. g.endFill();
  597. eventBlock = false;
  598. }
  599. /**
  600. * Draw all the series
  601. *
  602. */
  603. private function drawSeries():void {
  604. calculateSeriesPoints();
  605. var sortedSeries:Array = getSortedSeries();
  606. for each(var serie:RadarSeries in sortedSeries) {
  607. drawSerie(serie);
  608. }
  609. }
  610. /**
  611. * Return the array of series sorted by total area
  612. * @return
  613. *
  614. */
  615. private function getSortedSeries():Array {
  616. return series.clone().sort(function(a:RadarSeries, b:RadarSeries):int {
  617. if(a.area > b.area) return -1;
  618. if(a.area == b.area) return 0;
  619. if(a.area < b.area) return 1;
  620. return 0;
  621. });
  622. }
  623. /**
  624. * Using the sprite that a series is drawn on, find the series
  625. * @param sprite
  626. * @return
  627. *
  628. */
  629. private function getSeriesFromSprite(sprite:Sprite):RadarSeries {
  630. return (series.filter(function(s:RadarSeries, i:int, a:Array):Boolean {
  631. return s.sprite == sprite;
  632. }))[0];
  633. }
  634. /**
  635. * Redraw the series with highlight on.
  636. * @param serie
  637. * @param highlightOn
  638. *
  639. */
  640. private function highlightSeries(serie:RadarSeries, highlightOn:Boolean):void {
  641. var sortedSeries:Array = getSortedSeries();
  642. for each(var otherSerie:RadarSeries in sortedSeries) {
  643. if(otherSerie != serie)
  644. drawSerie(otherSerie, (highlightOn ? 'other' : 'off'));
  645. else
  646. drawSerie(serie, (highlightOn ? 'on' : 'off'));
  647. }
  648. // drawSerie(serie, (highlightOn ? 'on' : 'off'));
  649. }
  650. /**
  651. * Handle mouse over events for series. Highlights the serives and
  652. * dispatch a series roll over event.
  653. * @param e
  654. *
  655. */
  656. private function mouseOverSeriesHandler(e:MouseEvent):void {
  657. if(eventBlock) return;
  658. var serie:RadarSeries = getSeriesFromSprite(Sprite(e.target));
  659. highlightSeries(serie, true);
  660. dispatchEvent(new RadarChartSeriesEvent(RadarChartSeriesEvent.SERIES_ROLL_OVER, serie));
  661. }
  662. /**
  663. * Handle mouse out events for series. Removes the highlight and
  664. * dispatches a series roll out event.
  665. *
  666. * @param e
  667. *
  668. */
  669. private function mouseOutSeriesHandler(e:MouseEvent):void {
  670. if(eventBlock) return;
  671. var serie:RadarSeries = getSeriesFromSprite(Sprite(e.target));
  672. highlightSeries(serie, false);
  673. dispatchEvent(new RadarChartSeriesEvent(RadarChartSeriesEvent.SERIES_ROLL_OUT, serie));
  674. }
  675. /**
  676. * Handle mouse click events for series. Dispatches a series click event.
  677. * @param e
  678. *
  679. */
  680. private function mouseClickSeriesHandler(e:MouseEvent):void {
  681. if(eventBlock) return;
  682. var serie:RadarSeries = getSeriesFromSprite(Sprite(e.target));
  683. dispatchEvent(new RadarChartSeriesEvent(RadarChartSeriesEvent.SERIES_CLICK, serie));
  684. }
  685. /**
  686. * @inheritDoc
  687. * @param styleProp
  688. *
  689. */
  690. public override function styleChanged(styleProp:String):void {
  691. super.styleChanged(styleProp);
  692. }
  693. }
  694. }