🇨🇦Canada @kevin.bruner

Account created on 6 October 2020, about 4 years ago
#

Recent comments

🇨🇦Canada kevin.bruner

I've been at the JS hook override thing for a while now and I'm getting nowhere. I'm able to invoke the hook and confirm that it's running for each chart through Drupal logging, but I can't log out the results of $chart_id (it returns null) every time. I can't log $element because it contains circular references.

While I am grateful for your help, I must be frank: I don't think the examples are very self-explanatory.

🇨🇦Canada kevin.bruner

You seem to be pretty good at distilling my user error into actionable results, so if you have the patience, I have another question.

I have some pretty large values, so I was hoping to use the formatter function to save some space (e.g. 2.5M vs 25000000)

https://chartjs-plugin-datalabels.netlify.app/guide/formatting.html#data...

Is there a way that you know of to pass these into the raw_options array? Here's what I'm using for raw_options. The function is visible in the final canvas as a string which obviously means I'm doing this wrong!

$chartjs_options = [
'options' => [
'maintainAspectRatio' => FALSE,
'responsive' => TRUE,
'plugins' => [
'title' => [
'display' => FALSE,
],
'legend' => [
'position' => 'top',
'labels' => [
'font' => [
'size' => 16,
'family' => 'Montserrat, Helvetica, sans-serif',
],
],
],
'datalabels' => [
'anchor' => 'end',
'align' => 'top',
'color' => '#000',
'font' => [
'size' => 14,
],
'formatter' => 'function(value, context) {
if (value >= 1000000) {
return (value / 1000000).toFixed(1) + "M";
} else if (value >= 1000) {
return (value / 1000).toFixed(1) + "K";
} else {
return value;
}
}',
],
],
],
];

🇨🇦Canada kevin.bruner

Oh wow, absolutely a reading comprehension issue on my part. Yes, I see the numbers now! Marking as reviewed. I can't thank you enough for all your help.

🇨🇦Canada kevin.bruner

I was able to apply the patch and I can see the code changes on my server as expected. I can see the option in the views menu, but I'm not using views. I'm trying to create a custom block using a module. I've added the datalabels line where I believe it should go (see below) but to no effect. Is there something else I need to do?

$charts_container = [
'#type' => 'container',
'#data_labels' => TRUE,
'#attributes' => [
'class' => ['pop_by_sex'],
'id' => $chart_id,
],
'content' => [
'three_series_column' => [
'#type' => 'chart',
'#tooltips' => $charts_settings->get('charts_default_settings.display.tooltips'),
'#chart_type' => 'column',
'series_one' => $male_series,
'series_two' => $female_series,
'series_three' => $total_series,
'x_axis' => $xaxis,
'y_axis' => $yaxis,
'#raw_options' => $chartjs_options,
],
],
];

🇨🇦Canada kevin.bruner

That's great! I'll try it out this morning and let you know. Thanks so much!

🇨🇦Canada kevin.bruner

Here's attached the end goal. I've attached the current state in my original post. I'm really just an IT generalist on a very small team trying to refactor out some vue.js another developer left in that is unmaintainable. Drupal is just a tool we use and this is the first module I've attempted to write, so I didn't expect to go fully into the weeds of creating patches and modifying other modules on my first foray, but I'll do that if it's the best way to get some numerical values on these charts.

🇨🇦Canada kevin.bruner

Thanks. I'll look into that. I think you. I think we may have a case of this on our hands here because I'm not familiar at all with the modules structure https://xkcd.com/2501/

I'll report back with what I'm able to do, but I'll be learning these components and how to modify them from scratch

🇨🇦Canada kevin.bruner

Thank you, Joseph! I can confirm that your patch + patch-ignore combo worked, however, we are now getting the same issue with panels as the latest commentor has also mentioned.

🇨🇦Canada kevin.bruner

Thank you! This makes sense to me conceptually and I thank you for taking the time to explain it. I hope this thread can illuminate for anyone else like me.

🇨🇦Canada kevin.bruner

I've done so, I believe. And my site builds correctly, however, the issue persists. This is why I'm thinking I must have done something wrong

"patches": {
"drupalwxt/wxt" :{
"fix for title issue":
" https://www.drupal.org/files/issues/2024-01-22/wxt-update_patch_2938129-... "
}
},

This is from a fresh build with a re-import and update of the database on a dev server.

🇨🇦Canada kevin.bruner

I don't think my issue so much is that I don't know how to actually insert it into my composer.json, it's that I'm pulling this upstream by using the site-wxt example rather than using a custom composer.json of the wxt composer.json. It's a conceptual issue for including this patch in my implementation that I struggle with rather than the concept of patching entirely.

🇨🇦Canada kevin.bruner

What's the most appropriate way to include this patch in my drupal sites?

I haven't done a lot of patch inclusions in my composer.json.

I'm using the wxt-site example with this line: "drupalwxt/wxt": "5.2.x"

🇨🇦Canada kevin.bruner

Great! I'm happy that was easy to track down.

Do I have to wait for the next WxT release, or is there a way to apply this now?

Production build 0.71.5 2024