vBulletin Mods

The Official vBulletin Modifications Site
https://www.vbulletin.org/forum/showthread.php?t=316061

Google Chart Integration
by gfran5
16 Dec 2014 17:49

I would love to include a pie graph on my members profile, where users can enter two different values e.g. Height & Weight and it is automatically produced as a pie graph.

I noticed the Google Charts API and it seems like it would be possible to do, i'm not a coder so i'm not sure. Has anybody used Google Charts or knows how this would be possible?

https://developers.google.com/chart/

HM666 16 Dec 2014 20:11

You would probably need to hire a PHP programmer for that. That would take some coding to have it work if its possible. Since you do not code it would probably be near to impossible for you to implement it yourself.

Dave 16 Dec 2014 21:06

This is not something hard to do but not a task for the average hobbyist. (Store submitted data in the database, retrieve on user profile and call Google Charts API.)

gfran5 17 Dec 2014 01:29

Quote:

This is not something hard to do but not a task for the average hobbyist. (Store submitted data in the database, retrieve on user profile and call Google Charts API.)
So would you be able to help me out? I'm currently making my own profile tab.

ozzy47 17 Dec 2014 12:19

Someone might be able to help you out, once you start coding it, and then when you run into issues, post your code and describe what issues you are having.

kh99 17 Dec 2014 12:24

Quote:

Originally Posted by gfran5 (Post 2527473)
I would love to include a pie graph on my members profile, where users can enter two different values e.g. Height & Weight and it is automatically produced as a pie graph.

I don't think it's very difficult, there's an example as part of the docs that you linked to above. But I don't understand what you want to display. You say "height and weight", but are you going to display those two values on the same chart, or do you want to display all users' heights on one pie chart and weights on another?

gfran5 17 Dec 2014 13:42

I want to have them both on the same pie chart, one figure as weight and the other as body fat % as seen here: http://www.theironden.com/forum/members/24086-gfran5

thoughts on where i should start, or if anybody would be willing to start me off and give me a rough guide of what to do.

kh99 17 Dec 2014 13:55

OK, I guess you want a pie chart showing percentage of lean mass vs. total body weight, which you're going to caluclate using height and weight?

Anyway, here's the google example (modified a little) which you can put in a template and it should display:


Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

So you just have to change the parts you want to change. I guess you could create profile variables for height and weight (using the "User Profile Field Manager"), then you can access those values in the template. If you're creating a new template for this then you probably need a plugin to register variables to it and render it. To be honest I'm not sure of the details of adding a profile tab.

gfran5 17 Dec 2014 14:38

I have already created those variables for Height and Weight needed, but i'm currently stuck with making the My Bodyspace page.

I have followed this guide on how to setup extra profile tabs, but i have no idea how to register my custom height and weight profile fields in the plugin so that they display on the template.

my template currently has:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


kh99 17 Dec 2014 14:47

Hmm...yeah, it would be nice if that guide had a little more detail about using the member's data. But going by a comment that appears later in the thread, I think it's in $prepared. So you'd have to add 'register' lines to the code that renders your template. For example you might be able to just do this:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

(line in red added), then use {userdata.field7} and {userdata.field8} in your template. I'm not sure if that will work or not, but it's the best guess I can make without trying it myself.

gfran5 17 Dec 2014 14:53

i tried:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

but the numbers still didn't show up on the page, anything else i could try?

kh99 17 Dec 2014 14:55

Did you create a plugin like that guide showed? What code do you have in your plugin?

gfran5 17 Dec 2014 15:01

my plugin is this:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.

--------------- Added 17 Dec 2014 at 15:35 ---------------

Any other ideas for how i can get my custom field data into my bodyspace profile page Kevin?

kh99 17 Dec 2014 17:30

Sorry, I lost my internet connection for a couple hours. Anyway, I copied your plugin code to create a new plugin using hook member_complete, and I created a template called memberinfo_block_test using the code from the guide page you linked to, but I get a blank tab. I haven't had a chance to figure out why yet.

Are you seeing anything from your template? I think I might have been wrong about using $prepared, I think you might want to use $userdata instead. So maybe change the added line to:

Block Disabled:      (Update License Status)  
Suspended or Unlicensed Members Cannot View Code.


then use {userinfo.field8}, etc. But if you're having the same issue I am with the tab being entirely blank then you probably still won't see the profile fields.

gfran5 18 Dec 2014 00:09

I tried that but that didn't work either, i am able to see "Congratulations, you can see me, I'm your PHP Code!" on the profile tab page, therefore it should work if it is right.

Not sure why this is so hard to do.


All times are GMT. The time now is 20:32.

Powered by vBulletin® Version 3.8.12
Copyright © 2018, MH Sub I, LLC dba vBulletin. All Rights Reserved. vBulletin® is a registered trademark of MH Sub I, LLC
Copyright ©2001 - , vbulletin.org. All rights reserved.