@tsteur opened this Issue on November 2nd 2022 Member

See details below:

Error: {"message":"ceil(): Argument #1 ($num) must be of type int|float, string given","file":"\/vendor\/szymach\/c-pchart\/src\/BaseDraw.php","line":383,"request_id":"d387f","backtrace":" on \/vendor\/szymach\/c-pchart\/src\/BaseDraw.php(383)\n#0 \/vendor\/szymach\/c-pchart\/src\/BaseDraw.php(383): ceil('1.401.53')\n#1 \/vendor\/szymach\/c-pchart\/src\/BaseDraw.php(342): CpChart\BaseDraw->processScale(0, '1.401.53', 2, Array, 0)\n#2 \/vendor\/szymach\/c-pchart\/src\/Draw.php(2694): CpChart\BaseDraw->computeScale(0, '1.401.53', 2, Array, 0)\n#3 \/plugins\/ImageGraph\/StaticGraph\/GridGraph.php(177): CpChart\Draw->drawScale(Array)\n#4 \/plugins\/ImageGraph\/StaticGraph\/Evolution.php(24): Piwik\Plugins\ImageGraph\StaticGraph\GridGraph->initGridChart(true, 691053, false, true, true)\n#5 \/plugins\/ImageGraph\/API.php(506): Piwik\Plugins\ImageGraph\StaticGraph\Evolution->renderGraph()\n#6 [internal function]: Piwik\Plugins\ImageGraph\API->get(1, 'day', '2022-10-03,2022...', 'Goals', 'get', 'evolution', 0, 'revenue', false, true, 984, 450, '27', '27', '1', 'ecommerceOrder', '3450A3,43a047', '222222', 'efefef', 'dcdcdc', false, '0', false, false)\n#7 \/core\/API\/Proxy.php(244): call_user_func_array(Array, Array)\n#8 \/core\/Context.php(28): Piwik\API\Proxy->Piwik\API\{closure}()\n#9 \/core\/API\/Proxy.php(335): Piwik\Context::executeWithQueryParameters(Array, Object(Closure))\n#10 \/core\/API\/Request.php(267): Piwik\API\Proxy->call('\\Piwik\\Plugins\\...', 'get', Array)\n#11 \/plugins\/API\/Controller.php(45): Piwik\API\Request->process()\n#12 [internal function]: Piwik\Plugins\API\Controller->index()\n#13 \/core\/FrontController.php(631): call_user_func_array(Array, Array)\n#14 \/core\/FrontController.php(169): Piwik\FrontController->doDispatch('API', false, Array)\n#15 \/core\/dispatch.php(32): Piwik\FrontController->dispatch()\n#16

URL: /index.php?module=API&method=ImageGraph.get&idSite=1&apiModule=Goals&apiAction=get&token_auth=XYZANONYMIZED&idGoal=ecommerceOrder&period=day&date=2022-10-03,2022-11-01&filter_sort_column=revenue&column=revenue&columns=revenue&language=en&width=984&height=450&fontSize=27&showMetricTitle=0&aliasedGraph=1&legendAppendMetric=0&backgroundColor=efefef&gridColor=dcdcdc&colors=3450A3%2C43a047&legendFontSize=27&cacherand=7280344

@sgiehl commented on November 9th 2022 Member

This is yet another issue with numbers that a formatted to early. The ImageGraph fetches the numbers formatted from the database. Using those for calculations might result in failures.
There is actually some code, that tries to convert the formatted number back to something usable:

https://github.com/matomo-org/matomo/blob/a36b45a3764cd28303d2ce27c600c7d6f5a5ed20/plugins/ImageGraph/API.php#L557-L573

But this part actually might result in a invalid number. The error above seems to come from a revenue like 1,401.53 $. The code removes the currency and replaces the , with .. So the number being used i 1.401.53, which can't work.

I tried simply using the unformatted metrics for ImageGraph (see https://github.com/matomo-org/matomo/compare/m19940?expand=1), which fixes the problem above. But that means that most percent values, like conversion rate, are then not formatted at all and are used as their rate value, e.g. 0.15 instead of 15

This is actually a more general problem. Not sure if we already have a extra issue about that or only discussed that on various other ones. But the percentage metrics should actually not do any calculations while formatting. We might need to implement a way, that those metrics are always "calculated" automatically and formatted only when needed.

@justinvelluppillai commented on November 14th 2022 Member

Do we now have an issue tracking the more general case @sgiehl, or could you please create one?

Powered by GitHub Issue Mirror