Flex中如何创建放射线状填充列图(ColumnChart)图表的例子

下面是完整代码(或点击这里察看):

Download: main.mxml
  1. <?xml version="1.0"?>
  2. <mx:Applicationxmlns:mx="http://www.adobe.com/2006/mxml"
  3. layout="vertical"
  4. verticalAlign="middle"
  5. backgroundColor="white">
  6. <mx:Script>
  7. <![CDATA[
  8. import mx.charts.events.ChartItemEvent;
  9. import mx.charts.chartClasses.IAxis;
  10. import mx.charts.series.items.ColumnSeriesItem;
  11. import mx.core.UIComponent;
  12. private function linearAxis_labelFunc(item:Object, prevValue:Object, axis:IAxis):String {
  13. return currencyFormatter.format(item);
  14. }
  15. private function categoryAxis_labelFunc(item:Object, prevValue:Object, axis:CategoryAxis, categoryItem:Object):String {
  16. var datNum:Number = Date.parse(item);
  17. var tempDate:Date = new Date(datNum);
  18. return dateFormatter.format(tempDate).toUpperCase();
  19. }
  20. ]]>
  21. </mx:Script>
  22. <mx:DateFormatterid="dateFormatter" formatString="DD" />
  23. <mx:CurrencyFormatterid="currencyFormatter" precision="2" />
  24. <mx:XMLListCollectionid="dp">
  25. <mx:source>
  26. <mx:XMLList>
  27. <quotedate="8/1/2007" open="40.29" close="39.58" />
  28. <quotedate="8/2/2007" open="39.4" close="39.52" />
  29. <quotedate="8/3/2007" open="39.47" close="38.75" />
  30. <quotedate="8/6/2007" open="38.71" close="39.38" />
  31. <quotedate="8/7/2007" open="39.08" close="39.42" />
  32. <quotedate="8/8/2007" open="39.61" close="40.23" />
  33. <quotedate="8/9/2007" open="39.9" close="40.75" />
  34. <quotedate="8/10/2007" open="41.3" close="41.06" />
  35. <quotedate="8/13/2007" open="41" close="40.83" />
  36. <quotedate="8/14/2007" open="41.01" close="40.41" />
  37. <quotedate="8/15/2007" open="40.22" close="40.18" />
  38. <quotedate="8/16/2007" open="39.83" close="39.96" />
  39. <quotedate="8/17/2007" open="40.18" close="40.32" />
  40. <quotedate="8/20/2007" open="40.55" close="40.74" />
  41. <quotedate="8/21/2007" open="40.41" close="40.13" />
  42. <quotedate="8/22/2007" open="40.4" close="40.77" />
  43. <quotedate="8/23/2007" open="40.82" close="40.6" />
  44. <quotedate="8/24/2007" open="40.5" close="40.41" />
  45. <quotedate="8/27/2007" open="40.38" close="40.81" />
  46. </mx:XMLList>
  47. </mx:source>
  48. </mx:XMLListCollection>
  49. <mx:ColumnChartid="columnChart"
  50. showDataTips="true"
  51. dataProvider="{dp}"
  52. width="100%"
  53. height="100%">
  54. <mx:backgroundElements>
  55. <mx:GridLines>
  56. <mx:horizontalStroke>
  57. <mx:Strokecolor="haloSilver" weight="0" />
  58. </mx:horizontalStroke>
  59. </mx:GridLines>
  60. </mx:backgroundElements>
  61. <!-- vertical axis -->
  62. <mx:verticalAxis>
  63. <mx:LinearAxisbaseAtZero="false"
  64. labelFunction="linearAxis_labelFunc"/>
  65. </mx:verticalAxis>
  66. <!-- horizontal axis -->
  67. <mx:horizontalAxis>
  68. <mx:CategoryAxisid="ca"
  69. categoryField="@date"
  70. title="August 2007"
  71. labelFunction="categoryAxis_labelFunc"/>
  72. </mx:horizontalAxis>
  73. <!-- horizontal axis renderer -->
  74. <mx:horizontalAxisRenderers>
  75. <mx:AxisRendereraxis="{ca}"
  76. canDropLabels="true"/>
  77. </mx:horizontalAxisRenderers>
  78. <!-- series -->
  79. <mx:series>
  80. <mx:ColumnSeriesdisplayName="Open"
  81. xField="@date"
  82. yField="@open">
  83. <mx:fill>
  84. <mx:RadialGradient>
  85. <mx:entries>
  86. <mx:Array>
  87. <mx:GradientEntrycolor="white"
  88. ratio="0.0"
  89. alpha="1.0"/>
  90. <mx:GradientEntrycolor="haloBlue"
  91. ratio="1.0"
  92. alpha="1.0"/>
  93. </mx:Array>
  94. </mx:entries>
  95. </mx:RadialGradient>
  96. </mx:fill>
  97. </mx:ColumnSeries>
  98. </mx:series>
  99. <!-- series filters -->
  100. <mx:seriesFilters>
  101. <mx:Array/>
  102. </mx:seriesFilters>
  103. </mx:ColumnChart>
  104. </mx:Application>

本文转自:http://blog.minidx.com/2008/12/16/1741.html

你可能感兴趣的:(xml,Flex,Blog,Adobe)