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

Message ListMessage List     Post MessagePost Message

  Crosses in grids possible?
Posted by Christopher on Dec-07-2012 16:33
Attachments:
Hi Peter,

is it possible to create a grid with crosses as you can see in the attached image?

Regards
Christopher
chart_grid.png

  Re: Crosses in grids possible?
Posted by Peter Kwan on Dec-08-2012 05:27
Hi Christopher,

You may try to use a scatter layer to add "+" symbols to create the grid of crosses.

If you are using an XYChart, and assuming the axes are auto-scaled (so that you do  not know where are the crosses), the code would be like:

... create chart as usual ....

$c->layoutAxes();

#get the tick positions
$xTicks = $c->xAxis->getTicks();
$yTicks = $c->yAxis->getTicks();

for ($x = 0; $x < count($xTicks); ++$x) {
    for ($y = 0; $y < count($yTicks); ++$y) {
         $xCoor[] = $xTicks[$x];
         $yCoor[] = $yTicks[$y];
     }
}

$c->addScatterLayer($xCoor, $yCoor, "", CrossSymbol, 9, 0xaaaaaa);
$c->getPlotArea()->setGridColor(Transparent, Transparent);
$c->setClipping();

Hope this can help.

Regards
Peter Kwan

  Re: Crosses in grids possible?
Posted by Christopher on Dec-15-2012 01:08
In a simple Chart, your code is working. In our thousands of lines of code, it isn't displaying anything.

Anyway, a colleague found another simple solution: Just drawing the crosses (Perl):

my @yTicksPixel = map { $c->getYCoor($_) } @{$c->yAxis()->getTicks()};
my @xTicksPixel = map { $c->getXCoor($_) } @{$c->xAxis()->getTicks()};
foreach my $x (@xTicksPixel) {
    foreach my $y (@yTicksPixel) {
        $c->addLine($x - 3, $y, $x + 3, $y, 0x000000, 1);
        $c->addLine($x, $y - 3, $x, $y + 3, 0x000000, 1);
    }
}

I think, it also looks very short and nice ;-)