KoolReport's Forum

Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines

Format Number with custom method #2405

Open Aljaz Ketis opened this topic on on Oct 25, 2021 - 4 comments

Aljaz Ketis commented on Oct 25, 2021

I am displaying a number inside Morris BarChart and I want to override the FormatValue of a column value to be displayed. I cannot use prefix, suffix i need to call a php method to retrieve its currency and format the number to the string i want to display. I see that you have a formatValue function in d3 charts, but when i want to include that inside morris it does not get executed. What should i do?

Sebastian Morales commented on Oct 26, 2021

I think Morris chart hasn't had "formatValue" property yet. While waiting for the dev team to implement it similarly to other KoolReport charts we could try to overcome it with "yLabelFormat" and "hoverCallback" options like this:

    \koolreport\morris_chart\Bar::create(array(
        ...
        "options" => array(        
            "yLabelFormat" => "function(value) { return ...; }", // javascript function wrapped in string quotes
            "hoverCallback" => "function(index, options, content, row) { 
                console.log(row);
                return ...;
            }," // javascript function wrapped in string quotes
        )
    ));

Let us know if this is what you want. Tks,

Aljaz Ketis commented on Oct 26, 2021

This methods I know, but i need to use PHP code inside which is not possible inside any of the two you porpoused. Let me know when your developers will finish the formatValue for morris chrats so I can implement it.

Aljaz Ketis commented on Oct 29, 2021

Any updates regarding this issue?

Sebastian Morales commented on Oct 29, 2021

This is pretty complicated because Morris chart only supports displaying formatted values via client side (javascript) function. What you want is formatting values via server side (php) function. We would have to find a way to map php function to javascript one. We will try it next week and let you know if we succeed or not. Tks,

Build Your Excellent Data Report

Let KoolReport help you to make great reports. It's free & open-source released under MIT license.

Download KoolReport View demo
help needed

Morris Chart