HTML-D3
view release on metacpan or search on metacpan
{ name => 'Series A', data => [{ label => 'Jan', value => 100 }, ...] },
...
]
Returns a string containing the HTML and JavaScript code for the chart.
Tooltip strings use `<\/b>` rather than `</b>` for html-tidy compliance.
### Errors
- Throws `Data must be an array of hashes` when `$data` is not an ARRAY reference.
### Side Effects
None.
### API SPECIFICATION
#### Input
$self : HTML::D3 -- required
$data : ArrayRef[ HashRef{ name: Str, data: ArrayRef[HashRef] } ] -- required
#### Output
Str -- complete HTML5 document; one coloured line per series with mouseover tooltips.
## render\_multi\_series\_line\_chart\_with\_animated\_tooltips
$html = $chart->render_multi_series_line_chart_with_animated_tooltips($data);
Generates HTML and JavaScript code to render a chart of many lines with animated mouseover tooltips.
Accepts the following arguments:
- `$data` - Same format as `render_multi_series_line_chart_with_tooltips`:
an array reference of `{ name, data }` series hashes.
Returns a string containing the complete HTML5 document.
The tooltip appears with a CSS `translateY` slide-in animation.
Tooltip strings use `<\/b>` for html-tidy compliance.
### Errors
- Throws `Data must be an array of hashes` when `$data` is not an ARRAY reference.
### Side Effects
None.
### API SPECIFICATION
#### Input
$self : HTML::D3 -- required
$data : ArrayRef[ HashRef{ name: Str, data: ArrayRef[HashRef] } ] -- required
#### Output
Str -- complete HTML5 document; animated tooltip uses CSS translateY transition.
## render\_multi\_series\_line\_chart\_with\_legends
$html = $chart->render_multi_series_line_chart_with_legends($data);
Generates HTML and JavaScript code to render a chart of many lines with a static
colour legend. Each series gets a labelled colour swatch in the legend area.
Accepts the following arguments:
- `$data` - Same format as `render_multi_series_line_chart_with_tooltips`:
an array reference of `{ name, data }` series hashes.
Returns a string containing the complete HTML5 document. The stylesheet defines
a `.legend` CSS class used by the D3-generated legend elements.
### Errors
- Throws `Data must be an array of hashes` when `$data` is not an ARRAY reference.
### Side Effects
None.
### API SPECIFICATION
#### Input
$self : HTML::D3 -- required
$data : ArrayRef[ HashRef{ name: Str, data: ArrayRef[HashRef] } ] -- required
#### Output
Str -- complete HTML5 document; static colour legend rendered as SVG C<g> elements
with the C<.legend> CSS class applied via D3 C<.attr("class", "legend")>.
## render\_multi\_series\_line\_chart\_with\_interactive\_legends
$html = $chart->render_multi_series_line_chart_with_interactive_legends($data);
Generates HTML and JavaScript code to render a chart of many lines with interactive legends to filter, highlight or modify elements based on legend selections.
Accepts the following arguments:
- `$data` - Same format as `render_multi_series_line_chart_with_tooltips`:
an array reference of `{ name, data }` series hashes.
Returns a string containing the complete HTML5 document. Clicking a legend entry
toggles that series' opacity using an `isVisible` boolean flag in the D3 click
handler (opacity is set to `isVisible ? 0 : 1` on each click).
### Errors
- Throws `Data must be an array of hashes` when `$data` is not an ARRAY reference.
### Side Effects
None.
### API SPECIFICATION
#### Input
$self : HTML::D3 -- required
$data : ArrayRef[ HashRef{ name: Str, data: ArrayRef[HashRef] } ] -- required
#### Output
Str -- complete HTML5 document; legend clicks toggle series visibility.
The C<isVisible> JS variable tracks current visibility state.
Opacity toggled by C<isVisible ? 0 : 1>.
# SUPPORT
This module is provided as-is without any warranty.
Please report any bugs or feature requests to `bug-html-d3 at rt.cpan.org`,
or through the web interface at
[http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTML-D3](http://rt.cpan.org/NoAuth/ReportBug.html?Queue=HTML-D3).
I will be notified, and then you'll
automatically be notified of progress on your bug as I make changes.
You can find documentation for this module with the perldoc command.
perldoc HTML::D3
You can also look for information at:
# BUGS
It would help to have the render routine to return the head and body components separately.
# SEE ALSO
- [Configure an Object at Runtime](https://metacpan.org/pod/Object%3A%3AConfigure)
- [Test Dashboard](https://nigelhorne.github.io/HTML-D3/coverage/)
# AUTHOR
Nigel Horne <njh@nigelhorne.com>
# FORMAL SPECIFICATION
## render\_bar\_chart
render_bar_chart : HTML::D3 à (ArrayRef | undef) â Str ⪠â¥
pre data = undef â die "Data is not optional"
pre ref(data) â 'ARRAY' â die "Data must be an array of arrays"
post result â Str
post "<!DOCTYPE" â result
post â d â data . d[0] â result
## render\_line\_chart
render_line_chart : HTML::D3 à (ArrayRef | undef) â Str ⪠â¥
pre ref(data) â 'ARRAY' â die "Data must be an array of arrays"
post result â Str
post "<!DOCTYPE" â result
post "d3.scalePoint" â result â§ "d3.line()" â result
## render\_lint\_chart\_with\_tooltips
render_line_chart_with_tooltips : HTML::D3 à (ArrayRef | undef) â Str ⪠â¥
pre ref(data) â 'ARRAY' â die "Data must be an array of arrays"
post result â Str
post "<!DOCTYPE" â result
post "mouseover" â result
post "</b>" â result â§ "<\/b>" â result
## render\_multi\_series\_line\_chart\_with\_tooltips
render_multi_series_line_chart_with_tooltips : HTML::D3 à (ArrayRef | undef) â Str ⪠â¥
pre ref(data) â 'ARRAY' â die "Data must be an array of hashes"
post result â Str
post "<!DOCTYPE" â result
post "</b>" â result â§ "<\/b>" â result
## render\_multi\_series\_line\_chart\_with\_animated\_tooltips
render_multi_series_line_chart_with_animated_tooltips : HTML::D3 à (ArrayRef | undef) â Str ⪠â¥
pre ref(data) â 'ARRAY' â die "Data must be an array of hashes"
post result â Str
post "<!DOCTYPE" â result
post "translateY" â result
post "</b>" â result â§ "<\/b>" â result
## render\_multi\_series\_line\_chart\_with\_legends
render_multi_series_line_chart_with_legends : HTML::D3 à (ArrayRef | undef) â Str ⪠â¥
pre ref(data) â 'ARRAY' â die "Data must be an array of hashes"
post result â Str
post "<!DOCTYPE" â result
post ".legend" â result
## render\_multi\_series\_line\_chart\_with\_interactive\_legends
render_multi_series_line_chart_with_interactive_legends : HTML::D3 à (ArrayRef | undef) â Str ⪠â¥
pre ref(data) â 'ARRAY' â die "Data must be an array of hashes"
post result â Str
post "<!DOCTYPE" â result
post "isVisible" â result
post "isVisible ? 0 : 1" â result
post ".legend" â result
# LICENSE AND COPYRIGHT
Copyright 2025-2026 Nigel Horne.
Usage is subject to the GPL2 licence terms.
If you use it,
please let me know.
( run in 1.119 second using v1.01-cache-2.11-cpan-364913b4093 )