如何在 Embarcadero 的HTML5 Builder(Embarcadero® HTML5 Builder 版本 5.1.167.137)中更改MChart组件系列的颜色?在我的服务器移动应用程序中,我使用下面的代码从数据库中填充带有参数值的图表。我还创建了黄色的下限和上限线以及红色的下限和上限线。我的问题是我无法弄清楚如何更改黄色和红色系列,以便它们实际上是黄色和红色。
创建一个 Server Mobile 应用程序,在表单上放置一个 MChart,在页面 OnShow 事件中,使用以下代码:
function MPage5Show($sender, $params)
{
// set up y-axis from 0 to 100
$this->MChart1->Axes->Left->Automatic=false;
$this->MChart1->Axes->Left->Minimum=0;
$this->MChart1->Axes->Left->Maximum=100;
$yellowLoValues = array();
$yellowHiValues = array();
$redLoValues = array();
$redHiValues = array();
$values = array();
// yellow low and hi limits
$ylo=30;
$yhi=70;
// red low and hi limits
$rlo=20;
$rhi=80;
for ($i=0;$i<10;$i++)
{
// generate random values, " Y, X "
array_unshift($values, rand(0,100).','.$i);
$yellowLoValues[] = $ylo;
$yellowHiValues[] = $yhi;
$redLoValues[] = $rlo;
$redHiValues[] = $rhi;
}
// MChart1->Data takes array with values as "Y,X"
$this->MChart1->Data = $values;
$series1=$this->MChart1->addSeries(new TeeLine($this));
$series1->ColorEach = ceNo;
$series1->Values=$yellowLoValues;
$series1->Title="Yellow Low Limit";
$series1=$this->MChart1->addSeries(new TeeLine($this));
$series1->ColorEach = ceNo;
$series1->Values=$yellowHiValues;
$series1->Title="Yellow High Limit";
$series1=$this->MChart1->addSeries(new TeeLine($this));
$series1->ColorEach = ceNo;
$series1->Values=$redLoValues;
$series1->Title="Red Low Limit";
$series1=$this->MChart1->addSeries(new TeeLine($this));
$series1->ColorEach = ceNo;
$series1->Values=$redHiValues;
$series1->Title="Red High Limit";
}