Axis ticks example

The code below is the source for this graph.

<?php
// Axis ticks example
require_once 'SVGGraph/autoloader.php';

$settings = [
  'back_stroke_width' => 0,
  'back_shadow' => 3,
  'back_colour' => 'white',
  'auto_fit' => true,
  'axis_font' => 'Arial',
  'axis_font_size' => 12,
  'axis_font_weight' => 'bold',
  'axis_text_space' => 5,
  'line_stroke_width' => 1,
  'tooltip_font_size' => 11,
  'structure' => [
    'key' => 0, 'value' => [ 2, 3, ], 'tooltip' => 1,
  ],
  'axis_zero_y' => false,
  'marker_size' => [ 7, 4 ],
  'marker_type' => ['star', 'circle'],
  'marker_colour' => ['#00f/saturation(50%)', '#0f0/saturation(20%)'],
  'marker_stroke_colour' => '#fff',
  'datetime_keys' => true,
  'grid_stroke_width_h' => 2,
  'axis_ticks_x' => [
    '2008-05-02', '2012-05-04', '2015-05-01', '2018-04-27', '2019-04-26',
  ],
  'axis_ticks_y' => [ 100, 500, 1000, 1500, 2000, 2500, 2800 ],
  'datetime_text_format' => "j M\nY",
  'axis_max_v' => 2800,
  'legend_title' => "Marvel movies\nbox office",
  'legend_entries' => ['Domestic', 'Worldwide'],
  'legend_position' => 'top left 10 10',
  'legend_padding' => 10,
  'legend_autohide' => true,
  'legend_autohide_opacity' => -0.2,
  'legend_draggable' => false,
  'shape' => [
    ['rect', 'x' => 'g2008-05-02', 'y' => 'gt',
    'width' => 'u5 years', 'height' => 'u1300',
    'fill' => ['#c33', '#fff'], 'stroke' => 'none',
    'autohide' => true, 'autohide_opacity' => [0.8, 0.1], 'opacity' => 0.1],
    ['rect', 'x' => 'g2011-07-22', 'y' => 'gt',
      // pass the duration in seconds
      'width' => 'u' . (\Goat1000\SVGGraph\Graph::dateConvert('2016-05-06') - 
      \Goat1000\SVGGraph\Graph::dateConvert('2011-07-22')),
    'height' => 'u1300', 'fill' => ['#33c','#fff'], 'stroke' => 'none',
    'autohide' => true, 'autohide_opacity' => [0.8, 0.1], 'opacity' => 0.1],
  ],
];


$values = [
  ["2008-05-02", "Iron Man", 318.6, 585.2, ],
  ["2008-06-13", "The Incredible Hulk", 134.8, 263.4, ],
  ["2010-05-07", "Iron Man 2", 312.4, 623.9, ],
  ["2011-05-06", "Thor", 181, 449.3, ],
  ["2011-07-22", "Captain America: The First Avenger", 176.7, 370.6, ],
  ["2012-05-04", "The Avengers", 623.4, 1519, ],
  ["2013-05-03", "Iron Man 3", 409, 1215, ],
  ["2013-11-08", "Thor: The Dark World", 206.4, 644.6, ],
  ["2014-04-04", "Captain America: The Winter Soldier", 259.8, 714.3, ],
  ["2014-08-01", "Guardians of the Galaxy", 333.2, 773.3, ],
  ["2015-05-01", "Avengers: Age of Ultron", 459, 1405, ],
  ["2015-07-17", "Ant-Man", 180.2, 519.3, ],
  ["2016-05-06", "Captain America: Civil War", 408.1, 1153, ],
  ["2016-11-04", "Doctor Strange", 232.6, 677.7, ],
  ["2017-05-05", "Guardians of the Galaxy Vol. 2", 389.8, 863.8, ],
  ["2017-07-07", "Spider-Man: Homecoming", 334.2, 880.2, ],
  ["2017-11-03", "Thor: Ragnarok", 315.1, 854, ],
  ["2018-02-16", "Black Panther", 700.1, 1347, ],
  ["2018-04-27", "Avengers: Infinity War", 678.8, 2048, ],
  ["2018-07-06", "Ant-Man and the Wasp", 216.6, 622.7, ],
  ["2019-04-08", "Captain Marvel", 426.8, 1128, ],
  ["2019-04-26", "Avengers: Endgame", 858.4, 2792, ],
  ["2019-07-02", "Spider-Man: Far From Home", 390.5, 988, ],
];

$graph = new Goat1000\SVGGraph\SVGGraph(670, 300, $settings);
$graph->values($values);
$graph->colours(['red/saturation(180%)/brightness(150%)', 
  'orange/brightness(80%)']);
$graph->render('MultiSteppedLineGraph');

Please note: the source code above comes from a script used to generate one of the example graphs on the site. This is simply a wrapper page to apply highlighting and make the source code easier to read, so there is no content here to describe what the source code is doing.

This site uses cookies - details here.