使用php的简单水平条形图

2021-12-24 00:00:00 graph php

我见过一个 facebook 应用程序,其中单击一个单选按钮会呈现一个图表.

如下图所示:

我想知道是否有任何类似的图形库可以在 php 中生成相同的图形.

谢谢,

潘卡伊

解决方案

实际上,生成这种图形很容易——只需使用两个 DIVs——一个是 100% 宽度的条,另一个DIV 是在第一个 DIV 中制作您需要的背景颜色 %.你甚至可以在其中包含文本.简单,只是简单的 HTML/CSS.

更新:

HTML:

<div class="percentage" style="width:66%">这是 66% 宽的 div</div>

CSS:

.bar { 宽度:99%;边框:1px 实心 #000;}.percentage { 背景:#000;}

I have seen a facebook application in which clicking on a radio button renders a graph.

As you can see below:

I wanted to know whether there is any similar graph library through which i can generate the same graph in php.

Thanks,

Pankaj

解决方案

actually, generating this kind of graph is pretty easy - just use two DIVs - one is a 100% width bar, another DIV is in that first DIV making background colored % you require. you can even include text in that. easy, just plain HTML/CSS.

UPDATE:

HTML:

<div class="bar">
    <div class="percentage" style="width:66%">This is 66% wide div</div>
</div>

CSS:

.bar { width: 99%; border: 1px solid #000; }
.percentage { background: #000; }

相关文章