Question: I want to display a Column Chart which to show to quantity sold for list of items. Then I want to use the client events to track the click on item, I dont want o get the item name but the item_id. How can I do that?
Answer:: This is a workaround for this situation, you will create a special annotationText
column under item name:
Let say your dataStore sample
has three columns item_id
item_name
and quantity
<?php
ColumnChart::create([
"dataStore"=>$this->dataStore("sample"),
"columns"=>[
"item_name"=>[
"annotationText"=>function($row)
{
return (int)$row["item_id"];
}
],
"quantity"=>[
"type"=>"number",
],
],
"clientEvents"=>[
"itemSelect"=>"function(params){
console.log(params);
}"
]
]);
?>
When user click to column, you can get the item_id
in params.selectedRow[1]