Closed zedix closed 5 years ago
Was this actually fixed or just closed?
@mrpritchett It was actually fixed in Nova v2.8.0.
You can now change the precision
property like this:
use Laravel\Nova\Metrics\Value;
class AverageNights extends Value
{
/**
* The value's precision when rounding.
*
* @var int
*/
public $precision = 2;
}
Does this work for Trend metrics?
@mrpritchett I guess you already figured that out, but for anyone coming into this issue now, it doesn't work for trends.
@mrpritchett I guess you already figured that out, but for anyone coming into this issue now, it doesn't work for trends.
Well since you fixed it, it does now :-)
https://github.com/laravel/nova/pull/891
For anybody else, just use @zedix code
@mrpritchett It was actually fixed in Nova v2.8.0.
You can now change the
precision
property like this:use Laravel\Nova\Metrics\Value; class AverageNights extends Value { /** * The value's precision when rounding. * * @var int */ public $precision = 2; }
Thanks, y'all!
public $precision = 2;
Since I'm guessing Nova 4.0 this value changed its name to "roundingPrecision"
public $roundingPrecision = 2;
@mrpritchett I guess you already figured that out, but for anyone coming into this issue now, it doesn't work for trends.
Tested today on latest Nova - it does now work for Trend Metrics :monkey:
This issue is the only place I found to use $roundingPrecision - thanks @rderks88
Description
Today, metrics values are sent by
nova-api/metrics
api to front-end rounded with zero precision.Steps To Reproduce
Create a Value metric card displaying an average value.
Actual result: display "2"
Expected result: display "2.62"
In order to achieve the simple result above, we currently must override the
Laravel\Nova\Metrics\Value
class like this:This would be a great fix/addition.