I'm having issues generating a stacked bar chart using drupal cms.
I'm making use of this api to generate chart
(https://drupal.org/project/google_chart_tools)
as shown:
> $settings['chart']['chartOne'] = array(
>
'header' => array('Teachers', 'Student'),
'rows' => array(array(20, 100)),
'columns' => array('people'),
'chartType' => 'BarChart',
'containerId' => 'content1',
'options' => array(
'forceIFrame' => FALSE,
'title' => 'School',
'width' => 800,
'height' => 400,
'isstacked' => TRUE
)
how can i make it on the chart such that?
example :
10 out of 20 teachers are male and the other 10 are female
50 out of 100 students are male and the other 50 are female
Tried modifying the following and getting only teachers but empty students:
> $settings['chart']['chartOne'] = array(
>
'header' => array('Teachers', 'Students'),
'rows' => array(array(10),array(10)), array(array(50),array(50)),
'columns' => array('Male', 'Female'),
'chartType' => 'BarChart',
'containerId' => 'content1',
'options' => array(
'forceIFrame' => FALSE,
'title' => 'School',
'width' => 800,
'height' => 400,
'isstacked' => TRUE
)
Output Results : http://i.stack.imgur.com/V86qQ.png
Answer from the OP which was originally posted into the question
$settings['chart']['chartOne'] = array(
'header' => array('Teachers', 'Students'),
'rows' => array(array(10,50),array(10,50)),
'columns' => array('Male', 'Female'),
'chartType' => 'BarChart',
'containerId' => 'content1',
'options' => array(
'forceIFrame' => FALSE,
'title' => 'School',
'width' => 800,
'height' => 400,
'isstacked' => TRUE
)
Related
This question already has answers here:
How can I sort arrays and data in PHP?
(14 answers)
Closed 4 years ago.
How do you make someone who has a higher subscriberCount be sorted to the top? For example, I want to list the top 50 by subscriberCount. Currently it just sorts by the order added to $topchan1["items"]. I need to order by the highest subscriberCount.
$topchan1 = json_decode(file_get_contents('https://www.googleapis.com/youtube/v3/channels?id='
.$kanalas1.'&part=snippet%2Cstatistics&key='.$API.''),true);
$videoList = array_merge($topchan1["items"],$topchan2["items"],$topchan3["items"],$topchan4["items"]);
foreach ($videoList as $key => $part) {
$sort[$key] = sort($part['statistics']['subscriberCount']);
}
array_multisort($sort, SORT_DESC, $videoList);
$i = 1;
for( $i = 0 ; $i <= count($videoList)-1 ; $i++ )
{
if(isset($videoList[$i]["statistics"]["subscriberCount"])) {
echo $videoList[$i]["statistics"]["subscriberCount"].' _ ';
}
}
how looks
array ( 0 => array ( 'kind' => 'youtube#channel', 'etag' => '"XI7nbFXulYBIpL0ayR_gDh3eu1k/Wj45BU6eiZOcR9nLVG4cXvflUNY"', 'id' => 'UCgQ1CeGtjCbkvslmG3zTAFA', 'snippet' => array ( 'title' => 'ILYA STREKAL', 'description' => 'Привет, меня зовут Илья Стрекаловский, добро пожаловать на мой канал!', 'customUrl' => 'BayanCover', 'publishedAt' => '2013-01-13T15:44:18.000Z', 'thumbnails' => array ( 'default' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAytpuX_75kGnsI5bvr_EkGTeQtZy3AJJXfH2w=s88-mo-c-c0xffffffff-rj-k-no', 'width' => 88, 'height' => 88, ), 'medium' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAytpuX_75kGnsI5bvr_EkGTeQtZy3AJJXfH2w=s240-mo-c-c0xffffffff-rj-k-no', 'width' => 240, 'height' => 240, ), 'high' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAytpuX_75kGnsI5bvr_EkGTeQtZy3AJJXfH2w=s800-mo-c-c0xffffffff-rj-k-no', 'width' => 800, 'height' => 800, ), ), 'localized' => array ( 'title' => 'ILYA STREKAL', 'description' => 'Привет, меня зовут Илья Стрекаловский, добро пожаловать на мой канал!', ), 'country' => 'RU', ), 'statistics' => array ( 'viewCount' => '234688406', 'commentCount' => '0', 'subscriberCount' => '2254032', 'hiddenSubscriberCount' => false, 'videoCount' => '153', ), ),
1 => array ( 'kind' => 'youtube#channel', 'etag' => '"XI7nbFXulYBIpL0ayR_gDh3eu1k/1vk-0WWcl2cpv1LO_4WQGsb2Qhk"', 'id' => 'UCMnOYmqiAQhE51l6AzEuOBA', 'snippet' => array ( 'title' => '', 'customUrl' => 'yanshelestx', 'publishedAt' => '2016-01-08T13:06:33.000Z', 'thumbnails' => array ( 'default' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAx6VddPszhqRGnHG48L5wVzTyf-h9lFa4F9Ig=s88-mo-c-c0xffffffff-rj-k-no', 'width' => 88, 'height' => 88, ), 'medium' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAx6VddPszhqRGnHG48L5wVzTyf-h9lFa4F9Ig=s240-mo-c-c0xffffffff-rj-k-no', 'width' => 240, 'height' => 240, ), 'high' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAx6VddPszhqRGnHG48L5wVzTyf-h9lFa4F9Ig=s800-mo-c-c0xffffffff-rj-k-no', 'width' => 800, 'height' => 800, ), ), 'defaultLanguage' => 'ru', 'localized' => array ( 'title' => 'Shelest', 'description' => 'Hello! This channel is dedicated to high-tech. I\'m a big lover of quality products for an adequate cost. The channel will express the personal opinion of the purchased goods and to listen to your words. Thank you!', ), 'country' => 'UA', ), 'statistics' => array ( 'viewCount' => '53038697', 'commentCount' => '0', 'subscriberCount' => '404844', 'hiddenSubscriberCount' => false, 'videoCount' => '123', ), ),
2 => array ( 'kind' => 'youtube#channel', 'etag' => '"XI7nbFXulYBIpL0ayR_gDh3eu1k/sSeA4B5B1NeVdRrLvhV6IQk9AJs"', 'id' => 'UCEFpNxeybzVwRbnYabQsXEg', 'snippet' => array ( 'title' => 'Bass Music Movement', 'description' => 'Music Promotion & Record Label Submissions/Business inquiries: bassmusicmovement#outlook.com', 'customUrl' => 'brazilianbassmovement', 'publishedAt' => '2017-03-06T02:48:38.000Z', 'thumbnails' => array ( 'default' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAx25V8TX9UzZkzfLlHPFH9yFjxQQQFeILTi=s88-mo-c-c0xffffffff-rj-k-no', 'width' => 88, 'height' => 88, ), 'medium' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAx25V8TX9UzZkzfLlHPFH9yFjxQQQFeILTi=s240-mo-c-c0xffffffff-rj-k-no', 'width' => 240, 'height' => 240, ), 'high' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAx25V8TX9UzZkzfLlHPFH9yFjxQQQFeILTi=s800-mo-c-c0xffffffff-rj-k-no', 'width' => 800, 'height' => 800, ), ), 'localized' => array ( 'title' => 'Bass Music Movement', 'description' => 'Music Promotion & Record Label Submissions/Business inquiries: bassmusicmovement#outlook.com', ), 'country' => 'BR', ), 'statistics' => array ( 'viewCount' => '136215709', 'commentCount' => '0', 'subscriberCount' => '748023', 'hiddenSubscriberCount' => false, 'videoCount' => '46', ), ),
3 => array ( 'kind' => 'youtube#channel', 'etag' => '"XI7nbFXulYBIpL0ayR_gDh3eu1k/VwnSAHbLaj-RwQW8QKFECxplCp4"', 'id' => 'UCAf-RYRpQgxpj8voC29ck7w', 'snippet' => array ( 'title' => 'Hard Play', 'description' => '', 'customUrl' => 'hardplaygamechannel', 'publishedAt' => '2016-06-23T20:39:00.000Z', 'thumbnails' => array ( 'default' => array ( 'url' => '', 'width' => 88, 'height' => 88, ), 'medium' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAyu2XfSQsqjyNqu-fTTjleD9XzLSLoLsP-8Yw=s240-mo-c-c0xffffffff-rj-k-no', 'width' => 240, 'height' => 240, ), 'high' => array ( 'url' => 'https://yt3.ggpht.com/a-/AN66SAyu2XfSQsqjyNqu-fTTjleD9XzLSLoLsP-8Yw=s800-mo-c-c0xffffffff-rj-k-no', 'width' => 800, 'height' => 800, ), ), 'localized' => array ( 'title' => 'Hard Play', 'description' => '', ), 'country' => 'RU', ), 'statistics' => array ( 'viewCount' => '39723260', 'commentCount' => '0', 'subscriberCount' => '784162', 'hiddenSubscriberCount' => false, 'videoCount' => '260', ), ), )
You need to use usort() with custome function where you can compare viewCount and sort array in DESC order
function sortByviewCount($a, $b) {
return ($a['statistics']['viewCount'] > $b['statistics']['viewCount']) ? -1:1;
}
usort($videoList, 'sortByviewCount');
print_r($videoList);
Output:-https://3v4l.org/HqXVc
I want to show marketplace dropdown name in magento grid but what i write in my code that display marketplace value.Bellow is my code
protected function _prepareColumns()
{
$this->addColumn('marketplace', array(
'header' => Mage::helper('adminhtml')->__('Marketplace'),
'align' =>'right',
'width' => '10px',
'index' => 'marketplace',
));
$this->addColumn('action',
array(
'header' => Mage::helper('adminhtml')->__('Action'),
'width' => '100px',
'type' => 'action',
'getter' => 'getId',
'actions' => array(array(
'caption' => Mage::helper('adminhtml')->__('Edit'),
'url' => array('base' => '*/*/edit'),
'field' => 'id'
)),
'filter' => false,
'sortable' => false,
'index' => 'id',
));
return parent::_prepareColumns();
}
could anyone please point out what i am doing wrong as i do not have much experience in magento.
Thanking you all in advance
add field type for market place like...
$this->addColumn('marketplace', array(
'header' => Mage::helper('adminhtml')->__('Marketplace'),
'align' =>'right',
'width' => '10px',
'index' => 'marketplace'
'type' => 'options',
'options' => array(
6 => '6',
5 => '4',
4 => '4',
3 => '3',
2 => '2',
1 => '1'
),
));
First of all excuse my bad english.
I got a problem with my select-field in the BE. I would like to prefill (preselect) all of the available items.
Code in ext_tables.php:
'teilnehmer' => array(
'exclude' => 0,
'label' => 'LLL:EXT:kiwanisext/Resources/Private/Language/locallang_db.xlf:tx_kiwanisext_domain_model_veranstaltung.teilnehmer',
'config' => array(
'type' => 'select',
'foreign_table' => 'fe_users',
'MM' => 'tx_kiwanisext_veranstaltung_user_mm',
'size' => 10,
'autoSizeMax' => 30,
'maxitems' => 9999,
'multiple' => 0,
'wizards' => array(
'_PADDING' => 1,
'_VERTICAL' => 1,
'edit' => array(
'type' => 'popup',
'title' => 'Edit',
'script' => 'wizard_edit.php',
'icon' => 'edit2.gif',
'popup_onlyOpenIfSelected' => 1,
'JSopenParams' => 'height=350,width=580,status=0,menubar=0,scrollbars=1',
),
'add' => Array(
'type' => 'script',
'title' => 'Create new',
'icon' => 'add.gif',
'params' => array(
'table' => 'fe_users',
'pid' => '###CURRENT_PID###',
'setValue' => 'prepend'
),
'script' => 'wizard_add.php',
),
),
),
),
I found nothing helpful in the documentation.
Any hint, tip or help will be much appreciated!
Its not possible to do that with plain TCA config, afaik. You can however define a default value wich will be selected (if none is defines, 1st item will be selected).
'default' => 'myValue'
But to preselect multiple values at once, you have to use JavaScript I guess.
This code worked for me in typo3 6.2. I have a selectbox filled with database records.
I want the records with ID's 1 ans 2 to be preselected in the selectbox:
'thematique' => array(
'exclude' => 0,
'label' => 'LLL:EXT:dk_actus/locallang_db.xml:tx_dkactus_thematique',
'config' => array(
'type' => 'select',
'foreign_table' => 'tx_dkactus_thematique',
'foreign_table_where' => 'ORDER BY tx_dkactus_thematique.uid',
'size' => 10,
'minitems' => 0,
'maxitems' => 99,
'default' => '1,2',
),
),
In orangehrm3.1 I want to customize view leave request page. If leave request day is greater than 3 I need to hide Actions list box for supervisor.
How do I do this?
Currently editing in LeaveListConfigurationFactory.php
$leaveRequestService = new LeaveRequestService();
$header7->populateFromArray(array(
'name' => 'Actions',
'width' => '10%',
'isSortable' => false,
'isExportable' => false,
'elementType' => 'leaveListAction',
'textAlignmentStyle' => 'left',
'elementProperty' => array(
'classPattern' => 'select_action quotaSelect',
'defaultOption' => array('label' => 'Select Action', 'value' => ''),
'hideIfEmpty' => true,
'options' => array($leaveRequestService, 'getLeaveRequestActions', array(self::RECORD, self::$loggedInEmpNumber)),
'namePattern' => 'select_leave_action_{id}',
'idPattern' => 'select_leave_action_{id}',
'hasHiddenField' => true,
'hiddenFieldName' => '{eimId}-{leaveTypeId}',
'hiddenFieldId' => '{eimId}-{leaveTypeId}',
'hiddenFieldValueGetter' => 'getNumberOfDays',
'hiddenFieldClass' => 'quotaHolder',
'placeholderGetters' => array(
'id' => 'getId',
'eimId' => 'getEmpNumber',
'leaveTypeId' => 'getLeaveTypeId'
),
),
));
I have a variable $code which contains the following data. I want the contents of $feeds_importer to an array. How can I do this?
$feeds_importer = new stdClass;
$feeds_importer->disabled = FALSE;
/* Edit this to true to make a default feeds_importer disabled initially */
$feeds_importer->api_version = 1;
$feeds_importer->id = 'feed';
$feeds_importer->config = array(
'name' => 'Feed',
'description' => 'Import RSS or Atom feeds, create nodes from feed items.',
'fetcher' => array(
'plugin_key' => 'FeedsHTTPFetcher',
'config' => array(
'auto_detect_feeds' => FALSE,
'use_pubsubhubbub' => FALSE,
'designated_hub' => '',
),
),
'parser' => array(
'plugin_key' => 'FeedsSyndicationParser',
'config' => array(),
),
'processor' => array(
'plugin_key' => 'FeedsNodeProcessor',
'config' => array(
'content_type' => 'feed_item',
'update_existing' => 0,
'expire' => '-1',
'mappings' => array(
array(
'source' => 'title',
'target' => 'title',
'unique' => FALSE,
),
array(
'source' => 'description',
'target' => 'body',
'unique' => FALSE,
),
array(
'source' => 'timestamp',
'target' => 'created',
'unique' => FALSE,
),
array(
'source' => 'url',
'target' => 'url',
'unique' => TRUE,
),
array(
'source' => 'guid',
'target' => 'guid',
'unique' => TRUE,
),
),
'input_format' => 0,
'author' => 0,
),
),
'content_type' => 'feed',
'update' => 0,
'import_period' => '1800',
'expire_period' => 3600,
'import_on_create' => 1,
);
i want the contents of feeds_importer to an array how can i do this?
$array = (array) $feeds_importer;