-
Notifications
You must be signed in to change notification settings - Fork 9.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dashboard graph has broken y-axis range #7927
Comments
What's the status on this bug? Still an issue in 2.1.5 believe. |
2.1.6 still has the same issue. |
Internal ticket was created - MAGETWO-69966 |
Here's a plugin solution for this issue until the official fix: public function __construct(
\Magento\Backend\Helper\Dashboard\Data $dashboardData,
\Magento\Framework\UrlInterface $url
)
{
$this->_dashboardData = $dashboardData;
$this->_urlBuilder = $url;
}
public function aroundGetChartUrl(\Magento\Backend\Block\Dashboard\Graph $graph, \Closure $proceed, $directUrl = true)
{
$query = $proceed();
$series = $graph->getAllSeries();
$localmaxvalue = [0];
$localminvalue = [0];
foreach ($series as $index => $serie) {
$localmaxvalue[$index] = max($serie);
$localminvalue[$index] = min($serie);
}
$maxvalue = max($localmaxvalue);
$minvalue = min($localminvalue);
$miny = 0;
$maxy = 0;
if ($minvalue >= 0 && $maxvalue >= 0) {
if ($maxvalue > 10) {
$p = pow(10, $this->_getPow($maxvalue));
$maxy = ceil($maxvalue / $p) * $p;
} else {
$maxy = ceil($maxvalue + 1);
}
}
$params = array('chxr' => "1,$miny,$maxy");
// return the encoded data
if ($directUrl) {
return $query.'&chxr='.$params['chxr'];
} else {
$parts = parse_url($query);
parse_str($parts['query'], $parsedParams);
$params = array_merge($params, $parsedParams);
$gaData = urlencode(base64_encode(json_encode($params)));
$gaHash = $this->_dashboardData->getChartDataHash($gaData);
$params = ['ga' => $gaData, 'h' => $gaHash];
return $this->_urlBuilder->getUrl('adminhtml/*/tunnel', ['_query' => $params]);
}
}
protected function _getPow($number)
{
$pow = 0;
while ($number >= 10) {
$number = $number / 10;
$pow++;
}
return $pow;
} (Also thanks in part to @thaisatservermonkey) |
@tomasinchoo, thank you for your report. |
Working on it, to implement solution of Silarn or tomasinchoo |
Internal ticket to track issue progress: MAGETWO-82762 |
Internal ticket to track issue progress: MAGETWO-82761 |
The issue has been fixed in 2.2-develop branch and will be available with 2.2.2 release soon |
Internal ticket to track issue progress: MAGETWO-82760 |
Y-axis on dashboard graph always shows range 0 to 100 in steps of 10. That means quantity and amounts do not match actual value in graph.
Preconditions
Steps to reproduce
Expected result
Actual result
Fortunately, that issue is easy to fix:
This code (exists in M1, not in M2) needs to be inserted on line 424 in vendor/magento/module-backend/Block/Dashboard/Graph.php (thanks to @ivanweiler)
The text was updated successfully, but these errors were encountered: