cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
abhishekmundra
Helper I
Helper I

Create Pie Chart Using Labels

I want to create pie chart using 3 Labels. All 3 label contain numeric values. So in the below image, 201, 199 and 27 are labels.

 

Also, i dont know why this exclaimation mark is showing even after my output is correct. Something is missing in formula?

 

Capture.PNG

 

Please help.

 

1 ACCEPTED SOLUTION

Accepted Solutions
jhall
Continued Contributor
Continued Contributor

Well, I'm fairly certain then that you and I are missing something basic.  That's fairly common for me, but I expected better out of YOU!  😉

  • Create a new screen
  • Drop a button onto this screen
  • Change the OnSelect setting to: ClearCollect(myPieChartData,{Display:"birds",Value:3},{Display:"bees",Value:1})
  • Alt-Click on that button
    • (we just ran that code and populated the collection)
  • drop in a brand new Pie Chart
  • select the Pie Chart portion of the group that gets created

image.png

  • change its Items property to be
    • myPieChartData
    • (Data should now be displayed in the chart)
    • (You can change what is displayed via the Label and Series settings just below the Items property)
  • Click Label and Series just to be certain you don't have other fields selectable beyond Display and Value
    • If you do have other values, then click on some of the other values.
    • (all of these get populated by creating/populating a Collection so if you do this multiple times and/or have typos then they'll stick around until you fix them everywhere in your app)

image.png

View solution in original post

11 REPLIES 11
jhall
Continued Contributor
Continued Contributor

Hover over the Triangle to see what's going on.

Just to clarify, you want to do a Pie Chart based on those values in the Labels, correct?  Easiest way might be to create a Collection either similarly to the Labels (identical source) or just reference the label's values in your Collection.

So, similar to:  ClearCollection(myChartData,{value:Value(Label1.Text),title:"some text"},{value:Value(Label2.Text),title:"some text2"},{value:Value(Label3.Text),title:"some text3"})

Then drop in your Pie Chart and set the Items value to be myChartData.  It should default to the numeric values being used to calculate the chart and the "title" values I included to be the labels.

Thank you for sharing.

Yes, I want to do a Pie Chart based on the values in the Labels.

 

Where do I put below line?

CreateCollection(myChartData,{value:Value(Label1.Text),title:"some text"},{value:Value(Label2.Text),title:"some text2"},{value:Value(Label3.Text),title:"some text3"})

 

Thanks!

@jhall I was able to use the query shared by you.

 

Its now blank and not showing any pie chart. At the same time its not throwing any error either.

 

Capture.PNG

jhall
Continued Contributor
Continued Contributor

Well, that's the OnSelect for your Pie Chart, so it would only run/populate the Collection when you clicked on it.  What's in your Items for your Chart?

jhall
Continued Contributor
Continued Contributor

Sorry, I see the Items is Collection1.  So yes, if you ran this and clicked your chart then it should populate.

Not the best way to do this as you should do it after you populate your Labels (or get the data directly vs. from the labels).  You could instead run the code you currently have in your Pie Chart's OnSelect event from a Button's OnSelect or you could do it for the OnVisible event (but you'd probably have to call the same code you're using to populate the labels directly vs. referencing the labels).

Items - Collection1 

 

The one I created.Capture.PNG

So I ran the app, clicked on it and still not showing. Just to verify, i checked display mode of the chart and it was set to edit so should be visible upon click

jhall
Continued Contributor
Continued Contributor

Hmmm...And Label1, Label3, and Label4 are your values from top->bottom on the right-hand side (that contain the #'s), correct?

Perhaps the Warning you're seeing is causing something to hiccup.  If you change the Code you have to be hard-coded values do they appear in the Chart (just as a sanity check)?

Label1, Label3, and Label4 are your values from top->bottom on the right-hand side (that contain the #'s), correct?
Yes

 

This time I changed text property of all 3 Labels to a static number. Still no luck. Screenshot attached!

 

 

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Top Solution Authors
Top Kudoed Authors
Users online (24,585)