Skip to content

Feature request: custom properties in pie/doughnut charts #1185

@jedwards1211

Description

@jedwards1211

I was trying to do this (note Laravel templates are mixed in):

      var byClassChart = new Chart(ctx).Doughnut([
        @foreach ($allocations[$account->id]['by_class'] as $row)
          {
            value: ({{ $row['actual_dollars'] }}).toFixed(2),
            percent: ({{ $row['target_percent'] }}),
            color: colors[color],
            highlight: lightColors[color++],
            label: "{{ $row['asset_class_name'] }}"
          },
        @endforeach
      ], chartOptions); 

      var chartOptions = {
        tooltipTemplate: "<%if (label){%><%=label%>: <%}%><%=formatDollars(value)%> (<%=percent%>%)",
        animation: false,
        responsive: true
      };

However in the console I see that percent is not defined when the template is processed. Why sanitize extra properties out of the JSON passed to the chart? It would be much more convenient if I could do this than anything else.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions