473,396 Members | 2,052 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

How to plot dymanic pie chart from text file?

Hi, is there anyway to make the file reader read the text file dymanic?

Here are the codes.
Expand|Select|Wrap|Line Numbers
  1. <?php
  2.  
  3.  // Standard inclusions   
  4.  include("pChart/pData.class");
  5.  include("pChart/pChart.class");
  6.  
  7.      $file = "C:\Log\NMS-Television2011101416.txt"; 
  8.  
  9.   $Tv = count(file($file)); 
  10.  
  11.   echo "$Tv";
  12.   $file = "C:\Log\NMS-Games2011101315.txt"; 
  13.  
  14.   $Games = count(file($file)); 
  15.  
  16.   echo "$Games"; 
  17.  
  18.   $file = "C:\Log\NMS-Film2011101416.txt"; 
  19.  
  20.   $Film = count(file($file)); 
  21.  
  22.   echo "$Film"; 
  23.  
  24.   $file = "C:\Log\NMS-Pulishing2011100714.txt"; 
  25.  
  26.   $Pulishing = count(file($file)); 
  27.  
  28.   echo "$Pulishing"; 
  29.  
  30.    $file = "C:\Log\NMS-Animation2011101116.txt"; 
  31.  
  32.   $Animation = count(file($file)); 
  33.  
  34.   echo "$Animation"; 
  35.  
  36.    $file = "C:\Log\NMS-Distribution_Media_Services2011101014.txt"; 
  37.  
  38.   $Distribution = count(file($file)); 
  39.  
  40.   echo "$Distribution";
  41.  
  42.    $file = "C:\Log\NMS-Broadcasting & Technology2011101315.txt"; 
  43.  
  44.   $Broadcasting = count(file($file)); 
  45.  
  46.   echo "$Broadcasting"; 
  47.  
  48.  // Dataset definition 
  49.  $DataSet = new pData;
  50.  $DataSet->AddPoint(array($Tv,$Games,$Film,$Pulishing,$Animation,$Distribution,$Broadcasting),"Serie1");
  51.  $DataSet->AddPoint(array("Television","Games","Film","Pulishing","Animation","Distribution","Broadcasting"),"Serie2");
  52.  $DataSet->AddAllSeries();
  53.  $DataSet->SetAbsciseLabelSerie("Serie2");
  54.  
  55.  // Initialise the graph
  56.  $Test = new pChart(800,500);
  57.  $Test->drawFilledRoundedRectangle(7,7,413,243,5,240,240,240);
  58.  $Test->drawRoundedRectangle(5,5,415,245,5,230,230,230);
  59.  $Test->createColorGradientPalette(195,204,56,223,110,41,5);
  60.  
  61.  // Draw the pie chart
  62.  $Test->setFontProperties("Fonts/tahoma.ttf",8);
  63.  $Test->AntialiasQuality = 0;
  64.  $Test->drawPieGraph($DataSet->GetData(),$DataSet->GetDataDescription(),180,130,110,PIE_PERCENTAGE_LABEL,FALSE,50,20,5);
  65.  $Test->drawPieLegend(400,15,$DataSet->GetData(),$DataSet->GetDataDescription(),250,250,250);
  66.  
  67.  // Write the title
  68.  $Test->setFontProperties("Fonts/MankSans.ttf",10);
  69.  $Test->drawTitle(10,20,"Number of View",100,100,100);
  70.  
  71.  $Test->Render("example10.png");
  72. ?>
Oct 28 '11 #1
12 2914
johny10151981
1,059 1GB
all file reading are dynamic.

What is your problem??
reading the file or creating the pie chart
Oct 30 '11 #2
@johny10151981
I want the program to find the file itself. For example, there is many type of files in the folder, sort by date, if i want to call a few file out it will auto be sort into the pie chart.
Oct 31 '11 #3
omerbutt
638 512MB
HI SEAN ,
why dont you store the name/path of the file somewhere and retrieve it at the time of reading it .
regards,
Omer Aslam
Nov 2 '11 #4
@omerbutt
Those text file is save in a folder but i have no idea how to retrieve it dynamic.
For example, i need a from today and ytd files it will automatically those text file in and generate the chart.
Nov 2 '11 #5
omerbutt
638 512MB
weel what i am getting from your reply is that,
the file is saved inside a folder. But is the system saving the file? or the file is saved by some person or you manually? , if the system is saving the file means there is another process that writes the data inside a file and saves it then you need to save the name of the file inside the db and retrieve it later, if i didnt get you right , do correct me .
regards,
Omer Aslam
Nov 2 '11 #6
@omerbutt
Yeah you are right, the file is saved inside a folder by a system, it records the number of use of a program per hourly and name the file in YYYYMMDDHH format. It is not acutally a db, a folder rather.

Now i got to do is get those files from the folder based on the file name automatically, for example i want file from 2pm to 6pm, then those file will be place in the code automatically and generate into a pie chart.
Nov 2 '11 #7
omerbutt
638 512MB
you need to have some thing to track the filenames as you said you need the file of 2pm to 6pm then why not use the
Expand|Select|Wrap|Line Numbers
  1. filemtime()
  2.  
to track which files were written at the given time
see the manual here

you can even look at the
Expand|Select|Wrap|Line Numbers
  1. filectime()
  2. stat()
  3.  
on the given link
regards,
Omer Aslam
Nov 2 '11 #8
@omerbutt
ya i do need to track the files i need and extract it to generate a pie chart.
Nov 2 '11 #9
omerbutt
638 512MB
did it worked out for you sean , do ell me when you are done with it , or in case you got some problem
reagrds,
Omer Aslam
Nov 2 '11 #10
Ok i am still trying it out, will get back to you tmr. Thanks for the help!
Nov 2 '11 #11
Based on what i have learn so far, i still have to hard code in the textfile myself. My requirement doesn't allow me to do that, it will generate file every hour when the program start running.

Correct me if i'm wrong, Thanks.
Nov 3 '11 #12
omerbutt
638 512MB
Hi
cant you have a cron job type something that would trigger to save the file name when the file is created?........if its a local computer the you can use scheduler and remote mysql connection to update the live db .......are you getting what i am trying to say ?
regards,
Omer Aslam
Nov 10 '11 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: David Thomas | last post by:
Hi there, a while ago, I posted a question regarding reading japanese text from a text file. Well, since I solved the problem, I thought I'd post my solution for the benefit of other people with...
1
by: Rigga | last post by:
Hi, I am new to Python and need to parse a text file and cut parts out i.e. say the text file contained 5 rows of text: line 1 of the text file line 2 of the text file line 3 of the text...
6
by: Suresh Kumaran | last post by:
Hi All, Does anybody know the sytax in VB.NET to write the contents of a multiline text box to a text file? Appreciate help. Suresh
1
by: Eilsa | last post by:
I have a text file which is UTF-8 encoding. How can I read it from the ASP? Thanks
40
by: googler | last post by:
I'm trying to read from an input text file and print it out. I can do this by reading each character, but I want to implement it in a more efficient way. So I thought my program should read one...
60
by: Julie | last post by:
What is the *fastest* way in .NET to search large on-disk text files (100+ MB) for a given string. The files are unindexed and unsorted, and for the purposes of my immediate requirements, can't...
3
by: Krish | last post by:
I have requirement, that i get one big chunk of text file. This text file will have has information, that on finding "****End of Information****", i have to split them individual text file with our...
7
by: Chris | last post by:
Hi I can use a text file as a datasource but am unable to get the datatable to see the text file as having multiple columns. Everything gets put into the first column in the datatable. Sample of...
3
by: Leszek | last post by:
Hello! Is there any possibility to load a datagridview from a text file? I have *.tsv file with performance counters and I'm trying to create a webpage (or Windows application), that will show...
10
by: bluemountain | last post by:
Hi there, Iam new to python forms and programming too I had a text file where i need to extract few words of data from the header(which is of 3 lines) and search for the keyword TEXT1, TEXT2,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.