- Issue created by @ciesinsg
- πΊπΈUnited States andileco
Hi @ciesinsg, sorry to hear you've put in significant effort with no luck. The good news is that there are several ways to put multiple charts on the same page, and none of them require a code solution.
The approach you mention in #2 could be a good solution for you. To add an attachment, you should look at the toolbar under the heading "Displays" where you will see "Page". There is a "+ Add" to add a new display to your view. Select "Attachment" (you will also see "Chart attachment", but that us for a different use-case, so please ignore). Then you just configure the attachment the same way as your page display, except you will need to "attach" the attachment to your page display and make sure it inherits your view's exposed filters.
The other approach you could try would be to make all your views as block displays (rather than pages), and then use Layout Builder to create your grid and then just place the blocks in the grid. The tricky part there has to do with hiding the filters your don't need so you just have one filter showing. There are ways, they just take a while to explain.
I'll try to do a tutorial soon. Please also feel free to request tutorial videos here: https://www.drupal.org/project/charts/issues/3317614 β (I've been disappointed by no one commenting on this ticket!)
- π¨π¦Canada ciesinsg
Hi @andileco, thanks for the tips! I did try using the attachments yesterday but unfortunately I was unsuccessful. What happens is that the attachment chart changes the initial chart I create. Thankfully I discovered the solution, so I will outline it below in case it helps someone in the future:
Recreate Issue
In this example, I have one content type "change request" and I was creating two charts from the fields: category and reason.
1) + Add View - name the view, show content of type change request, checked the "create a page" option, and display a chart of fields.
2) Set up my first chart on this page. I added the category field for the labels, and a second counted category field to count the number of posts per category.
3) Modified the settings on the chart (Format -> Chart settings) to use the label and data field and successfully outputted a "category chart".
4) Clicked "+ Add" and selected attachment. In the Attachment settings, I attached it to Page (initial chart), changed position to after, and enabled "Inherit exposed filters". The rest of the settings on the attachment seemed to be cloned from the original page, including the fields I added and the chart settings.
5) Added the reason field for the labels, and a second counted reason field to count the number of posts per reason. During this process, I selected the option "For This attachment (override)" so that the fields successfully added only for the attachment.
6) Once again I went into the chart settings (Format -> Chart settings) and changed the chart information. I changed the title, labels, and data, however there was nowhere that I could select that previous option "For This attachment (override)". The result was that both charts changed and showed the labels and data for "reason".
Solution
So it seems that the "Format -> Chart | settings" option doesn't have the "For This attachment (override)" option, at least not in Drupal 10. Instead, you have to click Format: Chart | Settings (click chart) on the attachment, and there you can select the attachment as override. Once you do this, the settings are changed only for the attachment and the previous chart remains unchanged.
I wanted to include this explanation because this option is easy to miss and I completely missed it yesterday.
- Status changed to Fixed
over 1 year ago 2:25pm 27 July 2023 Automatically closed - issue fixed for 2 weeks with no activity.