CGI::A...h::HTML(3pm)

πŸ“¦
version 0.07 Β· 4 versions
, in debian bookworm, debian trixie, ubuntu noble, ubuntu resolute, ubuntu stonking

πŸ’– CGI::Application::Plugin::DBIProfile::Graph::HTML πŸ’–

okay bestie, so this is CGI::Application::Plugin::DBIProfile::Graph::HTML β€” and yes the name is a whole paragraph, we know, we've accepted it. it's VERY basic pure html vertical bar graphing for CAP:DBIProfile. like, bars. going up. in raw html. no canvas, no js, no drama. πŸŽ€


✨ SYNOPSIS ✨

drop this in your httpd.conf and you're literally good to go:

# in httpd.conf
SetVar CAP_DBIPROFILE_GRAPHMODULE CGI::Application::Plugin::DBIProfile::Graph::HTML
PerlSetVar CAP_DBIPROFILE_GRAPHMODULE CGI::Application::Plugin::DBIProfile::Graph::HTML

(yes both lines, one for each server config flavour, she contains multitudes πŸ’…)


🌸 DESCRIPTION 🌸

so this module is the basic starter implementation of graphing for CAP:DBIProfile. it's giving "reference design". it's giving "template you copy". it's giving example energy β€” the whole point is that you can look at it and go "oh that's how you do it" and then go build your own fancier, more sophisticated graphing solution. iconic behaviour tbh. πŸ‘‘


πŸ¦‹ GRAPH PLUGIN DEVELOPMENT πŸ¦‹

ok so if you're building your own graph plugin (main character move), here are the rules of the game:

your graphing plugin must have a method called build_graph, and that method must accept options as a hash. no exceptions, bestie, that's the contract.

it should return a scalar or a scalar ref holding the HTML output you need to generate your graph. that's it. that's the whole return vibe.

the following options are what's getting passed into the build_graph method:

  • self β€” the cgiapp object. hi queen 🫢
  • mode_param β€” $self->mode_param, aka the runmode variable used to determine runmode. lowkey super useful for creating links back to ourselves, iykyk.
  • title β€” a textual title for your graph. you don't have to use this, it's just there if you want it. optional garnish. 🌿
  • ylabel β€” label for the values we're graphing. it's either "Count" or "Seconds". that's the whole menu.
  • data β€” an array of the datapoints to graph. the actual numbers, the moment of truth.
  • tags β€” labels for each datapoint, and these match the labels that will be used on the sql statement list (1 to however many items there are). so like, tag city.

🧚 the easiest way: go fully inline

the easiest graphs to implement are fully inline β€” like, it doesn't need to make any external calls at all (no <image> or <embed> tags and such, none of that). CGI::Application::Plugin::DBIProfile::Graph::HTML is literally an example of this exact thing. other possible candidates are Plotr and Open Flash Chart (using the js interface to populate data). slay. ✨

another inline solution is to use the <img src="data:uri"> scheme. an example of this can be found in CGI::Application::Plugin::DBIProfile::Graph::GDGraphInline.

⚠️ bestie please note: this isn't supported under MSIE. πŸ’€ just so you know before you ship it.

🌈 the non-inline route

in order to generate a graph that isn't inline, you'll need to pass the data to be graphed along with your call to the external object. for example, if you want to use GDGraph, you could create a separate cgi script that returns graphs based on params passed to it, and return an appropriate image tag from your graphing module. for example:

<img src="/cgi-bin/graph.pl?data=20,14,42&tags=1,2,3">

another way would be to add a runmode in a CGI::Application "init" hook, and pass that runmode in a link back to the same script, and include your graph module in our script with a use statement. an example of this can be found in CGI::Application::Plugin::DBIProfile::Graph::SVGTT. go off. πŸ”₯


⭐ REQUIREMENTS ⭐

L<HTML::Template>

that's the one. that's the whole list. HTML::Template or bust. πŸ’œ


πŸ“ SEE ALSO πŸ“

  • L<CGI::Application::Plugin::DBIProfile>
  • L<CGI::Application::Plugin::DBIProfile::Graph::GDGraphInline>
  • L<CGI::Application::Plugin::DBIProfile::Graph::SVGTT>

go read those too, they're the extended universe. πŸ“š


πŸ‘‘ AUTHOR πŸ‘‘

Joshua I Miller, L<unrtst@cpan.org>

the legend herself. thank you for your service. 🫑


Copyright 2007 Joshua Miller, all rights reserved.

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


okay and that's the whole page bestie!! this one shipped as part of perl v5.36.0, dated 2022-11-19, under the manual name CGI::A...h::HTML(3pm) β€” yes it's truncated like that in the header, we don't make the rules. mwah, go graph something. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from