I am currenty working on a project using phplot for reporting purposes.
To keep long things short, I need to display a dynamic number of companys each
one in a single plot on the same page. So I have n plots, depending on how
many companys are currently acitve.
I worked all my way through and everything looks just fine. But than I noticed
that there might be an issue while calculation the size of the total image. So
I am facing two problems:
Eighter some text on the x-axis is getting cut or even some parts of the actuall plot
Or there is a lot of white space beneath the last plot. (So the overall plot size is to high)
Jesus, I hope you get the point.... :-/
I just found a work around and added some if-statements to determine how many
plots I need to display and then I am correcting the hight of the image...
What I found out is that the global size of the image needs to be reduced till
I have at least 5 plots. After that is seams to be stabil. But I am not
getting why??
Here is my code for the global and plot size:
if($num_getlfdfirmennr=='1'){$plot_y=$num_getlfdfirmennr*350;}elseif($num_getlfdfirmennr=='2'){$plot_y=$num_getlfdfirmennr*320;}elseif($num_getlfdfirmennr=='3'){$plot_y=$num_getlfdfirmennr*310;}elseif($num_getlfdfirmennr=='4'){$plot_y=$num_getlfdfirmennr*305;}else{$plot_y=$num_getlfdfirmennr*300;}$plot=newPHPlot(950,$plot_y);/***** PLOT POSITION *****/$xStart=60;$yStart=75;$xEnd=930;$yEnd=325;/***** END - PLOT POSITION *****///Disableauto-output:$plot->SetPrintImage(0);for($y=1;$y<=$num_getlfdfirmennr;$y++){//BUILDPLOTS#Setupareaforfirstplot://$plot->SetPlotAreaPixels(60,70,930,350);if($y==1){$plot->SetPlotAreaPixels($xStart,$yStart,$xEnd,$yEnd);}else{->Thisisthedistancebetweentheplotswhilehavingmorethanoneplottobegenerated$xStart=60;$yStart=$yEnd+40;$xEnd=930;$yEnd=$yEnd+290;$plot->SetPlotAreaPixels($xStart,$yStart,$xEnd,$yEnd);}
I really hope anyone knews about this or maybe there is a little bug in the
calculation itself... I don't know...
I know it is very hard to understand what I am trying to say but I can explain
it in more detail if you want/need or also give you a link to a website.
Thank you so much for you time!
Ingo
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Sorry, it seams I messed up with the code tag... again:
if($num_getlfdfirmennr=='1'){$plot_y=$num_getlfdfirmennr*350;}elseif($num_getlfdfirmennr=='2'){$plot_y=$num_getlfdfirmennr*320;}elseif($num_getlfdfirmennr=='3'){$plot_y=$num_getlfdfirmennr*310;}elseif($num_getlfdfirmennr=='4'){$plot_y=$num_getlfdfirmennr*305;}else{$plot_y=$num_getlfdfirmennr*300;}$plot=newPHPlot(950,$plot_y);/***** POSITIONIERUNG DER DIAGRAMME *****/$xStart=60;$yStart=75;$xEnd=930;$yEnd=325;/***** POSITIONIERUNG DER DIAGRAMME *****///Disableauto-output:$plot->SetPrintImage(0);for($y=1;$y<=$num_getlfdfirmennr;$y++){//DIAGRAMMEAUFBAUEN#Setupareaforfirstplot://$plot->SetPlotAreaPixels(60,70,930,350);if($y==1){$plot->SetPlotAreaPixels($xStart,$yStart,$xEnd,$yEnd);}else{$xStart=60;$yStart=$yEnd+40;$xEnd=930;$yEnd=$yEnd+290;$plot->SetPlotAreaPixels($xStart,$yStart,$xEnd,$yEnd);}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I'm pretty sure you just have a small error in calculating the size and plot
area. It's hard to tell because (I think) you posted a version that you fixed
up to work, rather than the one that doesn't work. But if I take out the IF
statements and just leave
$plot_y = $num_getlfdfirmennr * 300;
for all the cases, then I see that the image grows 300 pixels for each new
plot, but the plot area (SetPlotAreaPixels) only grows by 290 for each plot
($yEnd += 290). So it will start squishing out your plots and leave a lot of
empty space at the bottom.
Remember that the plot area is smaller than the image size, but the Y limits
of the plot area must still increase by the same amount as the image grows.
Depending on how many plots need to be drawn I need to fix the overall image
height with the if statements, otherwise there is eighter not enough or way to
less space. All plot have the exact same height an starting position but for
some reason the overall image height needs to be ajusted every time.
I also figured out that this is only needed for the first 5 plots! After that
every plot is drawn perfect using an increase of 300px for each plot.
I don't know how to explain otherwise :-/ I also calculated the sizes by hand
verything looks ok the way I am doing it. Yesterday I checked it over and over
again an tested it out but the only way to get it drawn correctly was to build
up this IF statements.
If will check out the thread you mentioned above! Thank you!
If you might have any additional idea!?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Here's how I do it. These are pieces taken from a PHPlot test script I use.
(Hope this helps. There is nothing special about the first 5, just the first 1
needs extra space above it for the overall title.)
Part 1: Setup
$n_plots = 8; // Number of plots to draw
$height_of_each_plot = 300; // Plot area height for of each plot
$title_space = 50; // Space at top of first plot, for overall title
$space_below_plots = 60; // Space below each plot, including axis label
Part 2: Calculate image size and create PHPlot object:
$y1=$title_space;// Top of plot area$y2=$y1+$height_of_each_plot;// Bottom of plot areafor($i=0;$i<$n_plots;$i++){$plot->SetPlotAreaPixels(80,$y1,740,$y2);...Setupanddrawtheplothere...$y1=$y2+$space_below_plots;// Step to next plot position$y2=$y1+$height_of_each_plot;// Step to next plot position}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
This BBcode stuff is really annoying... two tries to post that and it is still
messed up. The Part 3 "code" marker got lost somehow. Trying one more time:
Part 3: Loop creating plots:
$y1=$title_space;// Top of plot area$y2=$y1+$height_of_each_plot;// Bottom of plot areafor($i=0;$i<$n_plots;$i++){$plot->SetPlotAreaPixels(80,$y1,740,$y2);...Setupanddrawtheplothere...$y1=$y2+$space_below_plots;// Step to next plot position$y2=$y1+$height_of_each_plot;// Step to next plot position}
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I just copyed your code and edited it just a little bit to fit my width and it
is just awesome! Now every plot looks perfect without having these IF-
statements to correct my messed up calculation... If just tested it with 1 up
to 13 plots and all of them look exactly the same growing the way they should!
I can't thank you enough for you help! If I have a minute I will try to figure
out what the problem with my code is... I quess it might be something around
the plot height + bottom area. Especially if there is no title (plot 2 to n)
:-/ hmmm...
Again thank you very much for your kind support! I love working with PHPLOT so
much :-D
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hey guys,
I am currenty working on a project using phplot for reporting purposes.
To keep long things short, I need to display a dynamic number of companys each
one in a single plot on the same page. So I have n plots, depending on how
many companys are currently acitve.
I worked all my way through and everything looks just fine. But than I noticed
that there might be an issue while calculation the size of the total image. So
I am facing two problems:
Jesus, I hope you get the point.... :-/
I just found a work around and added some if-statements to determine how many
plots I need to display and then I am correcting the hight of the image...
What I found out is that the global size of the image needs to be reduced till
I have at least 5 plots. After that is seams to be stabil. But I am not
getting why??
Here is my code for the global and plot size:
I really hope anyone knews about this or maybe there is a little bug in the
calculation itself... I don't know...
I know it is very hard to understand what I am trying to say but I can explain
it in more detail if you want/need or also give you a link to a website.
Thank you so much for you time!
Ingo
Sorry, it seams I messed up with the code tag... again:
I'm pretty sure you just have a small error in calculating the size and plot
area. It's hard to tell because (I think) you posted a version that you fixed
up to work, rather than the one that doesn't work. But if I take out the IF
statements and just leave
for all the cases, then I see that the image grows 300 pixels for each new
plot, but the plot area (SetPlotAreaPixels) only grows by 290 for each plot
($yEnd += 290). So it will start squishing out your plots and leave a lot of
empty space at the bottom.
Remember that the plot area is smaller than the image size, but the Y limits
of the plot area must still increase by the same amount as the image grows.
This older thread might help too: https://sourceforge.net/projects/phplot/for
ums/forum/46382/topic/1827868
Sorry, "plot area only grows by 290 for each plot" should be: "plot area
position only increases by 290 for each plot."
Sorry for posting my "fixed" code... It is a little strange... assume there is
just one plot, what I do is the following:
which is absolutly ok! It may be because of the title within the plot that I
need a little more height.
If there are two plots I need to do this:
The thrid plot goes like:
Depending on how many plots need to be drawn I need to fix the overall image
height with the if statements, otherwise there is eighter not enough or way to
less space. All plot have the exact same height an starting position but for
some reason the overall image height needs to be ajusted every time.
I also figured out that this is only needed for the first 5 plots! After that
every plot is drawn perfect using an increase of 300px for each plot.
I don't know how to explain otherwise :-/ I also calculated the sizes by hand
verything looks ok the way I am doing it. Yesterday I checked it over and over
again an tested it out but the only way to get it drawn correctly was to build
up this IF statements.
If will check out the thread you mentioned above! Thank you!
If you might have any additional idea!?
Here's how I do it. These are pieces taken from a PHPlot test script I use.
(Hope this helps. There is nothing special about the first 5, just the first 1
needs extra space above it for the overall title.)
Part 1: Setup
Part 2: Calculate image size and create PHPlot object:
Part 3: Loop creating plots:
This BBcode stuff is really annoying... two tries to post that and it is still
messed up. The Part 3 "code" marker got lost somehow. Trying one more time:
Part 3: Loop creating plots:
I just copyed your code and edited it just a little bit to fit my width and it
is just awesome! Now every plot looks perfect without having these IF-
statements to correct my messed up calculation... If just tested it with 1 up
to 13 plots and all of them look exactly the same growing the way they should!
I can't thank you enough for you help! If I have a minute I will try to figure
out what the problem with my code is... I quess it might be something around
the plot height + bottom area. Especially if there is no title (plot 2 to n)
:-/ hmmm...
Again thank you very much for your kind support! I love working with PHPLOT so
much :-D