Is it possible to restrict flex bar chart y-axis count? - apache-flex

Is it possible to restrict flex bar chart y-axis count?
I have a very big name coming in my y-axis and i want to reduce or restrict it to 5 characters and on rollover i want to display it in full.

You can use the labelFunction of the axis. Check out the examples here: http://livedocs.adobe.com/flex/3/html/help.html?content=charts_displayingdata_06.html
You should easily be able to add a mouseOver event listener to put your tool tip on.

Related

Formatting legend markers

I would like to represent legend items' markers as lines for my Lineseries and not as boxes(by default) . I have managed it through setting markerWidth and markerHeight in a Legend tag. However, I have not only lineseries, but also plot series in my chart, which has diamond form marker. So, whenever I squeeze the box to a form of line in my legend, my plot series' marker is getting ugly.So, my questions:
1.Is there any way to control legend items separatly without creating a legend manually, item by item?
if I add item by item, how can I get the same style for my marker as related series have? (e.g. same shape and color as item renderer)
The way I'd do it is to create a custom LegendItem subclass that has a custom property with a getter/setter pair that takes a value of type function. Then I'd provide a ClassFactory that supplies the function as the LegendItem for your Legend. You'd call the function within the LegendItem to figure out what renderer to make based on the series.
I forget exactly when you'd do this in the Flex life-cycle--I've been out of Flex for almost 2 years. It's possible that there's a smarter/simpler way to do this that I've also forgotten. But it should work.

Drawing on Flex Chart

I've created a line chart in flex and it works like expected. Now, I would like to add shading to the background for specific information. For example, this chart - http://research.stlouisfed.org/fred2/graph/?id=TOTALSL,TOTALNS, - shows a shaded background for recessions. How would I mimic this shading in a Flex linechart?
Thanks
You could draw it in the background of the chart using the drawing api.
edit:
I dont know of any code examples on the web, I've only done it in production code (aka I cant share it, sorry :( )
you will want to create a container and put it into the charts
<mx:backgroundElements>
You should pass into this container the min and max for the x-axis probably as separate properties and a dataprovider that describes when to show a highlighted section. You might have to compute the min and max based on the dataprovider you pass into the chart.
If you just want to show the highlighted area you will just use the drawing api and compute where to put on the x-axis based on your min, max, width of container, and data point (start and end values) from your dataprovider. It will look something like this in your updateDisplayList:
// code is not tested but a good start
var shadeStartX:Number = (max-min)/startPoint;
var shadeEndX:Number = (max-min)/endPoint;
var shadeWidth:Number = shadeEndX - shadeStartX;
...
this.graphics.drawRect(shadeStartX, 0, shadeWidth, unscaledHeight);
but if you want to have things like hover states and all that goodness I would suggest creating a display object that you pass the width in and adding that to the container at the computed x-axis to set it at.
Hi I feel that drawing something yourself is not the right way to go.
You should ideally use a PlotSeries inside the LineChart, and create a custom item renderer for each element in the series.
PlotSeries allows you to give your own custom image/object to draw at a specific date/point in the chart.
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/mx/charts/series/PlotSeries.html
http://livedocs.adobe.com/flex/3/html/help.html?content=charts_types_10.html
All the examples show the plotSeries with smaller objects but you can create an object which covers the chart vertically and has a constant width.

How to Fill in the Area Underneath an ASP.Net Spline Chart Control with a Color?

I have an ASP.Net Chart Control of ChartType "Spline", one ChartArea and one Series (it's a sparkline). I was just wondering if anyone out there knew how I could color the area underneath the line - I can't seem to find the property that allows me to do this without coloring the entire background.
Thanks in advance
You need to have a chart with a ChartType of Area to achieve this type of look (similar to google analytics). I have tried it and it does work although i'm not sure how you might get the line to be one particular colour and the area underneath to be a second colour?
http://social.msdn.microsoft.com/Forums/en-US/MSWinWebChart/thread/981cc4df-2b23-4557-8d89-0b45d553fecc/

Custom grid line in a Flex Chart?

I am using the standard Flex 3 BubbleChart component and I would like to customize a couple of the grid lines separately from the rest.
I would like to highlight a gridline in the X-direction as well as in the Y-direction to show a quadrant.
Is there any way to customize the look and feel of a subset of gridlines within a Flex chart (i.e. bubble chart)?
Any ideas or suggestions would be appreciated.
Thanks!
Check out this two nice articles:
Using chart grid lines
Drawing on chart controls

Flex BarChart long text

In my application, I am using a BarChart to display data. However, the text in the category axis can be too long to display on the chart, so flex adjusts the font size automatically to the point that the data is either unreadable, or the text is partially visible.
The length of the text varies every time new data comes in, so I can't set the gutterLeft attribute to a static value at runtime.
Two things that come to my mind are:
Change the gutter dynamically according to new data
Have a scroll bar on the categoryaxis so that if any text won't fit in the space, the user can scroll to see it
Any help would be appreciated.
EDIT:
I have hundreds of rows of data being graphed at once, so I can't really use a legend for each item.
Also, I have no idea how to change the gutterLeft property with actionscript. Doing it in MXML is as simple as
gutterLeft="100"
but I cannot access the property using actionscript. I also tried to bind the gutterLeft variable to an integer and change that integer and it still didn't work. :|
the problem is that gutterleft is a style, and therefor needs to be set as one when using actionscript.
I was hoping to see your code to give a more detailed answer but what you want to do is:
mychart.setStyle("gutterLeft",500);

Resources