一:配置
1. 创建一个smarty文件夹
2. 将下载的包lib文件夹拷到下面
3. 在smarty下创建templates文件夹
4. 在templates文件夹下面分别创建 cache config templates templates_c四个文件夹
5. 在templates文件夹下创建你的tpl模板文件
6. 在php中引入lib下面的smarty.class.php文件,在php中指定相关的目录就可以使用了。
代码展示:
$smarty->template_dir="smarty/templates/templates";
$smarty->compile_dir="smarty/templates/templates_c";
$smarty->config_dir="smarty/templates/config_dir";
$smarty->cache_dir="smarty/templates/cache";
二:linux下运行
这其中有几个文件夹需要读写权限所以使用chmod命令将四个文件夹得权限改为777就可以了。
chmod 777 file 或者 chmod -R 777 fold
三: 如何指定X轴的内容
代码展示
$Dataset->addPoint(数组,"serial4");
$DataSet->SetAbsciseLabelSerie("Serie4");
这样就会创建一个一数组为x轴内容的图表,但是要注意数组内容不能是数字,否则还是会以数据的格式显示。
四: 如何显示百分数
首先使用string_format对数字进行格式化,在利用cat方法进行字符串拼接。
示例代码:
($percentage|string_format:"%2f")//保留两位小数显示
(($percentage*100|string_format:"%2f")|cat:'%')//乘以100后连接一个"%"