---
title: "新手问题—关于FLEX曲线上数据点显示"
author: "dong_java"
date: "2010-10-29T11:41:46Z"
tags: []
categories: ["Web前端"]
slug: "flex"
draft: false
lastmod: "2010-10-29T11:41:46Z"
id: 797447
url: "https://dong-java.iteye.com/blog/797447"
---

废话少说上代码！主要是红色部分，让数据点一直显示。

 

&lt;?xml version="1.0" encoding="utf-8"?&gt;  
&lt;mx:Application xmlns:mx="[http://www.adobe.com/2006/mxml](http://www.adobe.com/2006/mxml)" layout="absolute"&gt;  
    &lt;mx:Script&gt;&lt;![CDATA[  
        import mx.collections.ArrayCollection;  
        import mx.charts.events.ChartEvent;  
        import mx.controls.Alert;  
        \[Bindable]  
        public var clickData:ArrayCollection = new ArrayCollection([  
            {Date:"2月2日", Profit:33456567, Duration:23423234},  
            {Date:"2月3日", Profit:50892344, Duration:12313453},  
            {Date:"2月4日", Profit:23034586, Duration:56232343},  
            {Date:"2月5日", Profit:12439623, Duration:78345451},  
            {Date:"2月6日", Profit:40285234, Duration:1235123},  
            {Date:"2月7日", Profit:60345642, Duration:23544536}  
        ]);  
        public function showAllTips():void {  
            linechart1.showAllDataTips = !linechart1.showAllDataTips;  
        };  
        public function chartEventHandler(event:ChartEvent):void{  
            myValue.text = \[event.currentTarget,event.localX.toString(),event.localY.toString()].join("/");  
        };  
        public function lineEventHandler(event:MouseEvent):void{  
            var ls:LineSeries=event.target as LineSeries;  
                  }  
         
    ]]&gt;&lt;/mx:Script&gt;  
     
    &lt;mx:Style&gt;  
    .axisTitles {  
       color:red;  
       fontWeight:bold;  
       fontFamily:宋体;  
       fontSize:14;  
    }  
    LineChart {  
       axisTitleStyleName:axisTitles;  
    }  
    &lt;/mx:Style&gt;  
     
     
    &lt;mx:Panel layout="absolute" title="统计图表" top="10" left="10" right="10" bottom="40"&gt;  
        &lt;mx:LineChart id="linechart1" top="0" left="0" right="0" bottom="0" dataProvider="{clickData}" showDataTips="true" themeColor="#E314D7" itemSelectionColor="#FF0000" itemRollOverColor="#0600FF" fontFamily="宋体" fontAntiAliasType="advanced" chartClick="chartEventHandler(event)"&gt;  
            &lt;mx:horizontalAxis&gt;  
                &lt;mx:CategoryAxis categoryField="Date" title="时间"/&gt;  
            &lt;/mx:horizontalAxis&gt;  
            &lt;mx:series&gt;  
                &lt;mx:LineSeries displayName="点击率" itemRenderer="mx.charts.renderers.CircleItemRenderer"  yField="Profit" form="curve"  click="lineEventHandler(event)"/&gt;  
            &lt;/mx:series&gt;  
        &lt;/mx:LineChart&gt;  
        &lt;mx:Legend dataProvider="{linechart1}" right="10" top="10"/&gt;  
    &lt;/mx:Panel&gt;  
    &lt;mx:Button label="切换所有采集点提示" width="139" click="{showAllTips()}" bottom="10" left="10"/&gt;  
    &lt;mx:TextInput id="myValue" bottom="10" left="157" width="334"/&gt;  
     
&lt;/mx:Application&gt;