KoolReport's Forum

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

Handling large values on LineChart #1729

Open Brindicis opened this topic on on Nov 23, 2020 - 3 comments

Brindicis commented on Nov 23, 2020

Hi.

I have some values to display on a LineChart that are way larger than the rest. How should I handle this situation?

Currently, my LineChart has the following configuration in order to avoid negative values while using the "function" curveType.

LineChart::create(array(
    "title"=>"Vendas entre ".$from_date ." e " .$to_date,
    "dataSource"=>$report1->dataStore('sales_sellers'),
    "columns"=>$columns,
    "options"=>array(
        "curveType"=>"function",
        "vAxis"=>[
            "ticks"=>[0,25000,50000,75000,100000,125000,150000],
        ],
    ),
                                                
    "name"=>"chart_sales_seller",
));

Which displays:

The "spike" value is greater than 1 000 000, while all the other values are around 100 000. Since the data is dynamically added to the chart, is there a way of displaying the gridlines evenly spaced, while preserving the minimum value at 0 and using the "function" curveType function?

Sebastian Morales commented on Nov 24, 2020

Pls tell us which chart package you're using?

Brindicis commented on Jan 10, 2021

Sorry for taking so long to answer. I'm using the Google Chart package

Sebastian Morales commented on Jan 11, 2021

When there too much discrepancy among chart values, one common way is to use logarithm scale instead of the normal linear one. For Google chart you could try this syntax:

https://developers.google.com/chart/interactive/docs/customizing_axes#axis-scale

    LineChart::create(array(
        ...
        "options" => array(
            "vAxis" => array(
                "scaleType" => "log"                    
            )
        )
    ));

Let us know how it works for you

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

Laravel