[CLOSED] Pie Chart

  1. #1

    [CLOSED] Pie Chart

    Moving this from standard forums.

    ==
    Hi All

    Anyone got some code to insert a label into the centre space of a pie chart or know if there is a built in way of doing this?
    Basically I want a label in the space created in the centre of the Pie chart which is created by setting Donut="55".

    Ta,
    D
  2. #2
    Hello @CanopiusApplications!

    Just add an ext:Sprite like this:

    <ext:Sprite 
        Type="Text"
        Text="MyLabel"
        X="240" Y="240"
        Width="20" Height="20"
        Fill="red" />
    Inside the ext:Chart's Items block.

    Hope this helps!
    Fabrício Murta
    Developer & Support Expert
  3. #3
    Hi Fabricio

    Thanks for this, my concern with doing this was the re-positioning of the sprite on user actions such as browser resize, chart resize etc. Pretty sure I can come up with a way of doing this but was hoping there was some sort of inbuilt chart property that would do it for me.

    At a guess the only way to do this would be to monitor the chart resize event and set dynamic X & Y based on size.

    Marked as solved unless there is a better way.

    Ta,
    D
  4. #4
    This is what I ended up with which seems to work fine. Not tested fully though.

                                                    <ext:Chart ID="ChartAnalystPie" Flex="1" runat="server" Animate="false" Shadow="false" InsetPadding="25" Theme="Generic" >
    
                                                        <Listeners>
                                                            <Resize Handler="var sp = item.items[0].surface.items.get('spcount'); sp.setAttributes({x:adjWidth / 2, y:adjHeight / 2}, true);"></Resize>
                                                        </Listeners>
    
                                                        <Items>                                                                                                               
                                                            <ext:Sprite Type="Text" Text="MyLabel" Width="100" Height="20" X="0" Y="0" Fill="red" SpriteID="spcount"></ext:Sprite>
                                                        </Items>
  5. #5
    Hello @CanopiusApplications!

    Thanks for the feedback, and glad it helped. Unfortunately yes, that seems to be one of the best solutions on your case. Anything other than that would involve binding the events to the sprite you add in another manner. There's no built-in method to do such a thing as far as I know.
    Fabrício Murta
    Developer & Support Expert

Similar Threads

  1. [CLOSED] Line chart is Crossing the chart number axis
    By praveencat123 in forum 2.x Legacy Premium Help
    Replies: 3
    Last Post: Aug 26, 2015, 8:11 AM
  2. Replies: 2
    Last Post: Jul 23, 2014, 1:02 PM
  3. Replies: 1
    Last Post: Nov 07, 2013, 8:14 PM
  4. Replies: 2
    Last Post: Jun 20, 2013, 10:32 AM
  5. Replies: 2
    Last Post: Aug 13, 2012, 2:12 PM

Posting Permissions