Flex: view the details of a certain number of workers, and rewrite Renderer to display the data point label value of linechart and the displayed icon style ........

Source: Internet
Author: User

In the Microsoft Visual Studio development framework, right-click a class or function and choose go to view details.

Haha, there are some differences in flex:For example, View the class or function, right-click it, and choose goto definition (Shortcut Key F3) To View Details.

// Configure //--------------------------------------------------------------------------------------

Flex default Renderer is relatively simple and single. To implement complex or diverse functions, we can combine the various Renderer classes included in the Framework for redefinition.

The triangleitemrenderer class is accidentally introduced. The specific interfaces are all located. The labels and data dots can be simultaneously displayed by rewriting. Other functions are similar ....

AttachedMylabel.Code:

Package Custer
{
Import MX. charts. chartitem;
Import MX. Core. idatarenderer;
Import MX. Controls. label;
Import MX. Core. uicomponent;
Import MX. charts. Series. lineseries;
Import MX. charts. Series. Items. lineseriesitem;
Import flash. display. graphics;
Import flash. Geom. rectangle;
Import MX. charts. chartclasses. graphicsutilities;
Import MX. Core. idatarenderer;
Import MX. Graphics. ABAQUS;
Import MX. Graphics. istroke;
Import MX. Skins. programmaticskin;
Import MX. Controls. label;
Import MX. Core. uicomponent;
Import MX. charts. renderers .*;
Import MX. utils. colorutil;
Import MX. Styles. stylemanager;
Import MX. Graphics. solidcolor;

Public class mylabel extends uicomponent implements idatarenderer // idatarenderer
{
Private VaR _ label: label;

Public Function mylabel (): void
{
Super ();
_ Label = new label ();
// _ Label. setstyle ("itemrenderer", new MX. Core. classfactory (triangleitemrenderer ));

Addchild (_ label );

// New MX. Core. uicomponent (). addchild (_ label );
// Circleitemrenderer ().
_ Label. setstyle ("color", 0x999999 );
_ Label. setstyle ("fontsize", 12 );
_ Label. setstyle ("paddingtop", 4 );

_ Label. setstyle ("itemrenderer", new MX. Core. classfactory (triangleitemrenderer ));
}
Private VaR _ chartitem: chartitem;
Private VaR _ DATA: object;
Private Static Var rcfill: rectangle = new rectangle ();
Public Function get data (): Object
{
Return _ chartitem;
}

Public Function set data (value: Object): void
{
If (_ chartitem = value)
Return;
_ Chartitem = chartitem (value );

If (_ chartitem! = NULL)
_ Label. Text = lineseriesitem (_ chartitem). yvalue. tostring ();
}

Override protected function updatedisplaylist (unscaledwidth: Number,
Unscaledheight: Number): void
{
Super. updatedisplaylist (unscaledwidth, unscaledheight );

_ Label. setactualsize (_ label. getexplicitormeasuredwidth (), _ label. getexplicitormeasuredheight ());

VaR fill: ABAQUS;
VaR state: String = "";
_ DATA = _ chartitem;
If (_ data is chartitem & _ data. hasownproperty ('fill '))
{
Fill = _ data. Fill;
State = _ data. currentstate;
}
Else
Fill = graphicsutilities. fillfromstyle (getstyle ('fill '));

VaR color: uint;
VaR adjustedradius: Number = 0;

Switch (state)
{
Case chartitem. Focused:
Case chartitem. rolover:
If (stylemanager. isvalidstylevalue (getstyle ('itemrolovercolor ')))
Color = getstyle ('itemrolovercolor ');
Else
Color = colorutil. adjustbrightness2 (graphicsutilities. colorfromfill (fill),-20 );
Fill = new solidcolor (color );
Adjustedradius = getstyle ('adjustedradius ');
If (! Adjustedradius)
Adjustedradius = 0;
Break;
Case chartitem. Disabled:
If (stylemanager. isvalidstylevalue (getstyle ('itemdisabledcolor ')))
Color = getstyle ('itemdisabledcolor ');
Else
Color = colorutil. adjustbrightness2 (graphicsutilities. colorfromfill (fill), 20 );
Fill = new solidcolor (graphicsutilities. colorfromfill (color ));
Break;
Case chartitem. focusedselected:
Case chartitem. Selected:
If (stylemanager. isvalidstylevalue (getstyle ('itemselectioncolor ')))
Color = getstyle ('itemselectioncolor ');
Else
Color = colorutil. adjustbrightness2 (graphicsutilities. colorfromfill (fill),-30 );
Fill = new solidcolor (color );
Adjustedradius = getstyle ('adjustedradius ');
If (! Adjustedradius)
Adjustedradius = 0;
Break;
}

VaR stroke: istroke = getstyle ("stroke ");

VaR W: Number = stroke? Stroke. Weight/2: 0;

VaR CX: Number = unscaledwidth/2;

Rcfill. Left = rcfill. Left-adjustedradius;
Rcfill. Top = rcfill. Top-adjustedradius
Rcfill. Right = unscaledwidth + adjustedradius;
Rcfill. Bottom = unscaledheight + adjustedradius;

VaR G: Graphics = graphics;
G. Clear ();
G. moveTo (W, W );
If (stroke)
Stroke. Apply (g );
G. moveTo (W-adjustedradius, unscaledheight-W + adjustedradius );
If (fill)
Fill. Begin (G, rcfill );
G. lineto (CX, W-adjustedradius );
G. lineto (unscaledwidth-W + adjustedradius, unscaledheight-W + adjustedradius );
G. lineto (W-adjustedradius, unscaledheight-W + adjustedradius );
If (fill)
Fill. End (g );
}

}

}

 

Same as above, rewrite can define custom labels and Icon styles for linechart data points...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.