Flex Chart, determining chart area (not including - apache-flex

I am working on a flex application comparing multiple instance of the mx:PlotChart class. I need normalize the various instances of the PlotCharts such that the change in data value per pixel between charts remains constant. To do this, I must find the area of the chart actually used for graphing (and not for the axis labels). The area I am looking for is show (highlighted in fuschia) in the attached screen shot.
Thanks,
-Kevin

I think you're looking for the width and height of the series. Below is an example using a ColumnChart, but of course this will work for another type of chart such as LineChart.
Suppose we have the following data:
<mx:XMLListCollection id="dp">
<fx:XMLList>
<quote date="8/1/2007" open="40.29" close="39.58" />
<quote date="8/2/2007" open="39.4" close="39.52" />
<quote date="8/3/2007" open="39.47" close="38.75" />
<quote date="8/6/2007" open="38.71" close="39.38" />
<quote date="8/7/2007" open="39.08" close="39.42" />
<quote date="8/8/2007" open="39.61" close="40.23" />
<quote date="8/9/2007" open="39.9" close="40.75" />
<quote date="8/10/2007" open="41.3" close="41.06" />
<quote date="8/13/2007" open="41" close="40.83" />
<quote date="8/14/2007" open="41.01" close="40.41" />
<quote date="8/15/2007" open="40.22" close="40.18" />
<quote date="8/16/2007" open="39.83" close="39.96" />
<quote date="8/17/2007" open="40.18" close="40.32" />
<quote date="8/20/2007" open="40.55" close="40.74" />
<quote date="8/21/2007" open="40.41" close="40.13" />
<quote date="8/22/2007" open="40.4" close="40.77" />
<quote date="8/23/2007" open="40.82" close="40.6" />
<quote date="8/24/2007" open="40.5" close="40.41" />
<quote date="8/27/2007" open="40.38" close="40.81" />
</fx:XMLList>
</mx:XMLListCollection>
And the following chart:
<mx:ColumnChart id="myChart" dataProvider="{dp}" showDataTips="true" width="300">
<mx:horizontalAxis>
<mx:CategoryAxis categoryField="#date"/>
</mx:horizontalAxis>
<mx:series>
<mx:ColumnSeries id="openSeries"
xField="#date"
yField="#open"
displayName="Open"/>
</mx:series>
</mx:ColumnChart>
Then we can access the width and height of the series:
<s:Label text="{openSeries.width}" />
<s:Label text="{openSeries.height}" />

Related

Disable Telerik Chart Legend by default

How can I make one of the legend of a RadHtmlChart chart display unchecked by default when loading the chart.
Current Chart: current chart
Desired Chart: desired chart
Current telerik asp:
<telerik:RadHtmlChart runat="server" Skin="Bootstrap" ID="RhcIndicadores" Transitions="true">
<Legend>
<Appearance Position="Bottom"></Appearance>
</Legend>
<PlotArea>
<Series>
<telerik:ColumnSeries DataFieldY="Cantidad" Name="Cantidad">
<LabelsAppearance Position="InsideBase" DataFormatString="{0:0}">
<TextStyle Color="White" />
</LabelsAppearance>
<TooltipsAppearance>
<ClientTemplate>Cantidad: #=dataItem.Cantidad# requerimientos.</br>Participación: #= kendo.format(\'{0:N}\', dataItem.Participacion)#%.</br>Rango: #=dataItem.Rango#.</ClientTemplate>
</TooltipsAppearance>
</telerik:ColumnSeries>
<telerik:LineSeries DataFieldY="Participacion" Name="Participación" AxisName="AdditionalAxis">
<Appearance>
<FillStyle BackgroundColor="#ACB72F" />
</Appearance>
<LabelsAppearance DataFormatString="{0:N}%">
<TextStyle Color="#ACB72F" />
</LabelsAppearance>
<TooltipsAppearance DataFormatString="{0:N}%"></TooltipsAppearance>
</telerik:LineSeries>
<telerik:LineSeries DataFieldY="ParetoAcumulado" Name="Pareto Acumulado" AxisName="AdditionalAxisPareto">
<Appearance>
<FillStyle BackgroundColor="#5BC0DE" />
</Appearance>
<LabelsAppearance DataFormatString="{0:N}%" Position="Above">
<TextStyle Color="#5BC0DE" Bold="true" />
</LabelsAppearance>
<TooltipsAppearance DataFormatString="{0:N}%"></TooltipsAppearance>
</telerik:LineSeries>
</Series>
<XAxis DataLabelsField="Rango">
<LabelsAppearance RotationAngle="45"></LabelsAppearance>
<AxisCrossingPoints>
<telerik:AxisCrossingPoint Value="0" />
<telerik:AxisCrossingPoint Value="11" />
</AxisCrossingPoints>
<MajorGridLines Visible="false" />
<MinorGridLines Visible="false" />
</XAxis>
<YAxis Color="#337AB7">
<MajorGridLines Visible="false" />
<MinorGridLines Visible="false" />
</YAxis>
<AdditionalYAxes>
<telerik:AxisY Name="AdditionalAxis" Color="#ACB72F">
<LabelsAppearance DataFormatString="{0:N}%"></LabelsAppearance>
</telerik:AxisY>
<telerik:AxisY Name="AdditionalAxisPareto" Color="#5BC0DE">
<LabelsAppearance DataFormatString="{0:N}%"></LabelsAppearance>
</telerik:AxisY>
</AdditionalYAxes>
</PlotArea>
</telerik:RadHtmlChart>
I myself found the answer, in the desired series it should be indicated Visible="false" and VisibleInLegend="true":
<telerik:LineSeries DataFieldY="ParetoAcumulado" Name="Pareto Acumulado"
Visible="false" VisibleInLegend="true" AxisName="AdditionalAxisPareto">
<Appearance>
<FillStyle BackgroundColor="#5BC0DE" />
</Appearance>
<LabelsAppearance DataFormatString="{0:N}%" Position="Above">
<TextStyle Color="#5BC0DE" Bold="true" />
</LabelsAppearance>
<TooltipsAppearance DataFormatString="{0:N}%"></TooltipsAppearance>
</telerik:LineSeries>

Insert Image into a Column Series Telerik

I need to add an image in a specific Column chart, but I have no idea how can I insert the image, any idea, tutorial ?
I am using the RadHtmlChart
this is my code:
<telerik:RadHtmlChart ID="Chart" runat="server" Width="680" Height="500">
<PlotArea>
<XAxis>
<LabelsAppearance>
<TextStyle Color="white" FontFamily="Arial" FontSize="13" />
</LabelsAppearance>
</XAxis>
<YAxis MinValue="0" >
<LabelsAppearance DataFormatString="${0:0,0}">
<TextStyle Color="white" FontFamily="Arial" FontSize="12" />
</LabelsAppearance>
</YAxis>
<Series>
<telerik:ColumnSeries Name="Garantías Vigentes" Stacked="true">
<LabelsAppearance Position="Center" DataFormatString="${0:0,0}">
<TextStyle Color="Black" FontFamily="Arial" Bold="True" FontSize="18" />
</LabelsAppearance>
<Appearance>
<FillStyle BackgroundColor="#87cb50"></FillStyle>
</Appearance>
<SeriesItems>
</SeriesItems>
</telerik:ColumnSeries>
</Series>
<Series>
<telerik:ColumnSeries Name="Saldo Vigente" Stacked="true">
<LabelsAppearance Position="Center" DataFormatString="${0:0,0}">
<TextStyle Color="Black" FontFamily="Arial" Bold="True" FontSize="18" />
</LabelsAppearance>
<Appearance>
<FillStyle BackgroundColor="#8DB4E2"></FillStyle>
</Appearance>
<SeriesItems>
<telerik:CategorySeriesItem Y="0"></telerik:CategorySeriesItem>
</SeriesItems>
</telerik:ColumnSeries>
<telerik:ColumnSeries Name="" > //In this Column I need to insert the image
<LabelsAppearance Position="Center" DataFormatString="${0:0,0}">
<TextStyle Color="Black" FontFamily="Arial" Bold="True" FontSize="0" />
</LabelsAppearance>
<Appearance>
</Appearance>
<SeriesItems>
<telerik:CategorySeriesItem Y="0"></telerik:CategorySeriesItem>
</SeriesItems>
</telerik:ColumnSeries>
</Series>
</PlotArea>
<Legend>
<Appearance Position="Bottom"><TextStyle Color="white" FontFamily="Arial" FontSize="20" Bold="True"/></Appearance>
</Legend>
</telerik:RadHtmlChart>
I found in the forums Telerik but I can not find anything similar.
thanks for yours comments
I don't see where you have attempted to add an image, but this would be possible only inside a series tooltip, because this is the only place in the chart that renders HTML, the rest is SVG/VML.
Take a look at these articles to see how to add HTML to your tooltips and bind it to database data, if needed (e.g., for the src attribute):
http://www.telerik.com/help/aspnet-ajax/htmlchart-client-templates-for-tooltips-and-labels.html
http://www.telerik.com/help/aspnet-ajax/htmlchart-client-templates-for-tooltips-and-labels-execute-javascript-and-display-html.html

WHy is awesome_print gem showing <br /> in rspec output

I'm getting this output from ap, in my rspec test
"line1"<br />
"line2"<br />
"city"<br />
"state"<br />
"zip"<br />
"country"<br />
It is not because of the :html option, because when that's on it looks like:
<pre><kbd style="color:brown">"line1"</kbd></pre><br />
<pre><kbd style="color:brown">"line2"</kbd></pre><br />
<pre><kbd style="color:brown">"city"</kbd></pre><br />
<pre><kbd style="color:brown">"state"</kbd></pre><br />
<pre><kbd style="color:brown">"zip"</kbd></pre><br />
<pre><kbd style="color:brown">"country"</kbd></pre><br />

flex 3: RadioButtonGroups - multiple groups of independent radio buttons

I tried to search, but I couldn't find what I was looking for... so sorry if this is a repost.
I need to create 10 separate radio button groups, each with three options (show, collapse, or hide). I've created the following:
<mx:HBox>
<mx:Text text="Directors Prep." width="125" />
<mx:RadioButtonGroup id="dprepRB" enabled="false" />
<mx:RadioButton id="dprepshow" label="Show" value="1" groupName="{dprepRB}" />
<mx:RadioButton id="dprepcollapse" label="Collapse" value="0" groupName="{dprepRB}" />
<mx:RadioButton id="dprephide" label="Hide" value="-1" groupName="{dprepRB}" selected="true" />
</mx:HBox>
<mx:HBox>
<mx:Text text="Check In/Out" width="125" />
<mx:RadioButtonGroup id="checkIORB" enabled="false" />
<mx:RadioButton id="checkioshow" label="Show" value="1" groupName="{checkIORB}" />
<mx:RadioButton id="checkiocollapse" label="Collapse" value="0" groupName="{checkIORB}" />
<mx:RadioButton id="checkiohide" label="Hide" value="-1" groupName="{checkIORB}" selected="true" />
</mx:HBox>
... and so on with the other 8 groups
On load, I would like the "Hide" button to be selected. However, when the application loads, only the hide button on the last group is selected. If I select any other button on any other group, the "Hide" button from the last group is deselected, and the button I clicked becomes the only selected radio button. It seems like, for some reason, flex is thinking all the radio buttons belong to the same group. What am I doing wrong?
Thanks,
Brds
Try to use:
<mx:HBox>
<mx:Text text="Directors Prep." width="125" />
<mx:RadioButtonGroup id="dprepRB" enabled="false" />
<mx:RadioButton id="dprepshow" label="Show" value="1" group="{dprepRB}" />
<mx:RadioButton id="dprepcollapse" label="Collapse" value="0" group="{dprepRB}" />
<mx:RadioButton id="dprephide" label="Hide" value="-1" group="{dprepRB}" selected="true" />
</mx:HBox>
See details here.
Hi my solution was to define the RadioButtonGroup is the declarations tag block:
<fx:Declarations>
<mx:RadioButtonGroup id="dprepRB"/>
</fx:Declarations>
And then use the group later on in the HBox or whatever:
<mx:HBox>
<mx:Text text="Directors Prep." width="125" />
<mx:RadioButton id="dprepshow" label="Show" value="1" group="{dprepRB}" />
<mx:RadioButton id="dprepcollapse" label="Collapse" value="0" group="{dprepRB}" />
<mx:RadioButton id="dprephide" label="Hide" value="-1" group="{dprepRB}" selected="true" />
</mx:HBox>
You should use group="" not groupname="". Then each independent radio button group can be selected.
Cheers

Why is this Flex 4 Transition not working?

I have a test application here which was made using the following code:
<fx:Script>
<![CDATA[
public function comboBoxHandler():void{
var selectedItem:String = showComboBox.selectedItem;
if(selectedItem == "All results"){
currentState = "default";
return;
}else if(selectedItem == "Only results within tags"){
currentState = "tagInput";
return;
}
}
]]>
</fx:Script>
<s:states>
<s:State name="default"/>
<s:State name="tagInput"/>
</s:states>
<s:transitions>
<s:Transition id="showTagTextInput" fromState="default" toState="tagInput">
<s:Sequence id="t1p1" targets="{[tagsLabel,tagsTextInput,GoButton]}">
<s:Move duration="700"/>
<s:Fade duration="400"/>
</s:Sequence>
</s:Transition>
<s:Transition id="hideTagTextInput" fromState="tagInput" toState="default">
<s:Sequence id="t2p1" targets="{[tagsLabel,tagsTextInput,GoButton]}" >
<s:Fade duration="400"/>
<s:Move duration="700"/>
</s:Sequence>
</s:Transition>
</s:transitions>
<s:Label x="136" y="13" width="120" height="34" fontFamily="Arial" fontSize="15"
text="Lessons
Learnt" textAlign="center"/>
<s:Group id="group" width="100%" height="100%"
x.default="0" y.default="55" width.default="400" height.default="231"
y.tagInput="55" height.tagInput="256">
<s:Label x="45" y="38" width="50" height="22" text="Search" textAlign="center"
verticalAlign="middle"/>
<s:TextInput x="103" y="38" width="193"
useHandCursor.tagInput="false"/>
<s:Label x="45" y="89" width="51" height="22" text="Show" textAlign="center"
verticalAlign="middle"/>
<s:Button id="GoButton" x="253" y="137" width="43" label="Go" useHandCursor="true"
buttonMode="true" mouseChildren="false"
x.tagInput="254" y.tagInput="188"/>
<s:DropDownList id="showComboBox" x="104" y="89" width="192" change="comboBoxHandler();"
selectedIndex="0">
<s:ArrayCollection>
<fx:String>All results</fx:String>
<fx:String>Only results within tags</fx:String>
</s:ArrayCollection>
</s:DropDownList>
<s:Label id="tagsLabel" includeIn="tagInput" x="104" y="146" width="61" height="20" text="Tags"
textAlign="center" verticalAlign="middle"/>
<s:TextInput id="tagsTextInput" includeIn="tagInput" x="173" y="146" width="123"/>
</s:Group>
You can check, by clicking the link I gave, that this app performs some basic transition effect when you select different options from the DropDownBox.
The first (show) transition doesn't work so well, but the second (hide) transition does.
Does anyone know how to fix that? In the first transition, I would like the button to slide down first, only after that should the text input fade In. Why isn't this working?
Thanks in advance.
It is better to point particular effect target rather that pointing all the targets in <s:Sequence />. So place targets to <s:Move /> and <s:Fade />. Also you can perform additional transitions tuning by placing <s:AddAction /> and <s:RemoveAction /> with corresponding targets to point a place within sequence where transition should invoke includeIn and excludeFrom states declarations.
So these transitions works fine with your code:
<s:transitions>
<s:Transition fromState="default" id="showTagTextInput" toState="tagInput">
<s:Sequence id="t1p1">
<s:Move duration="700" targets="{[GoButton]}" />
<s:AddAction targets="{[tagsLabel,tagsTextInput]}" />
<s:Fade duration="400" targets="{[tagsLabel,tagsTextInput]}" />
</s:Sequence>
</s:Transition>
<s:Transition fromState="tagInput" id="hideTagTextInput" toState="default">
<s:Sequence id="t2p1">
<s:Fade duration="400" targets="{[tagsLabel,tagsTextInput]}" />
<s:RemoveAction targets="{[tagsLabel,tagsTextInput]}" />
<s:Move duration="700" targets="{[GoButton]}" />
</s:Sequence>
</s:Transition>
</s:transitions>
I would imagine it's because your tag input is only being included in the tagInput state, but the alpha is 100% and there's no transition between the states. Try this:
<s:Label id="tagsLabel" alpha.default="0" alpha.tagInput="100" x="104" y="146" width="61" height="20" text="Tags" textAlign="center" verticalAlign="middle"/>
<s:TextInput id="tagsTextInput" alpha.default="0" alpha.tagInput="100" x="173" y="146" width="123"/>
You might also want to set visible to false during 'default' state. Also, what Constantiner said is true.

Resources