Go Back   vb.org Archive > vBulletin 4 Discussion > vB4 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 12-16-2014, 03:49 PM
gfran5's Avatar
gfran5 gfran5 is offline
 
Join Date: Nov 2014
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default 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/
Reply With Quote
  #2  
Old 12-16-2014, 06:11 PM
HM666's Avatar
HM666 HM666 is offline
 
Join Date: Jan 2014
Location: Little Rock, AR
Posts: 1,060
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #3  
Old 12-16-2014, 07:06 PM
Dave Dave is offline
 
Join Date: May 2010
Posts: 2,583
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.)
Reply With Quote
  #4  
Old 12-16-2014, 11:29 PM
gfran5's Avatar
gfran5 gfran5 is offline
 
Join Date: Nov 2014
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #5  
Old 12-17-2014, 10:19 AM
ozzy47's Avatar
ozzy47 ozzy47 is offline
 
Join Date: Jul 2009
Location: USA
Posts: 10,929
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #6  
Old 12-17-2014, 10:24 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Quote:
Originally Posted by gfran5 View Post
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?
Reply With Quote
  #7  
Old 12-17-2014, 11:42 AM
gfran5's Avatar
gfran5 gfran5 is offline
 
Join Date: Nov 2014
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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.
Reply With Quote
  #8  
Old 12-17-2014, 11:55 AM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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:
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <
script type="text/javascript">

      
// Load the Visualization API and the piechart package.
      
google.load('visualization''1.0', {'packages':['corechart']});

      
// Set a callback to run when the Google Visualization API is loaded.
      
google.setOnLoadCallback(drawChart);

      
// Callback that creates and populates a data table,
      // instantiates the pie chart, passes in the data and
      // draws it.
      
function drawChart() {

        
// Create the data table.
        
var data = new google.visualization.DataTable();
        
data.addColumn('string''Topping');
        
data.addColumn('number''Slices');
        
data.addRows([
          [
'Mushrooms'3],
          [
'Onions'1],
          [
'Olives'1],
          [
'Zucchini'1],
          [
'Pepperoni'2]
        ]);

        
// Set chart options
        
var options = {'title':'How Much Pizza I Ate Last Night',
                       
'width':400,
                       
'height':300};

        
// Instantiate and draw our chart, passing in some options.
        
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
        
chart.draw(dataoptions);
      }
    </
script>
    <
div id="chart_div"></div
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.
Reply With Quote
  #9  
Old 12-17-2014, 12:38 PM
gfran5's Avatar
gfran5 gfran5 is offline
 
Join Date: Nov 2014
Posts: 21
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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">
<vb:if condition="$post['field8']">
<h2 style="display: inline;">H: {vb:raw post.field8}cm |&nbsp</h2> 
<vb:else />
<h2 style="display: inline;">H: -- |&nbsp</h2>
</vb:if>
<vb:if condition="$post['field7']">
<h2 style="display: inline;">W: {vb:raw post.field7} Lbs</h2>
<vb:else />
<h2 style="display: inline;">W: -- </h2>
</vb:if>    
</div>
Reply With Quote
  #10  
Old 12-17-2014, 12:47 PM
kh99 kh99 is offline
 
Join Date: Aug 2009
Location: Maine
Posts: 13,185
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

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');
$templater->register('selected_tab', $selected_tab);
$templater->register('test_tab_content', $test_tab_content);
$templater->register('userdata', $prepared);
$template_hook['profile_tabs'] .= $templater->render();
(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.
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 11:22 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
  • Page Generation 0.07255 seconds
  • Memory Usage 2,294KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_html
  • (1)bbcode_php
  • (2)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (2)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete