/php/ChartDirector/phpdemo/crosshair.php
Back to Chart Graphics
setPlotArea(60, 40, 450, 400, 0xffffff, -1, 0xc0c0c0, 0xc0c0c0, -1);
# Add a title to the chart using 18 point Times Bold Itatic font.
$c->addTitle(" Chemical X Thermal Conductivity", "Times New Roman Bold Italic", 18);
# Add titles to the axes using 12pt Arial Bold Italic font
$c->yAxis->setTitle("Thermal Conductivity (W/K)", "Arial Bold Italic", 12);
$c->xAxis->setTitle("Concentration (g/liter)", "Arial Bold Italic", 12);
# Set the axes line width to 3 pixels
$c->yAxis->setWidth(3);
$c->xAxis->setWidth(3);
# Add a scatter layer using (dataX, dataY)
$scatterLayer = $c->addScatterLayer($dataX, $dataY, "", GlassSphereShape, 13, 0xcc0000);
# Show custom Javascript tooltip for the scatter layer
$scatterLayer->setHTMLImageMap("", "",
"onmouseover='showDataPointToolTip({x}, {value})' onmouseout='hideToolTip()'");
# Add a trend line layer for (dataX, dataY)
$trendLayer = $c->addTrendLayer2($dataX, $dataY, 0xcc0000);
# Set the line width to 3 pixels
$trendLayer->setLineWidth(3);
# Add a 95% confidence band for the line
$trendLayer->addConfidenceBand(0.95, 0x806666ff);
# Add a 95% confidence band (prediction band) for the points
$trendLayer->addPredictionBand(0.95, 0x8066ff66);
# Show custom Javascript tooltip for the trend layer
$trendLayer->setHTMLImageMap("", "",
"onmouseover='showTrendLineToolTip({slope}, {intercept})' onmouseout='hideToolTip()'");
# Add a legend box at (60, 35) (top of the chart) with horizontal layout. Use 10pt Arial Bold Italic
# font. Set the background and border color to Transparent and use line style legend icons.
$legendBox = $c->addLegend(60, 35, false, "Arial Bold Italic", 9);
$legendBox->setBackground(Transparent);
$legendBox->setLineStyleKey(true);
# Add entries to the legend box
$legendBox->addKey("95% Line Confidence", 0x806666ff);
$legendBox->addKey("95% Point Confidence", 0x8066ff66);
$legendBox->addKey(sprintf("Trend Line: y = %.4f x + %.4f", $trendLayer->getSlope(),
$trendLayer->getIntercept()), 0xcc0000, 3);
# Create the WebChartViewer object
$viewer = new WebChartViewer("chart1");
# Output the chart
$viewer->setChart($c, SVG);
# Include tool tip for the chart
$viewer->setImageMap($c->getHTMLImageMap(""));
# Output Javascript chart model to the browser to support tracking cursor
$viewer->setChartModel($c->getJsChartModel());
?>
Crosshair with Axis Labels
Crosshair with Axis Labels
renderHTML() ?>