I'm attaching a new patch with a small improvement of the number of columns shown. Instead of three, the new patch is showing four columns.
Hey again!
It turns out that the all of the issues seems related to a custom javascript which was implemented on our website.
I commented out the lines which were throwing an errors and the 'donut' chart is visualised. It's not like the original one, but at least it's there and I think I can handle it from here.
Huge thank you for your help! You can mark this ticket as resolved.
Thanks,
Daniela
Hey andileco!
Thank you for your time and efforts to help me, I really appreciate your help!
I've implemented your code and there is some progress, however something is not quite right.
1. The first issue is for the 'column' type chart. The chart is visualised almost accurate, but have the following issues:
1.1 The label above each column is missing
1.2 On hover there is some 'undefined' text
See attached screenshots for comparison between the original (column-chart-original-v3.5.png) chart and the new one (column-chart-new-v5.1.png).
2. The second issue is with the 'donut' chart type, which is not visualised at all.
Is should look like screenshot donut-chart-original-v3.5.png, but instead it's not visualised at all.
I have made a screenshot donut-chart-new-v5.1.png of the dumped $variables array and the DOM structure which seems that it's builded properly in the template. However nothing is shown.
Maybe the issue is coming from the JS, because there are some errors in the console, see donut-JS-error.png
Can you help with that issues?
Thank you in advance!
Hi andileco!
Thank you very much for your response. I might not have explained the issue clearly, and I apologize for any confusion. Let me provide more clarity on the situation.
On the website I manage, there's a specific paragraph called "Infographic," consisting of multiple fields designated for entering chart data. I've included some screenshots for your reference.
I have created a preprocess function that retrieves data from the Infographic paragraph and transfers it to a custom template.
Here is the preprocess function, which is currently experiencing an error because the buildVariables functionality is not available in the latest version of the module:
function abc_preprocess_paragraph__infographic(&$variables) {
$series_data = [];
$content = $variables['content'];
$options = \Drupal::config('charts.settings')->get('charts_default_settings');
if (!empty($content['field_chart_type']['#items'])) {
$options['type'] = $content['field_chart_type']['#items']->getString();
}
if (!empty($content['field_chart_xaxis_title']['#items'])) {
$options['xaxis_title'] = $content['field_chart_xaxis_title']['#items']->getString();
}
if (!empty($content['field_chart_yaxis_title']['#items'])) {
$options['yaxis_title'] = $content['field_chart_yaxis_title']['#items']->getString();
}
if (!empty($content['field_chart_multicolor']['#items']->getString())) {
$variables['attributes']['class'][] = 'charts-multicolor';
}
$categories = (!empty($content['field_chart_categories']['#items']->getString())) ? explode(',', $content['field_chart_categories']['#items']->getString()) : [];
if (!empty($content['field_chart_data']['#items'])) {
$series_data[] = [
'name' => '',
'data' => array_map('intval', explode(',', $content['field_chart_data']['#items']->getString())),
];
}
if ($options['type'] == 'column'
&& $content['field_chart_series']['#items']->getString()
&& !empty($content['field_chart_multiple_series']['#items'])
) {
$series_data = [];
foreach ($content['field_chart_multiple_series']['#items']->getValue() as $serie) {
$serie_entity = \Drupal\paragraphs\Entity\Paragraph::load($serie['target_id']);
$series_data[] = (object)[
'name' => $serie_entity->field_chart_series_name->getString(),
'data' => array_map('intval', explode(',', $serie_entity->field_chart_series_data->getString())),
];
}
$options['grouping'] = TRUE;
}
$plugin_manager = \Drupal::service('plugin.manager.charts');
$plugin = $plugin_manager->createInstance($options['library']);
$plugin->buildVariables($options, '', $variables, $categories, $series_data, [], []);
$variables['content']['options'] = $options;
}
Here is the corresponding template for the Infographic paragraph:
{% set options = content.options %}
{% set library, height, width, height_units, width_units = 'charts_' ~ options.library ~ '/' ~ options.library, options.height, options.width, options.height_units, options.width_units %}
{{ attach_library("#{ library }") }}
<div {{ attributes }} {{ content_attributes }} style="{% if width is not empty %}width:{{ width }}{{ width_units }};{% endif %}{% if height is not empty %}height:{{ height }}{{ height_units }};{% endif %}"></div>
The issue I'm facing is that the buildVariables method is no longer supported, and I need guidance on rewriting this section using the latest available functionalities. If you have any advice or suggestions, they would be greatly appreciated.
Thank you!
divanova → created an issue.
Hi Ana Bozhilova,
thanks for your response. Installing "google/cloud-firestore" and applying your latest patch worked for me.
The push messages are sent without any errors.
Hi everyone,
I have installed the latest patch (#32) and updated the new configuration page accordingly.
I've uploaded a .json file which I was given from the Firebase, but it's not working.
Here is the structure of the .json file I received:
type
project_id
private_key_id
private_key
client_email
client_id
auth_uri
token_uri
auth_provider_x509_cert_url
client_x509_cert_url
universe_domain
For the "Project ID" field in the "Firebase Push Notification Configuration" page, I've used the "project_id" from the .json file.
For "Credentials" field, I have uploaded the provided .json file.
The old code is:
function _eutb_firebase_push_message($topic, $val) {
/** @var FirebaseMessageService $messageService */
$messageService = \Drupal::service('firebase.message');
$messageService->setTopics($topic);
// Notification
$notification = new Notification($val['title']);
$notification->setBody($val['body']);
// Message data
$messageData = MessageData::fromArray([
'type' => 'axp-content',
'url' => $val['url'],
]);
// Message
$message = new Message($notification);
$message->setData($messageData);
$messageService->setMessage($message);
// Android config
$android_config = new AndroidConfig();
$android_config->setPriority('normal');
$message->setAndroidConfig($android_config);
// Apple config
$apns_config = new ApnsConfig();
$apns_config->setHeaders(['apns-priority' => '5']);
$apns_config->setPayload([
'aps' => [
'mutable-content' => 1,
'content-available' => 1
]
]);
$message->setApnsConfig($apns_config);
try {
$messageService->sendToTopic();
}
} catch (Exception $e) {
$error = 'Push-Message failed: ' . $val['title'] . ' - ' . $val['body'] . ' URL: ' . $val['url'] . ' Error: ' . $e->getMessage();
}
}
The new code is:
/** @var FirebaseMessageService $messageService */
$messageService = \Drupal::service('firebase.message');
$messageService->setTopics($topic);
// Notification
$notification = new Notification($val['title']);
$notification->setBody($val['body']);
// Message data
$messageData = MessageData::fromArray([
'type' => 'axp-content',
'url' => $val['url'],
]);
// Message
$message = new Message($notification);
$message->setData($messageData);
$messageService->setMessage($message);
// Android config
$android_config = new AndroidConfig();
$android_config->setPriority('normal');
$message->setAndroidConfig($android_config);
// Apple config
$apns_config = new ApnsConfig();
$apns_config->setHeaders(['apns-priority' => '5']);
$apns_config->setPayload([
'aps' => [
'mutable-content' => 1,
'content-available' => 1
]
]);
$message->setApnsConfig($apns_config);
try {
$messageService->sendToTopic();
} catch (Exception $e) {
$error = 'Push-Message failed: ' . $val['title'] . ' - ' . $val['body'] . ' URL: ' . $val['url'] . ' Error: ' . $e->getMessage();
}
After I try to send a push message, I get this error:
Error: Class "Google\Auth\ApplicationDefaultCredentials" not found in Drupal\firebase\Service\FirebaseServiceBase->getHandler()
I saw that mieg (#8) reported the same issue, but this dependancy is already integrated in the latest patch and I have it locally and on my DEV system, but it still complains about it.
Does anyone can help with ideas what might be wrong?
I also tried the example from Tri Tran (#29) with the $messageService->sendToTokens();, but then I have another error: Error: The message should contain target.
Any ideas/thoughts would be highly appreciated!
Regards,
Daniela
Hello, I'm uploading a patch for this issue for version "drupal/endroid_qr_code": "4.0.x-dev@dev", where the problem is still there.
I'm using the DEV version, because the latest 4.0 version is throwing the following error: ValueError: Path cannot be empty in file_get_contents() (Line 24 in /var/www/html/project/vendor/endroid/qr-code/src/ImageData/LogoImageData.php).
Thanks for the patch. It's working on Drupal 10.2.4.
divanova → created an issue. See original summary → .
Actually this patch is not working with version 3.4
I manually made the changes on my local file and I thought that the patch is going to work, but in this version the modified line is a little bit bellow and the patch is failing.
Anyway, I made a new patch which is working with the 3.4 version.
Thanks for the patch, @yojohnyo!
I had the same error and this patch fixed it.