我正在使用库将图形添加到我的php代码中我只能将图标插入到图形中以便用户可以隐藏或显示图形可以有人帮助我吗?
班级图书馆https://github.com/fusonic/amcharts-php
更新
我的代码
function getData()
{
return array(
array(
"bolivia" => 989,
"argentina" => 7701,
"year" => 2000
),
array(
"bolivia" => 939,
"argentina" => 7209,
"year" => 2001
),
array(
"bolivia" => 894,
"argentina" => 2712,
"year" => 2002
),
array(
"bolivia" => 955,
"argentina" => 3413,
"year" => 2003
),
array(
"bolivia" => 1021,
"argentina" => 3997,
"year" => 2004
),
array(
"bolivia" => 1203,
"argentina" => 4740,
"year" => 2005
),
array(
"bolivia" => 1356,
"argentina" => 5490,
"year" => 2006
),
array(
"bolivia" => 1696,
"argentina" => 6630,
"year" => 2007
),
array(
"bolivia" => 1735,
"argentina" => 8231,
"year" => 2008
),
array(
"bolivia" => 1935,
"argentina" => 7674,
"year" => 2009
),
array(
"bolivia" => 1925,
"argentina" => 0133,
"year" => 2010
),
);
}
// Require necessary files
require("AmSerialChart.php");
// Create a new serial chart
$chart = new AmSerialChart("myLineChart");
// Set the path to the amcharts JS library
$chart->setLibraryPath(_WEB."js/amcharts");
// Set the X axes to represent the "year" field (optional)
$chart->setConfig("categoryField", "year");
// Use a chart cursor (optional)
$chart->setConfig("chartCursor", array("cursorPointer" => "mouse"));
// Add the data for the chart to use
$chart->setData(getData());
// Add 2 graphs
$graphConfigBolivia = array(
"balloonText" => "Bolivia: [[value]] $",
"title" => "Asia-Pacific"
);
$chart->addGraph("bolivia", $graphConfigBolivia);
$graphConfigArgentina = array(
"balloonText" => "Argentina: [[value]] $" ,
"title"=> "Asia-Pacific" );
$chart->addGraph("argentina", $graphConfigArgentina);
// Get the HTML/JS code
echo $chart->getCode();
答案 0 :(得分:0)
您需要在配置中设置图例属性。将$chart->setConfig("legend", array());
添加到您的代码中以启用基本图例。
您需要查看AmCharts documentation和demos以更好地了解JSON配置以及如何将它们映射到PHP类(或者只是直接使用JavaScript而且只能使用JavaScript使用PHP来检索你的数据。)