Flex中如何通过lineStroke样式改变LineChart图表线条颜色的例子

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

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.styles.StyleManager;
  9. ]]>
  10. </mx:Script>
  11. <mx:XMLListCollectionid="dp">
  12. <mx:source>
  13. <mx:XMLList>
  14. <quotedate="8/27/2007" open="40.38" close="40.81" />
  15. <quotedate="8/24/2007" open="40.5" close="40.41" />
  16. <quotedate="8/23/2007" open="40.82" close="40.6" />
  17. <quotedate="8/22/2007" open="40.4" close="40.77" />
  18. <quotedate="8/21/2007" open="40.41" close="40.13" />
  19. <quotedate="8/20/2007" open="40.55" close="40.74" />
  20. <quotedate="8/17/2007" open="40.18" close="40.32" />
  21. <quotedate="8/16/2007" open="39.83" close="39.96" />
  22. <quotedate="8/15/2007" open="40.22" close="40.18" />
  23. <quotedate="8/14/2007" open="41.01" close="40.41" />
  24. <quotedate="8/13/2007" open="41" close="40.83" />
  25. <quotedate="8/10/2007" open="41.3" close="41.06" />
  26. <quotedate="8/9/2007" open="39.9" close="40.75" />
  27. <quotedate="8/8/2007" open="39.61" close="40.23" />
  28. <quotedate="8/7/2007" open="39.08" close="39.42" />
  29. <quotedate="8/6/2007" open="38.71" close="39.38" />
  30. <quotedate="8/3/2007" open="39.47" close="38.75" />
  31. <quotedate="8/2/2007" open="39.4" close="39.52" />
  32. <quotedate="8/1/2007" open="40.29" close="39.58" />
  33. </mx:XMLList>
  34. </mx:source>
  35. </mx:XMLListCollection>
  36. <mx:ApplicationControlBardock="true">
  37. <mx:Buttonlabel="0xFF0000" click="closeSeries.setStyle('lineStroke', new Stroke(0xFF0000, 2, 0.4));" />
  38. <mx:Buttonlabel="0xFF00FF" click="closeSeries.setStyle('lineStroke', new Stroke(0xFF00FF, 2, 1.0));" />
  39. <mx:Buttonlabel="haloSilver" click="closeSeries.setStyle('lineStroke', new Stroke(StyleManager.getColorName('haloSilver'), 2, 1.0));" />
  40. <mx:Spacerwidth="100%" />
  41. <mx:LegenddataProvider="{lineChart}" />
  42. </mx:ApplicationControlBar>
  43. <mx:LineChartid="lineChart"
  44. showDataTips="true"
  45. dataProvider="{dp}"
  46. width="100%"
  47. height="100%">
  48. <!-- series filters -->
  49. <mx:seriesFilters>
  50. <mx:Array/>
  51. </mx:seriesFilters>
  52. <!-- vertical axis -->
  53. <mx:verticalAxis>
  54. <mx:LinearAxisbaseAtZero="false" title="Price" />
  55. </mx:verticalAxis>
  56. <!-- horizontal axis -->
  57. <mx:horizontalAxis>
  58. <mx:CategoryAxisid="ca" categoryField="@date" title="Date" />
  59. </mx:horizontalAxis>
  60. <!-- horizontal axis renderer -->
  61. <mx:horizontalAxisRenderers>
  62. <mx:AxisRendereraxis="{ca}" canDropLabels="true" />
  63. </mx:horizontalAxisRenderers>
  64. <!-- series -->
  65. <mx:series>
  66. <mx:LineSeriesid="closeSeries" yField="@close" form="curve" displayName="Close">
  67. <mx:lineStroke>
  68. <mx:Strokecolor="haloGreen" weight="2" alpha="0.6" />
  69. </mx:lineStroke>
  70. </mx:LineSeries>
  71. <mx:LineSeriesyField="@open" form="curve" displayName="Open">
  72. <mx:lineStroke>
  73. <mx:Strokecolor="haloOrange" weight="2" alpha="0.6" />
  74. </mx:lineStroke>
  75. </mx:LineSeries>
  76. </mx:series>
  77. </mx:LineChart>
  78. </mx:Application>

本文转自:http://blog.minidx.com/2008/11/23/1644.html

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