I created a bar graph with 2 values on x-axis. Only the first label on x-Axis is displayed and the second one is not displayed. Here is the code. I want both the lables “Andorid devices” and “iPhone Device” should be displayed. Now for every two intervals on X-Axis the lable is displayed. See the attached screenshot.
Controller
function barGraph()
{
$view = Piwik_ViewDataTable::factory(‘graphVerticalBar’);
$view->init( $this->pluginName, FUNCTION, ‘SamplePlugin.getVisitsData’ );
$view->setColumnTranslation(‘value’, “#Visits”);
//$view->setColumnsToDisplay( array(‘active’, ‘registered’) );
//$view->setColumnTranslation(‘active’, “Active Users”);
//$view->setColumnTranslation(‘registered’, “Registered Users”);
//$view->setAxisYUnit(‘°C’);
$view->setGraphLimit( 2 );
$view->disableFooter();
return $this->renderView($view);
}
API.php
public function getVisitsData()
{
$xAxis = array(
‘Android Devices’, ‘iPhone Devices’
);
$VisitValues = array(20,40);
$yAxisValues = array();
foreach($xAxis as $i => $xAxisLabel) {
$yAxisValues[$xAxisLabel] = $VisitValues[$i];
}
// convert this array to a DataTable object
$dataTable = new Piwik_DataTable();
$dataTable->addRowsFromArrayWithIndexLabel($yAxisValues);
return $dataTable;
}