Calculating a pie wedge

Ok I stuck, I have tried several different equations and I can't seem to get this one.
int[]  totalAnswersForAnswer
totalAnswersForAnswer[0] = 2
totalAnswersForAnswer[1] = 3
totalAnswersForAnswer[2] = 2
totalAnswersForAnswer[3] = 2
totalAnswersForAnswer[4] = 1
// using k in place of i so I don't get stupid italics
int k = 0;
while ( k < totalAnswersForAnswer.length ){
// ? is where I'm stuck
currAngle = (int)Math.round( ? * TotalOutput[k] );
g.fillArc(0, 0, pieSize, pieSize, startAngle, currAngle);
startAngle+=currentAngle;
k++;
}How do I get the proportions right to fill in the circle
Thanks
Jim

// ? is where I'm stuck
currAngle = (int)Math.round( ? * TotalOutput[k] );Try this:
currAngle = (int)Math.round(totalAnswersForAnswer[k] * 360.0 / TotalOutput);I think TotalOutput is an integer, not an array and contains the sum of totalAnswersForAnswer

Similar Messages

  • Pie chart wedge function call

    Hi,
    I am trying to build a pie chart that will fire a custom function on rollover of the individual pie wedges.
    I need to be able to pass information about the wedge that is rolled over (i.e. a name or id) to this function.
    Thanks.

    I am close. I just need to find the right path to the wedge id.
    This is what I have so far.
    <fx:Script><![CDATA[
            import mx.charts.events.ChartItemEvent;
            private function itemClickHandler(e:ChartItemEvent):void {
                var selectedIndx:String= e.currentTarget.series.index; //<--returns null
        ]]></fx:Script>
    <s:VGroup>
            <mx:PieChart width="220" height="220" id="piechart1"
                         dataProvider="{srv.lastResult.AAFunds.fundName}"
                         itemClick="itemClickHandler(event)"
                         >
                <mx:series>
                    <mx:PieSeries  displayName="pie series 1" />
                </mx:series>
            </mx:PieChart>
        </s:VGroup>

  • Pie chart wedge itemRollOver

    I need help with creating a custom pie chart class that will allow a function call on pie wedge rollOver.
    Right now I can get a function call on rollover using itemRollOver using;
    import mx.charts.events.ChartItemEvent;
    -in the <mx:PieChart>;
    itemRollOver="pieChart_itemRoll(event);"
    -which calls this function
    private function pieChart_itemRoll(evt:ChartItemEvent):void {
                    var psi:PieSeriesItem = evt.hitData.chartItem as PieSeriesItem;
                    trace(psi.item.target);
    Please advise on how can I put this into a custom PieChart .as that extends PieChart?
    Currently itemRollOver in my custom class throws an undefined property error.
    Thanks.

    OK, now I get it. So you would need to place your two PieCharts in a s:Group or mx:Canvas. On top of the pie charts, lay another s:Group on which you will do some drawing on its graphics:Graphics object.
    In your case, you need to use dataToLocal() (will give you pixel coordinates in your chart) then localToGlobal()  (convert to Application coordinates) then globalToLocal() (convert to the Top Group or Canvas coordinates you want to draw in) :
    Using the dataToLocal() method
    The dataToLocal() method converts a set of values to x  and y coordinates on the screen. The values you give the method are in  the "data space" of the chart; this method converts these values to  coordinates. The data space is the collection of all possible combinations of data values that a chart can represent.
    The number and meaning of arguments passed to the dataToLocal() method depend on the chart type. For CartesianChart controls, such as the BarChart and ColumnChart controls, the first value is used to map along the x axis, and the second value is used to map along the y axis.
    For PolarChart controls, such as the PieChart control, the first value maps to the angle around the center of the  chart, and the second value maps to the distance from the center of the  chart along the radius.
    The coordinates returned are based on 0,0  being the upper-left corner of the chart. For a ColumnChart control, for  example, the height of the column is inversely related to the x  coordinate that is returned.
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayOb ject.html#localToGlobal%28%29
    http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/DisplayOb ject.html#globalToLocal%28%29

  • How to retrieve pie chart wedge id

    Hi.
    I'm trying to figure out how to get an id or index of a specific wedge from a pie chart
    I think I'm close. I just need to find the right path to the wedge id.
    This is what I have so far.
    <fx:Script><![CDATA[
            import mx.charts.events.ChartItemEvent;
            private function itemClickHandler(e:ChartItemEvent):void {
                var selectedIndx:String= e.currentTarget.series.index; //<--returns null
        ]]></fx:Script>
    <s:VGroup>
            <mx:PieChart width="220" height="220" id="piechart1"
                         dataProvider="{srv.lastResult.AAFunds.fundName}"
                         itemClick="itemClickHandler(event)"
                         >
                <mx:series>
                    <mx:PieSeries  displayName="pie series 1" />
                </mx:series>
            </mx:PieChart>
        </s:VGroup>

    Figured it out.
    Here is a simple example;
    <?xml version="1.0" encoding="utf-8"?>
    <!-- http://blog.flexexamples.com/2007/11/15/displaying-a-pieseries-items-data-when-a-user-clic ks-an-item-in-a-flex-piechart-control/ -->
    <s:Application
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library://ns.adobe.com/flex/mx"
        xmlns:s="library://ns.adobe.com/flex/spark"
        >
        <fx:Declarations>
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import mx.charts.series.items.PieSeriesItem;
                import mx.charts.events.ChartItemEvent;
                [Bindable]
                public var chartDP:Array = [
                    {wedgeName:'Pie wedge 1', percent:45 },
                    {wedgeName:'Pie wedge 2', percent:25},
                    {wedgeName:'Pie wedge 5', percent:22},
                    {wedgeName:'Pie wedge 4', percent:8}
                private function pieChart_itemClick(evt:ChartItemEvent):void {
                    var psi:PieSeriesItem = evt.hitData.chartItem as PieSeriesItem;
                    myTextArea.text += "\rwedgeName: "+psi.item.wedgeName+" percent: "+ psi.item.percent;
            ]]>
        </fx:Script>
    <s:VGroup>
        <mx:PieChart id="pieChart"
                     dataProvider="{chartDP}"
                     itemClick="pieChart_itemClick(event);"
                     showDataTips="false"
                     height="300"
                     width="300">
            <mx:series>
                <mx:PieSeries id="pieSeries"
                              field="percent">
                </mx:PieSeries>
            </mx:series>
        </mx:PieChart>
        <s:TextArea id="myTextArea"  y="82" width="350" height="250" />
    </s:VGroup>
    </s:Application>

  • How can I wrap text in a pie in pages?

    How can I wrap text in a pie in pages?

    If you need to insert text into a shape like a pie wedge, the easiest way might be to simply use the shape - freeform tool (at the bottom of the shape menu) and create a shape and type your text in it then place the shape over your pie wedge. The text within the shape should wrap - additional controls for text can be used with the Text Inspector.
    You can edit the actual shape with Format Object > Make Shape Editable option but unfortunately, you have an option to make straight or smooth curves, but not both, so you'll need to shape the object using smooth curves and use the the bezier controls that appear as you select a control point.

  • Pie Chart Color Scheme

    Post Author: Janice
    CA Forum: Charts and Graphs
    I have a report written in Crystal Reports XI that has a pie chart in the Report Header displaying counts of activity by "reason code" for a selected time period.  The users have noticed that, when they run the report for different time periods, the same "reason" has a different color on each report.   It seems that the default is to sequence colors based on volume (size of 'pie wedge').
    They would like to have the colors appear linked to Reason Code rather than to volume.  Is there a way to change the pie chart color scheme so that it is coded by "description" not by "count"?

    hi,
    As you are selecting 'Color Highlight' for different Pie Slices,  "For all records" option shouldn't be selected.
    It should be "On Change of".
    Then obviously you will see the colors specified in 'Color Hghlight' tab.
    Regards,
    Vamsee

  • How to Fill PieChart Explode Wedge Potion

    All,
    I need to create a Pie Chart with two Wedges using perWedgeExplodeRadius = [0,0.2]. It works fine. But my requirments is i need to fill the explode wedge potion with someother color.
    I have attached the expected PieChart, i need help for how to achive the gray potion. It's possible to draw a circle around the chart or there is any way to fill that explode potion. Please help me.
    Thanks in advance.
    By,
    Dhanasekaran

    Figured it out.
    Here is a simple example;
    <?xml version="1.0" encoding="utf-8"?>
    <!-- http://blog.flexexamples.com/2007/11/15/displaying-a-pieseries-items-data-when-a-user-clic ks-an-item-in-a-flex-piechart-control/ -->
    <s:Application
        xmlns:fx="http://ns.adobe.com/mxml/2009"
        xmlns:mx="library://ns.adobe.com/flex/mx"
        xmlns:s="library://ns.adobe.com/flex/spark"
        >
        <fx:Declarations>
        </fx:Declarations>
        <fx:Script>
            <![CDATA[
                import mx.charts.series.items.PieSeriesItem;
                import mx.charts.events.ChartItemEvent;
                [Bindable]
                public var chartDP:Array = [
                    {wedgeName:'Pie wedge 1', percent:45 },
                    {wedgeName:'Pie wedge 2', percent:25},
                    {wedgeName:'Pie wedge 5', percent:22},
                    {wedgeName:'Pie wedge 4', percent:8}
                private function pieChart_itemClick(evt:ChartItemEvent):void {
                    var psi:PieSeriesItem = evt.hitData.chartItem as PieSeriesItem;
                    myTextArea.text += "\rwedgeName: "+psi.item.wedgeName+" percent: "+ psi.item.percent;
            ]]>
        </fx:Script>
    <s:VGroup>
        <mx:PieChart id="pieChart"
                     dataProvider="{chartDP}"
                     itemClick="pieChart_itemClick(event);"
                     showDataTips="false"
                     height="300"
                     width="300">
            <mx:series>
                <mx:PieSeries id="pieSeries"
                              field="percent">
                </mx:PieSeries>
            </mx:series>
        </mx:PieChart>
        <s:TextArea id="myTextArea"  y="82" width="350" height="250" />
    </s:VGroup>
    </s:Application>

  • Numbers legend problem

    i have a problem, actually i have two problems. my first thing is that i can't order a chart's legend to show in a vertical column.
    I want this legend to be shown vertically, at the right side of my chart. I can't find any way to make this happen.
    My second problem is with keynote. if my legend is shown vertically, i can't separate the values in it (CV, HR...) so if I want to use the Move in effect, the values would move in by pie wedge. Ex, first pie wedge move in, first legend value move in, and so on. I don't know i i was clear enough

    On your first problem,
    Select the legend. It will get resizing handles (little white squares) on each side
    Grab one of those handles and make the legend less wide until it is all vertical
    Move the legend to the right side of the pie
    On your second problem, because the legend is a single object it moves in as a single object. You need to make the legend manually so each category label (with its colored circle) is a separate object.  Then you can have the chart and legend move in as slice 1, legend 1, slice 2 , legend 2 ...

  • Mail.app stuck spinning on "opening mailbox"

    I just used Migration Assistant to move my content from my old iMac (running 10.5.8) to my new iMac (running 10.6.4). When opening Mail.app everything works fine — except in the Activity Window I see Mail.app trying to open two mailboxes. Also next to "Sent" is a spinning dial for a bit and then a pie wedge.
    Connection Doctor shows my two e-mail accounts are connecting just fine (inbound and outbound). I can receive mail, but it will not send. Clicking the stop sign next to the two "Opening Mailbox" messages in the Activity Window does nothing.
    I've rebuilt the mailboxes, rebuilt the index using the trick of removing the ~/Library/Mail/Envelope Index file and restarting Mail.app to reimport everything.
    I even reinstalled the OS on the new machine and reimported my content via Migration Assistant after first rebuilding the mailboxes on the old iMac but same problem exists.
    It seems like Mail.app is trying to send a message and getting stuck.... or something like that. Note I have NO outbox appearing... only Sent, never an outbox even when I try to send Mail.
    Any help is appreciated.
    -Werner

    I took the computers to a local Mac guy and he discovered the issue was Carbonite trying to restore the old computer hard drive on the new one as soon as the machine was turned on and connected to the internet.
    Once Carbonite was disabled and ~/Library/Mail/* files were put back in place, all worked well.

  • My SWF is not reading a data file when off my machine

    I have done a build out of Flash Builder 4.5.
    My app reads an external XML in the local dir and displays a pie chart and then a bar chart for each of the selected pie wedges.
    Works great for me.
    But when I share the SWF and XML with co workers the SWF does not seem to read the XML for them.
    Is there another file I need to provide them?
    Or is there a build setting I have not set?

    Thank you.
    I tried this and it seems to work.
    But a total standalone app is not what I am looking for.
    I am producing this for researchers that would then want to add these visualizations
      to their presentations and reports.
    So the product needs to be able to be embeded into Word docs, Power Point and the like.
    My goal is to produce an SWF that reads an external XML file for data to
      then visualize on charts.
    I have found that if I embed the data in the original mxml file it seems to work fine.
    I only am having trouble when I start trying to read external data.
    I guess I will resort to hard wiring the data into the SWF but it seems to not be right.

  • SAP charting capabilities (ABAP)

    Hi everybody,
    I did some research into SAP's charting capabilities and I am a little confused about the different ways charts can be created.
    One key feature I need in my charting application is event handling, for example when a user clicks on a pie wedge.
    Right now I see three different ways of creating charts in ABAP
    - Using the GRAPH_... function modules for example GRAPH_2D
    - Using the Graphical Framework as in GFW_PROG_TUTORIAL
    - Using the CL_GUI_CHART_ENGINE class
    Is there any major difference between these three? I know that GFW and CL_GUI_CHART_ENGINE support event handling. Do the GRAPH_... FuBas so?
    BTW, is it possible to use the xml file created in Chart Designer in one of the aforementioned solutions?
    Thanks everybody,
    Mane

    This code snippet shows how to use function GFW_PRES_SHOW.
    ...data gathering
    *__Make data format
    DATA: lv_cnt(2), lv_text(30).
    REFRESH values.
    REFRESH column_texts.
    SORT it_gra BY zcono.
    *__Row definition
    LOOP AT it_gra.
      lv_cnt = sy-tabix.
      CONCATENATE 'VALUES-VAL' lv_cnt INTO lv_text.
      CONDENSE lv_text.
      ASSIGN (lv_text) TO <fs>.
      <fs> = it_gra-cnt.
    ENDLOOP.
    *___Row Text
    values-rowtxt = '??????'.
    APPEND values.
    *__Column definition
    LOOP AT it_gra.
      column_texts-coltxt = it_gra-zcono.
      APPEND column_texts.
    ENDLOOP.
    *___Call graph function
    CALL FUNCTION 'GFW_PRES_SHOW'
         EXPORTING
           presentation_type = 31        "graph type 31 = pie type, 8 or 1 = bar chart
           parent = contc                "Custom Container
         TABLES
           values = values               "row data(Maximun 32)
           column_texts = column_texts   " column definition
         EXCEPTIONS
           error_occurred = 1
           OTHERS = 2.

  • Deactivate mac acrobat pro on laptop, activate on macPro floor-top--can't uninstall, can't launch (config error 1)

    Trying to do two things: switch Acrobat Pro XI 11.0.6 from laptop to floor-top (MacQuadProDual what'sit)    AND update from 11.0.6. to 11.0.9.
    11.0.6 already on the floor-top gives me "Configuration Error 1"  check Adobe Support.
    All attempts to Uninstall 11.0.6 crash the Uninstaller.
    Launch, as noted above, results in the Configuration Error 1.
    I deactivated the laptop first,  then tried to launch and re-activate Acrobat Pro 11.0.6 on the floor-top. Error as above.  Attempted matching 11.0.6 UnInstaller--crashes as noted.
    Surely there not so many Acrobat Pro thieves in the world that Adobe has to go to these (non-working) extreme lengths to protect it's monopoly-of-short-duration (17 years is it still? I think that's the # of years set out in the US Constitution).  Or perhaps they should petition Congress, CIA, Justice for permission to use the new US Standard for legal matters, "Enhanced".  "Enhanced Interrogation" is our new trend-setting feature in treatment of prisoners of war, as per our self-proclaimed US Convention in 2001 (where we agreed with ourselves that "Torture Is A Person, Too" (oops. thinking of something else).  Mean to say, "Torture Is the New Black. drat--meant "Torture Is the New US Policy."
    So, by analogy, we can use "Enhanced Deposition-Taking" in civil and criminal lawsuits, "Enhanced Examination, Cross-Examination, Re-Examination, and Re-Cross Examination. We could use Enhanced Ticketing in misdemeanor cases.
    And of course, we should be able to implement Enhanced Impeachment Procedures in ridding ourselves of traitorous presidents, congress-persons, supreme court and federal judges,  and civil servants.  It would be neat to see the Enhanced Impeachment Procedures on C-SPAN, from the well of the House. They'd have to use the finest of spring-water, of course. And Turkish washcloths. I guess any high-end surfboard, with appropriate no-slip safety straps added, would serve as the Enhanced Reclining Representative's Seat.
    But I digress.
    Here's another point: I have four  internal drives running on the floor-top Mac. Months ago I did switch start-up disks from a 1TB to a 2TB drive and I don't think I had used the Acrobat Pro since that time. Should I do something with stale cookies, or dried-up brownies or cake wedges? Pie wedges?  Maybe just remove the raisins and Toll House Chocolate Morsels from the cookies, leaving the cooked batter behind?
    Any assistance would be appreciated.
    Yours in sorrow, 
    bw 

    OK. Fingers crossed. Maybe someone out there has an answer, if Adobe doesn't.

  • Interactive Report Charts

    When a user creates a chart in an interactive report, is it possible to set it so that clicking on a bar/pie wedge/value would take them to a report view filtered down to the records in that set?
    An example: we have an IR, and built a pie chart of users vs. number of requests; when we click on a particular user's wedge, it slides out from the pie slightly, but we'd prefer to be taken to a view of the IR filtered down to that user's requests (so we can view/edit them). Can we do this?
    -David

    That's what I thought. It's not what my users expect, of course, and would make a great feature (HINT, HINT, developers!).
    On the plus side, it's possible to build a report and a (separate) flash chart to give drill-down functionality. It's a more limited option, and might result in user confusion--why can I drill down in this report, but not in this other one?--but it is an option.
    -David

  • Finder showing a "CD" even though there is no CD in the drive?

    Several days ago I went through some old, unlabeled CD's to see what was on them. Most of them just had some music, a few of them were blank. Since then my finder has been showing "Untitled CD" listed in the same category as my documents, applications, desktop, etc. To the right there is a small circle with yellow and black pie wedges.  (Please excuse the highly technical terminology ). I am unable to click on either the label or the symbol and when I right click the only option I get is "Open Sidebar Preferences." I have tried inserting then ejecting a different CD and I have also rebooted the computer but it doesn't go away. Any thoughts?

    Hi s,
    Click on the desktop > Finder menu > Preferences > General > uncheck CDs
    Click on the desktop > Finder menu > Preferences > Sidebar > uncheck CDs
    I don't know if a restart is needed, but I would. Set prefs back up the way you want and see if it's gone.

  • Disable hitArea for an imported swf

    hi.
    I am trying to create a custom data tip for a pie chart that is an imported swf.
    Basically I have the pie wedge move the swf on rollOver.
    The problem is that swf is on a higher depth than the pie chart it is not getting the rollOut call when the mouse rolls out of the wedge.
    Can anyone tell me if there is a way to disable the hitArea of the swf?
    Thanks!

    That only seems to affect the mouse cursor.
    I actually found a work around by setting the visibility of the swf to false on rollout of the pie wedge.
    I was mistaken when I thought the pie wedge was not getting it's rollOut call while the swf was visible.
    However any pie wedges that are hidden by the swf do not get their rollOver call, so it necessitates turning the visibility off.
    The same effect is achieved by setting the swf alpha to 0.
    FYI

Maybe you are looking for