0

Flex3.0 に縦棒グラフがあります。Datatip のフォントの色や背景の肌の色を変更できません。私は datatip を true に設定しており、Datatip 用に変更する機能がありません。

                         <mx:Panel title="Angles" alpha="1" color="#88442"  backgroundColor="#ffffff" >
    <mx:ColumnChart id="myColumnChart"    showDataTips="true"color="#88442 height="500" 
                    width="1300"  

                    dataProvider="{graphbar_data}"  
                    selectionMode="multiple"
                    dragEnabled="true" 
                    dropEnabled="false"

                    >
4

2 に答える 2

0

このカスタム データ ヒント アクション スクリプトを試してください。

// charts/MyDataTip.as
package {
import mx.charts.chartClasses.DataTip;
import mx.charts.*;
import flash.display.*; 
import flash.geom.Matrix;
import flash.text.TextField;     

public class MyDataTip extends DataTip {

    // The title is renderered in a TextField.
    private var myText:TextField; 

    public function MyDataTip() {
        super();            
    }       

    override protected function createChildren():void{ 
        super.createChildren();
        myText = new TextField();
    }

    override protected function updateDisplayList(w:Number, h:Number):void {
        super.updateDisplayList(w, h);

        // The data property provides access to the data tip's text.
        if(data.hasOwnProperty('text')) {
            myText.text = data.text;
        } else {
            myText.text = data.toString();        
        }

        this.setStyle("textAlign","center");
         this.setStyle("color","#FFFFFF");
        var g:Graphics = graphics; 
        g.clear();  
        var m:Matrix = new Matrix();
        m.createGradientBox(w+100,h,0,0,0);
        g.beginFill(0x339966,1);
        g.drawRect(-50,0,w+100,h);
        g.endFill(); 
    }
 }
}

このアクション スクリプトを creationComplete="applyCustomDataTips()" 関数で使用します。

例えば:

 public function applyCustomDataTips():void {
    myColumnChart.setStyle("dataTipRenderer",MyDataTip);    
}

カスタム DataTip レンダラーを参照

于 2013-04-15T13:49:53.800 に答える
0

Style プロパティを使用して変更できます。

ここに画像の説明を入力

<?xml version="1.0" encoding="utf-8"?>
<mx:Application 
xmlns:mx="http://www.adobe.com/2006/mxml" 
layout="absolute" 
minWidth="955" minHeight="600">

<mx:Script>
    <![CDATA[
        import mx.collections.ArrayCollection;
        [Bindable]private var graphbar_data:ArrayCollection = new ArrayCollection([
            {Month:"Jan", Profit:2000, Expenses:1500},
            {Month:"Feb", Profit:1000, Expenses:200},
            {Month:"Mar", Profit:1500, Expenses:500}
        ]);
    ]]>
</mx:Script>

<mx:Style>
    @namespace mx "library://ns.adobe.com/flex/mx";

    mx|DataTip {
        fontFamily: "Arial";
        fontSize: 14; 
        fontWeight:bold;
        fontStyle:italic; 
        backgroundColor:#ffff42;
        color:#ff0000;
    }
</mx:Style>

<mx:Panel title="Angles" x="20" y="20" width="400" height="300" alpha="1" color="0x88442" backgroundColor="0xffffff">
    <mx:ColumnChart 
        id="myColumnChart"    
        showDataTips="true"
        color="0x88442" 
        height="100%" 
        width="100%"  
        dataProvider="{graphbar_data}"  
        selectionMode="multiple"
        dragEnabled="true" 
        dropEnabled="false">

        <mx:horizontalAxis>
            <mx:CategoryAxis dataProvider="{graphbar_data}" categoryField="Month"/>
        </mx:horizontalAxis>

        <mx:series>
            <mx:ColumnSeries xField="Month" yField="Profit" displayName="Profit"/>
            <mx:ColumnSeries xField="Month" yField="Expenses" displayName="Expenses"/>
        </mx:series>    

    </mx:ColumnChart>
</mx:Panel>
</mx:Application>

Flex 4.6 を使用しています。3 番目のバージョンしかない場合は、次のようにスタイルを定義する必要があります。

<mx:Style>
    DataTip {
        fontFamily: "Arial";
        fontSize: 14; 
        fontWeight:bold;
        fontStyle:italic;    
        backgroundColor:#ffff42;
        color:#ff0000;        
    }
</mx:Style>
于 2013-04-13T15:59:20.670 に答える