#!/usr/bin/env perl

use lib 'lib';
use HTML::D3;

my $chart = HTML::D3->new(
    width  => 800,
    height => 600,
    title  => 'Monthly Revenue Trends by Product (With Legends)',
);

my $data = [
    {
        name => 'Product A',
        data => [
            { label => 'January', value => 1000 },
            { label => 'February', value => 1200 },
            { label => 'March', value => 950 },
        ],
    },
    {
        name => 'Product B',
        data => [
            { label => 'January', value => 800 },
            { label => 'February', value => 1150 },
            { label => 'March', value => 1000 },
        ],
    },
];

my $html_output = $chart->render_multi_series_line_chart_with_interactive_legends($data);

# Save the output as an HTML file
open my $fh, '>', 'chart.html' or die $!;
print $fh $html_output;
close $fh;

print "Chart with legends saved as 'chart.html'. Open it in a browser.\n";
