fetch data from php for canvas js - php

ok so the thing is i need to create charts and i found canvas js, which looks promising, problem is i have the website on php and i dont know how to give data to the charts from php to jquery to charts, basically how to feed it from mysqli database and php with jquery.
i didnt find any explanation on the main website and its chatbot want my number straight away so no use.
this is my 2nd question so if this is not the right question to ask without any code, i am sorry, ill take care of it in the future. but i dont have any code cause i dont know where to start. with php to fetch data. and feed it to the chart through jquery.

Code-Samples for rendering chart with data from datababse is readily available in CanvasJS gallery section. You can even download working sample from download page, which you can run in your local machine directly.
If you still unable to make it work or facing issue, share the code with brief of the issue you are facing so that the community can help you!

Related

Create Google Drive Document template from HTML and CSS

I've been implementing a google drive connector into a web application.
Basically when a known event is triggered in the page it launches a webhook which communicates with the 'drive-connector' in order to generate a document and fill it with some information.
This 'drive-connector' is a custom PHP which uses the Google Drive API to create folders and files. I am able to create the folders and files and give the files the desired content.
To give the content to the drive document I use an HTML template (https://developers.google.com/drive/api/v3/manage-uploads) which is allowed by the API, before uploading it I change some variables inside the template with the data that comes from the webhook, all well for now.
The problem
I'm able to upload the HTML document, once I replace the variables for the desired data, but It has to be very simple and without much css. When I try to upload the document from a more worked and beautiful template Google Drive doesn't recognize many CSS and it changes the appearence of the document. I can't put a header nor a footer. Many fields are moving from its places and making a mess of the whole document.
In order to make it easier for me to replace the variables in the template I choosed to use HTML anyways I'm starting to think that would be easier to use a .doc or .odt template ( I would need to use a library in order to do that )
My question
Is good to use an HTML document as template for the google drive document? Or should I change the way I am trying to achieve this?
Thanks in advance
Observation: Since I don't really have problem with my code I haven't put any line of code, how ever If you need the HTML template to guess if it has any problem, just tell me.
EDIT 1 -> I've found this: How can developers edit a Google Doc programmatically? Is there a Docs API?
It is not the answer of my question but seems to have some solutions to my problem. Anyways I don't get much clear in that post, I haven't found the proper documentation so I'm still fighting to get this.
EDIT 2-> Reading again the documentation I thought that I could make the document firstly in the google drive and then using the API download it as HTML, this way I would have the template but I'm not sure if I could modificate it has I wish. If this works I will reply my own question and close the post
After trying this I could not upload the HTML which was exported from the google doc. The error that the google api gives me is: code 400 message: bad request
Finally I could find a work around!
Anyways It is not a very effective and good way of doing it.
As I explained in my EDIT 2, I tried to download a google drive document created in google drive by hand and export it has HTML, so I had the template in HTML. Then I added my variables for future dynamic replacements and everything works more or less fine.
I solved the problem of the bad request modifying a bit the document, seems like you cannot have exacly the same document twice in the drive, after changing some lines of code It started to work.
Anyways I don't feel like this is a definitive and fine way of doing what I want so I will keep the post open for if somebody knows a better way of achieving this.

PHP: Generating PDF by fetching data from database

I Have just started to learn PHP. As a task,
I submitted a form which sent the values to the MySQL database, Now, I want to fetch these values from the database and display it in a letterhead format and then have to output that letterhead as a PDF file.
Please suggest me a way to do that from the basic level, I tried to follow 1-2 questions here but couldnt get any results. I need a step-by-step procedure...
Thanks in advance!
Your work can't be done by us. so please search and research again. PHP itself provides a good way to generate pdf. If you don't like it you can go for a library such as fpdf.
You should google it first. try some code. Then you will get most errors. If you can't find a solution for that errors. You can post a question seeking help. We can help you.
Here is the link for Php pdf documentation
Here is the link for fpdf php library website

Drawing graphs in PHP or HTML

I'm looking for quite a specific technique.
The short of it:
I need HTML which can generate a line chart, as shown below (but without the background image. That is totally irrelevant)
However, I want to make it in HTML, without Javascript or Flash and in a way that the dots can be hovered to show more information.
The long of it:
The image shown above comes from the website jpgraph.net. That is a PHP library for creating charts. The downside of that however, is that it generates images. Since you have no clue of knowing where the dots are going to end up, you can't estimate where the hovers should be made.
Ofcourse there are also loads of javascript ways of doing this, but the graph should also work without javascript.
Flash is out of the question, since it should also work on tablets (read iPads)... And because it is flash...
All the information shown in the graph is generated by an external system. That means that the code should work and change the graph, depending on the information put in there.
EDIT:
I'm aware of the fact that it is easily done with javascript, and my fallback would be to offer a javascript version and as a fallback the php version. However, I'm hoping to find a way which doesn't need a fallback. Using 1 script to do the same task would be better than using two.
You should check out Charts.js by Nick Downie.
It has simple HTML5 Charts using the canvas element -
Charts and Graphs Included:
Bar Chart
Doughnut Chart
Line Graph
Pie Chart
Polar-area Chart
Radar Chart
Read the documentation here: http://www.chartjs.org/docs/
and download on GitHub here: https://github.com/nnnick/Chart.js
Hope I Helped
For those still interested: I fixed this using the jpgraph.net library. It's a php library which allows you to draw graphs on the server using data you get from somewhere else.
As enhzflep pointed out, since you have the data, you can calculate where the points will end up. This is however, quite a tedious job, but it's working in javascript-less browsers.

Flash or JQuery or Other Graph Visualization

I have two basic bar charts and I am currently using XML/SWF Charts which is great but the problem I have is I need to be able to send these graphs via email to the user. As well as display them on the site.
I know sending Flash is a bad idea, I would love to find a way to convert my current graphs to an image, but am pretty certain there is no quick fix without building a work around myself.
Therefore what are the best open source or closed solutions for this problem.
I need to be able to display two graphs dynamically and then email them to users.
Any advice is appreciated.
You may want to check out the "Google Image Chart Api" (not to be confused with the Google Chart API).
http://code.google.com/apis/chart/image/
It allows you to generate numerious different types of charts just from the URL.
For example:
https://chart.googleapis.com/chart?cht=p3&chd=t:60,40&chs=250x100&chl=Hello|World
That URL could also be put into an HTML e-mail.
Alternatively, looking at this stackoverflow quesiton FLASH save frame, to image (tiff, bmp, jpg, gif, png)
If you can modify the flash movie. It appears that you can save frames in AS3 via BitmapData. So you may be able to send the data back to the server for processing (emailing). But I can't vouch for this as I haven't tried it.
jqPlot seems pretty good. Piwik uses it. http://www.jqplot.com/
I would recommend using gRaphael. It is a javascript library for rendering graphs using svg(or vml for IE8 and below). I've personally use it and it is quite good.
This probably won't work for you since you're not running .net, but for anyone else who's looking for resources for generating charts there's the MS Chart controls.

Copying specific data from a website to excel

A friend of mine has asked me to figure out a way of getting information from a website and putting it into an excel file.
This is the website in question: http://www.manta.com/world/North+America/Canada/Newfoundland/grocery_stores--B619B/#Location
He wishes to have an excel file with a list of all the names, addresses and phone numbers of all the results of his search.
So far I'm stumped in coming up with an idea. I'm fairly new to internet programming.
I was thinking that maybe I could create a greasemonkey userscript which would search for all the required data on the page and at the click of a button open a pop-up which would have the data in CSV format which could then be copied and pasted into excel. However the phone numbers aren't on the search results page so I don't think this is possible.
My second thought was to create a webpage that would search that site and get all the required data, then provide a "Download data to Excel" option.
Are these ideas possible and how would I best go about doing them? Is there a better way?
Thanks!
This would be easier to answer if we know what languages you're familiar with.
Assuming windows this can be done using jscript or vbscript on WSH using WinHttpRequest , excel may be accessed via ActiveX. If you need a UI i would suggest HTA.

Categories