The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Quiq::Gd::Component::Grid - Gitter eines XY-Plot

BASE CLASS

Quiq::Gd::Component

DESCRIPTION

Ein Objekt der Klasse definiert ein Gitter für den Hintergrund (oder Vordergrund, je nach Reihenfolge beim Zeichnen) eines XY-Plot. Das Gitter besteht aus gepunkteten Linien an den Haupt-Ticks der X- und der Y-Achse.

ATTRIBUTES

Fett hervorgehobene Attribute sind Pflicht-Attribute. Sie müssen beim Konstruktoraufruf immer angegeben werden.

xAxix => $axis

X-Achse (Subklasse von Quiq::Axis).

yAxix => $axis

Y-Achse (Subklasse von Quiq::Axis).

color => $color (Default: '#000000')

Farbe der Gitterlinien.

EXAMPLE

Code:

  use Quiq::Gd::Image;
  use Quiq::Gd::Component::Grid;
  use Quiq::Axis::Numeric;
  use Quiq::Axis::Time;
  
  my ($width,$height) = (500,200);
  
  # Achsen definieren
  
  my $ax = Quiq::Axis::Numeric->new(
      orientation => 'x',
      font => Quiq::Gd::Font->new('gdSmallFont'),
      length => $width,
      min => 0,
      max => 20,
  );
  my $gAx = Quiq::Gd::Component::Axis->new(
      axis => $ax,
      tickDirection => 'u',
  );
  
  my $ay = Quiq::Axis::Time->new(
      orientation => 'y',
      font => Quiq::Gd::Font->new('gdSmallFont'),
      length => $height,
      min => Quiq::Epoch->new('2019-11-08 08:00:00')->epoch,
      max => Quiq::Epoch->new('2019-11-08 16:00:00')->epoch,
      debug => 0,
  );
  my $gAy = Quiq::Gd::Component::Axis->new(
      axis => $ay,
      reverse => 1,
  );
  
  # Gitter definieren
  
  my $grid = Quiq::Gd::Component::Grid->new(
      xAxis => $ax,
      yAxis => $ay,
      color => '#ff0000',
  );
  
  # Rasterbild erzeugen
  
  my $axHeight = $gAx->height;
  my $ayWidth = $gAy->width;
  
  my $img = Quiq::Gd::Image->new(
      $width + 2*$ayWidth,
      $height + 2*$axHeight,
      # $width,
      # $height,
  );
  $img->background('#ffffff');
  
  # Grid und Achsen zeichnen
  
  $grid->render($img,$ayWidth,$axHeight);
  $gAx->render($img,$ayWidth,$axHeight);
  $gAx->render($img,$ayWidth,$axHeight+$height-1,tickDirection=>'d');
  $gAy->render($img,$ayWidth,$axHeight);
  $gAy->render($img,$ayWidth+$width-1,$axHeight,tickDirection=>'r');

Grafik:

    [Grafik: Gitter eines XY-Plot]

METHODS

Konstruktor

new() - Konstruktor

Synopsis

  $g = $class->new(@keyVal);

Description

Instantiiere ein Grafik-Objekt mit den Eigenschaften @keyVal (s. Abschnitt ATTRIBUTES) und liefere eine Referenz auf das Objekt zurück.

Zeichnen

render() - Zeichne Gitter

Synopsis

  $g->render($img);
  $g->render($img,$x,$y,@keyVal);
  $class->render($img,$x,$y,@keyVal);

Description

Zeichne das Gitter in Bild $img an Position ($x,$y).

Objektmethoden

siehe BASE CLASS

VERSION

1.196

AUTHOR

Frank Seitz, http://fseitz.de/

COPYRIGHT

Copyright (C) 2021 Frank Seitz

LICENSE

This code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.