KoolReport's Forum

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

Column Chart show lables on XAxis and numbers on Y-axis #127

Open Humayun opened this topic on on Oct 6, 2017 - 7 comments

Humayun commented on Oct 6, 2017

hi

KoolReport i want this type of chart (https://cdn.koolreport.com/assets/images/editor/c3/image59d7748ad7558.png)

i am using following setup ` $this->src('irmnch')

    ->query("Select Total_number_of_06_month_children , Number_of_Referrals_for_SAM_under_6_Month from zform_352")
    ->pipe(new AggregatedColumn(array(
        "total_child"=>array("sum","Total_number_of_06_month_children")
    )))
    ->pipe(new AggregatedColumn(array(
        "number_of_ref"=>array("sum","Number_of_Referrals_for_SAM_under_6_Month")
    )))
    ->pipe($this->dataStore("result_0_6_months"));
Can you please tell me the view of column chart for the desired output. Thanks
KoolReport commented on Oct 6, 2017

Could you please show us sample of your data?

Humayun commented on Oct 7, 2017

Simple one row data please see following: Total Child SAM Reffered SAM Underweight 191 7 7

and i want this desired output through your package. https://cdn.koolreport.com/assets/images/editor/c3/image59d7748ad7558.png

Thanks

Humayun commented on Oct 9, 2017

any suggestions?

KoolReport commented on Oct 9, 2017

I am sorry for my late reply. We was busy to code some of cool features for next version.

Here is what you can do:

In the setup() function of report

$this->src("your_data_source")
->query("
    SELECT
        sum(Total_number_of_06_month_children) AS total_child,
        sum(Number_of_Referrals_for_SAM_under_6_Month) AS number_of_ref 
    FROM
        zform_352
")
->pipe(new ColumnMeta(array(
    "total_child"=>array(
         "label"=>"Total Child",
    ),
    "number_of_ref"=>array(
        "label"=>"Number of Reference"
    )
)))
->pipe(new Transpose())
->pipe(new ColumnMeta(array(
    "c0"=>array(
        "name"=>"category",
        "label"=>"Category",
    ),
    "c1"=>array(
        "name"=>"quantity",
        "label"=>"Quantity"
    )
)))
->pipe($this->dataStore("result_0_6_months"));

Draw chart on the report view:

<?php
ColumnChart::create(array(
    "dataStore"=>$this->dataStore("result_0_6_months"),
));
?>

Let me explain a little for the steps you take on the setup() function:

  1. First you get data in form of table which have total_child and number_of_ref as columns.
  2. You set the label for total_child as "Total Child" and number_of_ref as "Number of Reference" using ColumnMeta.
  3. Important: Using the Transpose process to transform the columns into rows.
  4. Change the name of columns from "c0" to "category" and "c1" to "quantity".

The format of table before step 3 will look like this:

total_child number_of_ref
500200

The format of table after step 3 will look like this:

c0c1
Total Child500
Number of Reference200

Using the Transpose process, you will bring data table to the format that can be visualized by Google ColumnChart.

Hope that my answer helps.

Let us know if you need any further assistance.

Regards,

KoolPHP Inc

Humayun commented on Oct 11, 2017

Great KoolReport. Thanks for your assistance.

Thanks again.

Humayun commented on Oct 20, 2017

Hi koolreport

can you please tell me the parameter for color for each column ? so i can put different colors to different columns.

thanks

KoolReport commented on Oct 23, 2017

You can do this:

ColumnChart::create(array(
    ...
    "colorScheme"=>array("#333","#666",""#999")
));

Basically you just input array of color to colorScheme, this colors will be used to draw your charts.

Let us know if you need further assistance.

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

None