Problem/Motivation

Sometimes when altering the render array produced by the charts views style we might want to identify which chart data came from chart attachment. It will be good to provide a way to identify chart attachment added to chart render array as chart_data element type.

Steps to reproduce

For example, if a module implement a hook_chart_alter() and try to only process chart element children of type chart_data and were built from chart_attachment. It can not easily identify the chart attachment.

Proposed resolution

Add a '#chart_views_attachment' property that has the view id and view display id of the attachment.

Remaining tasks

The code.

User interface changes

N/A

API changes

Adding a '#chart_views_attachment' for chart render array generated by the views charts style.

Data model changes

N/A

Issue fork charts-3490047

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

nikathone created an issue. See original summary.

andileco made their first commit to this issue’s fork.

andileco’s picture

Status: Active » Needs review

I added two properties, as I think this would be more helpful for users when separated:

$chart[$key]['#view_id'] = $this->view->id();
$chart[$key]['#chart_attachment_id'] = $child_display_handler->display['id'];
andileco’s picture

Assigned: Unassigned » nikathone
nikathone’s picture

Assigned: nikathone » Unassigned
Status: Needs review » Needs work

We do have $chart['#view']. The users can get the view ID from it. We might also need to document this at https://git.drupalcode.org/project/charts/-/blob/5.1.x/charts.api.php?re....

  • andileco committed b7df78ae on 5.1.x
    Issue #3490047 by andileco, nikathone: Provide a way to identify chart...
andileco’s picture

Status: Needs work » Fixed

  • andileco committed a82340f5 on 5.0.x
    Issue #3490047 by andileco, nikathone: Provide a way to identify chart...

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.