• flex 改变linechart datatips 显示样式代码


    这是flex文件mxml的一个sample,是关于linechart这个控件的

    以及弹出datatip中字体大小的控制,但仅限于字体,其他样式颜色并不能改变

    <?xml version="1.0" encoding="utf-8"?>

    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
            layout="vertical"
            verticalAlign="middle"
            backgroundColor="white" >
    <mx:Style source="css/default.css" />
       <mx:Script>
            <![CDATA[
                import mx.styles.StyleManager;       
                import legendfont;           
                import mx.charts.HitData; 
                import mx.charts.series.items.LineSeriesItem;
                
                 private function pieChart_dataTipFunction(item:HitData):String { 
                    var LCI:LineSeriesItem = item.chartItem as LineSeriesItem; 
                    return "<font size='19'><b><i>"+ LCI.yValue+ "</i></b><br />" + 
                           
    LCI.item.@date+ "</b><br/></font>"; 
                }

              //改变datatip字体大小
            ]]>
        </mx:Script>
        <mx:XMLListCollection id="dp">
            <mx:source>
                <mx:XMLList>
                    <quote date="8/7/2007" open="20" close="21" zz="22.3" dd="22.3" />
                    <quote date="8/6/2007" open="25" close="23" zz="24.5" dd="24.3" />
                    <quote date="8/5/2007" open="18" close="25" zz="23.2" dd="26.3" />
                    <quote date="8/4/2007" open="24" close="24.5" zz="19" dd="27.3" />
                    <quote date="8/3/2007" open="26" close="22.8" zz="14.5" dd="28.3" />
                    <quote date="8/1/2007" open="19" close="19.5" zz="18" dd="21.3" />
                </mx:XMLList>
            </mx:source>
        </mx:XMLListCollection>
        <mx:Panel
        borderStyle="solid"
             borderColor="#cbdce4"      
             borderThickness="1" 
             width="60%" 
             height="60%"
             cornerRadius="0"
        >
             <mx:LineChart id="lineChart1"
                     showDataTips="true"
                     dataProvider="{dp}" 
                     width="100%"
                     height="90%"           
                        x="0" y="0" dataTipFunction="pieChart_dataTipFunction" useHandCursor="true">           
                 
                 <!-- series filters -->
                 <mx:seriesFilters>
                     <mx:Array />
                 </mx:seriesFilters>
                 
                 <!-- vertical axis -->
                 <mx:verticalAxis>
                     <mx:LinearAxis baseAtZero="false" title="Price" />
                 </mx:verticalAxis>
                 
                 <!-- horizontal axis -->
                 <mx:horizontalAxis>
                     <mx:CategoryAxis id="ca" categoryField="@date" title="Date" />
                 </mx:horizontalAxis>
                 
                 <!-- horizontal axis renderer -->
                 <mx:horizontalAxisRenderers>
                     <mx:AxisRenderer axis="{ca}" canDropLabels="true" />
                 </mx:horizontalAxisRenderers>
                 
                 <!-- series -->
                 <mx:series>
                     <mx:LineSeries id="closeSeries" yField="@close" displayName="11111" >
                         <mx:lineStroke>
                             <mx:Stroke color="#fb8201" weight="2" alpha="1" caps="round" />
                         </mx:lineStroke>
                     </mx:LineSeries>
                     <mx:LineSeries yField="@open" displayName="22222" >
                         <mx:lineStroke>
                             <mx:Stroke color="#47fe04" weight="2" alpha="1" />
                         </mx:lineStroke>
                     </mx:LineSeries>
                     
                     <mx:LineSeries yField="@zz" displayName="33333">
                         <mx:lineStroke>
                             <mx:Stroke color="#3080ff" weight="2" alpha="1" />
                         </mx:lineStroke>
                     </mx:LineSeries> 
                     
                      <mx:LineSeries yField="@dd" displayName="44444">
                         <mx:lineStroke>
                             <mx:Stroke color="#caca9e" weight="2" alpha="1" />
                         </mx:lineStroke>
                     </mx:LineSeries> 
                     
                   
                                   
                 </mx:series>

                    //关于linechart中线条的颜色样式
               
             </mx:LineChart>
        <mx:Legend dataProvider="{lineChart1}" direction="horizontal" height="28" legendItemClass="legendfont" />
        </mx:Panel>

        <mx:ApplicationControlBar dock="true">
            <mx:Button label="0xFF0000" click="closeSeries.setStyle(&apos;lineStroke&apos;, new Stroke(0xFF0000, 2, 0.4));" />
            <mx:Button label="0xFF00FF" click="closeSeries.setStyle(&apos;lineStroke&apos;, new Stroke(0xFF00FF, 2, 1.0));" />
            <mx:Button label="haloSilver" click="closeSeries.setStyle(&apos;lineStroke&apos;, new Stroke(StyleManager.getColorName(&apos;haloSilver&apos;), 2, 1.0));" />

            <mx:Spacer width="100%" />
        </mx:ApplicationControlBar>
        
         
        
    </mx:Application>

    来自: http://hi.baidu.com/%B2%D0%C7%EF%BF%D5%CA%C5/blog/item/786a5ad72a90c32606088bb8.html

  • 相关阅读:
    【NOIP】提高组2015 运输计划
    【BZOJ】1635: [Usaco2007 Jan]Tallest Cow 最高的牛
    【51nod】1766 树上的最远点对
    【BZOJ】2054: 疯狂的馒头
    【SRM20】数学场
    【Luogu】P3930 SAC E#1
    【Luogu】P3927 SAC E#1
    【Luogu】 P3928 SAC E#1
    【Codeforces】868C. Qualification Rounds
    【CodeForces】866D. Buy Low Sell High
  • 原文地址:https://www.cnblogs.com/zcy_soft/p/2076487.html
Copyright © 2020-2023  润新知