ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  Gauge Charts
Posted by Ade Groves on Dec-13-2017 19:25
Attachments:
Has anyone put together a gauge chart that looks like the attached image ? If so, can anyone please provide sample code (preferably PHP).

Many thanks,

Ade
1.png

  Re: Gauge Charts
Posted by Peter Kwan on Dec-14-2017 02:24
Attachments:
Hi Ade,

I have attached an example for your reference. The guage is created as a donut chart with a label in the center.

Hope this can help.

Regards
Peter Kwan
donut.png
donut.php
<?php
require_once("../lib/phpchartdir.php");

# The percentage to display
$percentage = 65;

# The chart size
$size = 120;

$c = new PieChart($size, $size);

# Set the donut (x, y) center and the outer and inner radius
$c->setDonutSize($size / 2, $size / 2, $size / 2 - 2, $size / 2 - 12);

# Set the data to plot
$c->setData(array($percentage, 100 - $percentage));

# Set the colors for the donut
$c->setColors2(DataColor, array(0x888888, 0xeeeeee));

# Disable sector labels
$c->setLabelStyle("normal", 8, Transparent);

# Add the percentage text at the center
$c->addText($size / 2, $size / 2, $percentage . "%", "arial.ttf", $size / 5, 0x888888, Center);

# Output the chart
header("Content-type: image/png");
print($c->makeChart2(PNG));
?>

  Re: Gauge Charts
Posted by Ade Groves on Dec-14-2017 16:36
Great :) Many thanks Peter !