S
S
seredaes2015-03-17 11:51:25
PHP
seredaes, 2015-03-17 11:51:25

How to build the graph shown in the picture?

5982caaefe5a4fe58321ec6c4aec8f44.png
The graph must be dotted, and so that projections fall onto the OX axis from these points. Just a grid in the background is not an option! All this will need to be inserted into the site.
I looked in Google, there are no such options, other libraries for plotting also did not offer such an option. Tell me, who knows?
-------------------------------------------------- -------------------------------------------------- ---------------------
I solved the problem with svg
Here is the result: sandbox.zz.vc/sandbox/graph

Answer the question

In order to leave comments, you need to log in

3 answer(s)
S
seredaes, 2015-03-17
@seredaes

Plotting is possible in 2 ways:
1. Using the GD library in PHP, then a couple of lines of code

header('Content-type: image/png');
  $image = imagecreatetruecolor(600,250) or die('Cannot create image');
  imagefill($image, 0, 0, 0xff8106);	

// 	Задаём толщину линии
  imagesetthickness($image, 2);

// строим линию по 4 координатам
  imageline($image, 0, 198, 100, 198, 0x000000);

But I did not like this option for 2 points:
a. When you zoom in, the picture blurs, setting large sizes is also not an option.
b. seemed cumbersome (although this is my subjective opinion)
2. The second option is using the SVG branch which is supported by modern browsers and even my Android mobile browser.
The pluses are that no matter how much you scale, everything looks great!!!
Code example:
<svg class="graph">
 <line x1='50' y1='20' x2='50' y2='350' stroke-width='1' stroke='#ffffff' />
</svg>

Result: sandbox.zz.vc/sandbox/graph

F
FanatPHP, 2015-03-17
@FanatPHP

Well, as an option - you can build points by hand in where.
Unless, of course, you didn’t skip math at school.

P
Peter, 2015-03-17
@petrtr

www.amcharts.com/demos/line-with-changing-color and it's full of options

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question