How to set image in axis text in SVGGraph?

12 views Asked by At

I am trying to add the image in axis text. I am using RadarGraph from SVGGraph library.

Radar SVGGraph

I am not able to find a solution for that.

What I tried

I found an option axis_text_callback_x but I am not able to use it for setting the images

'axis_text_callback_x' => function ($v) {
    return array(
        'image',
        'src' => 'https://myimagelink.png',
    );
},

But still unable to get the image on X axis.

Full Code

$settings = [
    'auto_fit' => true,
    'back_colour' => 'none',
    'back_stroke_width' => 0,
    'back_stroke_colour' => '#eee',
    'stroke_colour' => '#000',
    'axis_colour' => '#333',
    'axis_overlap' => 2,
    'grid_colour' => '#666',
    'axis_font' => 'Arial',
    'axis_font_size' => 10,
    'pad_right' => 20,
    'pad_left' => 20,
    'marker_type' => 'circle',
    'marker_size' => 3,
    'marker_colour' => 'blue',
    'fill_under' => true,
    'show_labels' => false,
    'label_font' => 'Arial',
    'label_font_size' => 14,
    'minimum_grid_spacing' => 20,
    'show_subdivisions' => true,
    'show_grid_subdivisions' => true,
    'grid_subdivision_colour' => '#ccc',
    'grid_straight' => true,
    'show_x_axis' => false,
    'reverse' => true,
    'axis_text_callback_x' => function ($v) {
        return array(
            'image',
            'src' => 'https://imagelink.png',
        );
    },
];

$width = 300;
$height = 200;
$type = 'RadarGraph';

$colours = ['#FFC0CB'];

$graph = new Goat1000\SVGGraph\SVGGraph($width, $height, $settings);
$graph->colours($colours);

$graph->values(['Group 1' => 12, 'Group 2' => 14, 'Group 3' => 14]);

echo $graph->fetch($type, false);
0

There are 0 answers