Sparkline image

We use a request like this to obtain a sparkline image which we embed in various places. In Matomo 5, the sparkline width got oddly thicker and I’m wondering if someone can point me to reference on whether there’s a “linewidth” or similar inputs to tweak this back to the way it was.

Thanks!

?action=get&colors={“backgroundColor”:“%23ffffff”,“lineColor”:“%236f727d”,“minPointColor”:“%23f4516c”,“maxPointColor”:“%2334bfa3”,“lastPointColor”:“%2336a3f7”,“fillColor”:“%23ffffff”}&columns=nb_pageviews&date=previous30&forceView=1&idSite=XXXXXX&module=API&period=day&random=77495950&segment=dimension2%3D%3D123456&showtitle=1&viewDataTable=sparkline&widget=1&token_auth=

Hi there,

There isn’t a way via a parameter to set the line width for spark lines. In the code the thickness is set to 1 pixel.

The relevant file is:

core/Visualization/Sparkline.php

In the sparkline initialization code, around lines 109–112:

$sparkline->setWidth($this->getWidth());
$sparkline->setHeight($this->getHeight());
$sparkline->setLineThickness(1); <------- this one 
$sparkline->setPadding('5');

But altering that may not make a difference. Did you find going from Matomo 4 to 5 that the line looks thicker?

Yes, the line was thicker from 4->5.

We reviewed the code and instead doubled the native size of the image request and forced the tag width the same. The @2x pixel density fixed the issue.

I saw this:


   public const DEFAULT_WIDTH = 200;

    public const DEFAULT_HEIGHT = 50;

    public const LINE_THICKNESS = 4;

    public const POINT_SIZE = 6;

...

$sparkline->setLineThickness(self::LINE_THICKNESS);