dualxaxis.php
Back to Chart Graphics
setPlotArea(50, 50, 200, 200);
# Add a title to the primary (left) y axis
$c->yAxis->setTitle("US Dollars");
# Set the tick length to -4 pixels (-ve means ticks inside the plot area)
$c->yAxis->setTickLength(-4);
# Add a title to the secondary (right) y axis
$c->yAxis2->setTitle("HK Dollars (1 USD = 7.8 HKD)");
# Set the tick length to -4 pixels (-ve means ticks inside the plot area)
$c->yAxis2->setTickLength(-4);
# Synchronize the y-axis such that y2 = 7.8 x y1
$c->syncYAxis(7.8);
# Add a title to the bottom x axis
$c->xAxis->setTitle("Hong Kong Time");
# Set the labels on the x axis.
$c->xAxis->setLabels($labels0);
# Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.
$c->xAxis->setLabelStep(3, 1);
# Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve means ticks inside
# the plot area)
$c->xAxis->setTickLength2(-4, -2);
# Set the distance between the axis labels and the axis to 6 pixels
$c->xAxis->setLabelGap(6);
# Add a title to the top x-axis
$c->xAxis2->setTitle("New York Time");
# Set the labels on the x axis.
$c->xAxis2->setLabels($labels1);
# Display 1 out of 3 labels on the x-axis. Show minor ticks for remaining labels.
$c->xAxis2->setLabelStep(3, 1);
# Set the major tick length to -4 pixels and minor tick length to -2 pixels (-ve means ticks inside
# the plot area)
$c->xAxis2->setTickLength2(-4, -2);
# Set the distance between the axis labels and the axis to 6 pixels
$c->xAxis2->setLabelGap(6);
# Add a line layer to the chart with a line width of 2 pixels
$c->addLineLayer($data0, -1, "Red Transactions")->setLineWidth(2);
# Add an area layer to the chart with no area boundary line
$c->addAreaLayer($data1, -1, "Green Transactions")->setLineWidth(0);
# Output the chart
$viewer = new WebChartViewer("chart1");
$viewer->setChart($c, SVG);
# Include tool tip for the chart
$viewer->setImageMap($c->getHTMLImageMap("", "",
"title='{dataSetName}\nHKT Jun {=3.5+{x}/24|0} {={x}%24}:00 (NYT Jun {=3+{x}/24|0} ".
"{=({x}+12)%24}:00)\nHKD {={value}*7.8} (USD {value})'"));
?>
Dual X-Axis
Dual X-Axis
renderHTML(); ?>