所以我想這是一個比PHP更重要的數學問題,但我不知道它會去哪裏。所以我有一個電視節目網站,顯示每個用戶的收視率分佈。這裏可以看到兩個例子:http://broadcasted.tv/user/2/albertmarch/,這裏是http://broadcasted.tv/user/21/freshprincelive/。 這裏是我用來計算每一個此刻條的公式:PHP中的條形圖高度
$division = $scores[$i][1]/$countvotestotal;
//we divide the number of scores for each score (1 to 10) by the total number of score
$percentage = $division * 100;
$pixels = 180;
//max number of pixels
$pixelsactual = ($percentage/100) * $pixels;
$addthat = $percentage * 3.4;
//add some pixels to give more relief to the charts (otherwise, with many ratings, you end having bars between 10px and 20px)
$finalpixels = $pixelsactual + $addthat;
if ($finalpixels > 130) {
$finalpixels = 130;
}
//and this is a fix that I use, basically, if there is only one rating the biggest bar is gonna be huge (especially because of the $addthat var which add some px with a ratio to the final pixels value)
的問題是,一些圖表看起來狗屎(像第一型材),或不同的值有條大小像有相同http://broadcasted.tv/user/98/armchairtv/
任何建議將非常感激。由於
我檢查了一下,它很好,定製它使它看起來像我目前的圖表看起來像是一個巨大的屁股疼痛。但他們的酒吧高度很好,所以我會試着弄清楚他們是如何得到它的。 – Callombert