![]() |
Google Chart Integration
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/ |
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.
|
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.)
|
Quote:
|
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.
|
Quote:
|
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. |
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: PHP Code:
|
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: HTML Code:
<div class="body_measurements"> |
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:
Code:
$templater = vB_Template::create('memberinfo_block_test'); |
i tried:
HTML Code:
<div class="body_measurements"> |
Did you create a plugin like that guide showed? What code do you have in your plugin?
|
my plugin is this:
PHP Code:
Any other ideas for how i can get my custom field data into my bodyspace profile page Kevin? |
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: Code:
$templater->register('userinfo', $userinfo); 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. |
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. |
Yeah, I can't even get that message to show up and it's frustrating me. I don't think I can deal with it any more tonight.
I noticed that the template uses $userinfo in a condition, but for some reason it's not registered in the example plugin. Maybe it's preRegistered somewhere else or something. But that does mean that {userinfo.fieldX} would work if the profile fields are actually there (and since this is the profile page you'd think they would be). Did you create those fields as private? Even if you did they should appear when you're looking at your own profile. You have data entered for those fields, right? I just can't think of any other reason right now. Anyway, I'll look at it again in the morning if you haven't figured it out by then. If I can get the template to appear then I can figure out the field value problem. |
Yeah Kevin, sometimes it is best to step back for the night, and come at it fresh in the morning.
|
1 Attachment(s)
Yeah, i have entered data and i am even displaying this information on my postbit_legacy template with all the numbers showing up, but for some reason when i try the same thing on a member profile tab, nothing shows up.
I'm still trying to look for a way.. i know you can go into custom "profile field categories" and set it to display on it's own tab...i think it uses the template "memberinfo_block_profilefield" but even using that template the numbers don't show up in the code i used for postbit_legacy. Thanks for helping me out on this! do you have any ideas Chris? |
OK, I have no idea what my problem was yesterday, but I went back to using the plugin code and template code from the guide and got it to appear. Then I added a register line for userinfo, like:
Code:
$templater->register('userinfo', $userinfo); Now here's where I might have steered you wrong, just because I was spacing out - you should add {vb:raw userinfo.field7} in the template (I don't know why I was forgetting the vb:raw part). Anyway, if that was the only problem you were having, I'm really sorry about that. So if you can get those values displaying then you probably would want to add code to the plugin to calculate whatever values you need for the chart and register them to the template, then you just have to copy that chart html to your template and insert the parameters. |
You were pretty close, just forgot to mention to change (if $post) to (if $userinfo)... but thanks for your help. I will try get this chart working, if i have any questions i will post back.
|
Quote:
|
Hi,
This is slightly unrelated but i'm having some CSS issues on the template: Link to the page For some reason my footer is half may up the page, rather than normal position on bottom. Here is my template code: Code:
<div id="view-test" class="<vb:if condition="$selected_tab == 'test'">selected_view_section<vb:else />view_section</vb:if><vb:if condition="$userinfo['userid'] != $bbuserinfo['userid']"> vm_other_prof</vb:if>"> |
I'm not really an html/css person, but I looked at the page and your new tab doesn't look like it's any different than the other tabs, so I don't think the problem is in the template for the new tab. I see that the .footerBanner css has absolute positioning for that 'free gift' image, so that's why that's in the middle of eveyrthing. There's also that red line, but I don't know exactly why that's happening.
|
That red line goes with the footer-main section, making the advertisement absolute doesn't fix the issue, this is getting me confused, because the only pages effected are the ones on the member profile... could it be anything in the PHP code?
|
Does it still happen if you disable the new plugin?
|
Sorry don't worry i've figured it out, was missing just one </div> element.. lol hate when it's that simple right in front of your face.
|
Glad you figured it out. I should just not reply at all when people ask html questions.
|
Hi,
Was wondering if you know how to do math equations in html template just simple things like times, divide, etc ? |
There is a {vb:math expression} tag that lets you do some simple math, but I don't think it's used much, and if I remember correctly there's some limitation so that it's not very useful. It may be that you can't use variables in the expressions or something like that.
In general I think you'll probably have to do you calculations in the plugin. |
So i was able to use vb:math to do what i wanted but i can't control the number of decimals displayed. So how would i do the maths in the plugin? and then call the equation in the template? I was trying to measure BMI based off height and weight but need to do
this is in my template and is right answer, with heaps of decimals: Code:
{vb:math {vb:math {vb:raw userinfo.field7}/2.2} / {vb:math ({vb:raw userinfo.field8}/100)*2}} |
You could try using the vb:number tag. It takes two arguments, a number and the number of decimal you want to display.
Or in the plugin you'd do something like: PHP Code:
and then in the template code: PHP Code:
|
thanks worked!! Also i was able to get that google pie chart to work, having some small sizing issues but hopefully figure that out soon.
|
All times are GMT. The time now is 04:13 PM. |
Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information | |
---|---|
|
|
![]() |
|
Template Usage:
Phrase Groups Available:
|
Included Files:
Hooks Called:
|