Sign in to follow this  
FusionCharts Support

Plotting with varchar

Recommended Posts

Hello All.

I'm trying to plot my inventory ..... stocktype (eg. Bearings, Motors etc) against quantity (from the same table), but the chart won't plot. I think it's because the chart only works with numbers. Is this true? So how can I plot how many bearings and motors I have without creating another table etc.?

Thanks.

Jamie.

Share this post


Link to post
Share on other sites

Thanks for the quick response.

I'm plotting from a database with MySql/PHP.

My table looks similar to this:

PartNumber   catagory quantity

1   bearing   4

2   bearing   5

3   bearing 15

4   motor     2

5   motor   6

6   belt 2

7   belt  5

I want a simple graph to show total quantities for each catagory.

I can do it if catagory was a number, but not as a word.

Can you help?

Thanks. Jamie.

Share this post


Link to post
Share on other sites

Hi,

  Already I gave you xml structure. Follow that structure.

here first need to sum of individual category by using sql i.e

Select category, sum (quantity) as Qty from table group by category

Then fetch this record and using loop put all data into an xml (already given xml structure).

further help please follow php sample code and documentation

Share this post


Link to post
Share on other sites

Thanks Arindam.

The XML structure you've given me is a static XML page. I'm trying to plot dynamically from a database table. I've done the SQL and it is plotting with the base line (catag) values as numbers (1,2,3 etc), but if I change these values to words (bearings, motors etc) then it won't return data to plot. Any ideas what I'm doing wrong.

I appreciate how frustrating it must be trying to guide people who don't know what they're doing but I've been struggling with this for 2 weeks now. Your help is much appreciated while I build an evaluation of your product.

Jamie.

Share this post


Link to post
Share on other sites

Hi Jamie,

Could you please go through the Documentation of similar example from our online Documentation? http://www.fusioncharts.com/docs? Section: Guide for Web Developers >> Using With PHP >> Plotting from Database or Creating Drilldown charts.

You would need to FOLLOW the XML structure that Arindam has sent you in earlier post, even while fetching the data dynamically from database. That XML was just an example of how your final dynamically generated XML might look like. 

In the XML the numeric values (sum) go to value attribute, while the category names go to label attribute.

You would need to iterate through all the records that your SQL fetches. While irerating you would need to build the XML string using string concatination.

<set label='{Your Category from each row }' value='{Your numeric Sum from each row}' />

If you find that you are unable to figure out the code in Documentation pages sepified, please let us know.

Edited by Guest

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this