Chart plotting algorithms? - php

I am looking to plot charts using the PHP image create, what kind of algorithms are used to transform my terrible chart:
Into something better like:
and
How can I make the lines of my chart smooth and pretty like the 2 charts above?
edit: I don't want to use any library, I am trying to do this myself.

Try this best think, I use these charts all the time
http://www.highcharts.com

For "smoothing the lines", you have to refer to external sources about antialiasing (or let PHP do this part, see manual)
Then, you need to have an idea how exactly your graph should look like:
axis (scaling, labeling, ...)
grid (with differend line width for major and minor segments?)
representation of data (points, straight lines, smooth lines [getting rather hard again here])
description
And I think each point could be a quite well suited coding exercise. But without more specific questions, I can't help you better.

Related

Add windy.js on leaflet map as a layer

i want to add wind data on my leaflet map as a layer
wind data like this https://danwild.github.io/leaflet-velocity/
I've been working on something similar. I found a pretty good looking
and intuitive method being used to represent vector information. Have
a look at the following examples:
http://earth.nullschool.net/
http://hint.fm/wind/
http://air.nullschool.net/
http://googlemapsmania.blogspot.com/2014/07/the-growth-of-slippy-wind-map.html
In my case, I still need to find a suitable format for the wind/ocean
data I want to plot on my Leaflet map. It's certainly not a quick fix,
but man, it looks great!
Maybe this can help you too. I hope to be able to post a working
solution soon.
This plugin takes input data in form of speed in knots (nautical miles
(1.852 km) per hour) and direction in degrees. It then generates the
wind barbs and outputs an icon. This icon can easily be added to a
Leaflet marker.
You can download it here:
https://github.com/JoranBeaufort/Leaflet.windbarb And you can see a
live example here: http://www.geonet.ch/leaflet-windbarb/

Generate countries map based on geoip data

I have searched a lot on this topic, and have found no answers.
I have my own statistics package where I'm saving the geoip data of my users (along with a bunch of other data). I'm using the maxmind geoip library to get this information.
So, in my backend I'm visualizing this data as text that have basically two columns, one for the country name and another for the number of visits from the country.
I'd like to generate a map with this data.
something like a world map with the countries I have visits from highlighted.
Heat mapping would be nice, but not required.
I dont really care if it's generated with php (GD image library) or jquery, since I'm already using both those technologies for the statistics backend. But I'd REALLY like to do this without google analytics or their graphing APIs.
I will try to suppose. The way I would try do it ...
Get FullHD (or HighRes world map)
Coordinates I'd keep in WGS84 standard (float values, otherwise it is easy to convert)
I would try to approach real coordinates to the scale of image, but before this ...
The major part in this work is Math. I'm actually not a mathematician, but I know that it should be applied here and why.
Main goal here is to project coordinates on a flat surface, bec. WGS84 uses oblate spheroid as a reference surface (with radius = 6378137 m; flattering = 1/298.257223563), so it is not ideal circumference and it should be taken into account. + image should be GEO binded somehow (you should know coordinates of corner angles of this image #least. it is the easiest case if so).
Calculations for this case are not very massive, everything leads to the elementary plane geometry.
Here is the library that could help you working with geospatial data http://www.gdal.org/.
My advice to you, to consult some specialists in this field if you know nothing about it (maybe SatCom spec. or MobCom spec. in some university/academy) (or try Google if you are familiar enough with math and GEO) and to ask for a math model for projection of GPS coordinates to the flat surface and you will definitely get the answer.
If you don't need very high accuracy, try it yourself maybe you'll have luck.
You can try yourself in MatLab (more applicable in this case) or Mathcad if you know math enough and try yourself to position few points on the raster.
If you will find the answer in the nearest future, I would be glad if you post it here or share with me your solution for the particular case.
i need to finally answer my own question here. for anyone else who stumbles across this:
i have been using the d3js library with the topojson extension.
https://github.com/mbostock/topojson

php: library for drawing this specific graph

I would like to ask you if you know any concrete library that is capable of drawing graph like:
so this is variation of something I would call "doube bipartitiate graph". Vertical lines just illustrate columns and i do not mean to draw a graph that look like sequence graph - just all nodes should lay somewhere on them. This picture illustrates what I mean:
The only thing we have found so far is js.graph but it seems like it is a lot of work to make it look like it. Also, google charts does not seem appropriate. Any ideas?
check this graph may be useful
Thanks

Use GD or any other php library to build a workflow

I am developing a sports website that would be keeping a record of all tournaments in tennis, football and rugby. Now my database structure is built to hold who plays who in which tournament, so it would just be a select to display all the information. The type of workflow that I am talking about is the one that is commonly used in the sports arena where players' names are listed head to head, and the level of that match(knockout,quater final, semifinal, etc.) are also listed. I do not know the correct term for this though. I will give you an example for how it would look.
I am sure this is possible by using web technology, I am just finding it hard on where to start. Any advice or suggestions are much appreciated. Also if there are any libraries I could use for this, that would be immensely helpful.
Depending on how you want to format the information you should be able to do it in a few ways.
You could use GD like you mentioned but that may be a bit tedious once you get larger and larger brackets. (I don't have a lot of exp. with GD but I know the basics)
I have implemented a 256 person ladder or bracket using html and css. This proved to be pretty simple to do and it should be able to scale easily and be easy to make changes to.
Well on a first glance I would see the following data:
Teams
Cups (having Rounds)
Rounds (of Matches)
Matches (of Teams)
You could model that into a relational database, e.g. MySQL.
You can then create models in classes for your application, e.g. in PHP.
You can then create a Web UI to display the data you've entered into the database. You can use GD for that (if it's a need, I think HTML is not that bad for that, would do it with simple text based output first before turning everything into an image).
Maybe that's helpful. Was a bit lengthy for a comment, so I added it as an answer.

How can I create a list catalouge page for my website, without shopping cart/detailed product page functions

I want to make Newegg's like catalouge functionality for my little website. I want mine to be sligthly different(greatly simplified) though. I haven't done anything so advanced(atleast in my books) before, and wanted to know if it's possible to do. I want to use PHP and JS. The new records will be added manually through using either phpMyAdmin or pehaps I will install and use either SQLyog, HeidiSQL or Navicat for such purposes. Could someone point me to the right resources to get this kind of job done as fast as possible and properly?
What I had in mind was:
For example the cell which contains the thumbimage, all the mini information about the product and the big price tag will not have a separate, more detailed page. Everything user will need to know will be inside that product cell.
Right under the thumbnail image there will be numbers(1 2 3 4 5 6), and when you hover over them, under the cursor, a big version of one of the all available images will appear.
Lastly, it should have the page generation(don't know what you call it). For example there's more than 20 product entries on the page, then the server should create a new page(First 1 >2< Last) to hold the older records.
Oh and there won't be any shopping cart functionality. You can't really "order" these kinds of products, you just find something you like and call me up about it.
TIA
I'm sure there are dozens of books on this subject. I'm attempting a short reply, however:
This sounds like something that could profit from:
a MCV-framework like CakePHP (or Django, Ruby on Rails etc), which could handle database-logic (including pagination, which is the word you're looking for), and
a JavaScript library like JQuery to handle Ajax, JavaScript and other UI-related stuff.
++?
For the page numbers, I recently had to do this. The technique is called pagination, and this thread helped me out immensely: PHP Formula For a Series of Numbers (Mathy Problem)
The thumbnail effect you want to include would need to be done in javascript. I'd recommend learning jQuery, as it is pretty easy to use for this sort of thing.
This is a hard question to answer because you haven't given much indication as to your skill level, or progress towards accomplishing your goal. Assuming we're starting at 0, there is probably more to discuss than this thread can contain. :\
UPDATE
To learn PHP's database functions, I would lean on W3School's PHP/MySQL tutorial for a quick summary, referring to the php manual's mysql documentation for details and code examples when W3schools isn't enough. This should at least get you the markup you will need to work with.
For the thumbnails, I would reiterate my recommendation for jQuery, specifically attaching a .hover() event to the image numbers (this is equivalent to the onmouseover and onmouseout events in JS) that uses the .fadeIn() and .fadeOut() animations to show and hide your full size images. Hope that helps.

Categories