Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-65256

Pie Charts: check if chartLabels are provided in the tooltip

    XMLWordPrintable

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Minor
    • Resolution: Unresolved
    • Affects Version/s: 3.6.3
    • Fix Version/s: None
    • Component/s: JavaScript
    • Labels:
      None

      Description

      Hi all,

      recently I've created a custom dashboard in moodle that show 2 pie chart next to each other but it's happening that, due to the fact their legends are different and occupy different height the pies are different conseguently.

      So i have tought to not show the legend in order to have the pieswith the same size, as in the following code:

      $chart = new \core\chart_pie();
      $s = new \core\chart_series("Name", [10,20,30,40]);
      $s->set_labels(["Label 1", "Label 2", "Label 3", "Label 4"]);
      $chart->add_series($s);

      But, in this case when hovering on the pie an undefined text is showed in the tooltip because the tooltip code tryes to find the chartLabel that aren't provided.

      So I've made this change to the lib/amd/src/chart_output_chartjs.js in order to not show the chartLabels if they are not provided.

      Hope this could be merged in the moodle code base
      Thanks

        Attachments

          Activity

            People

            Assignee:
            Unassigned
            Reporter:
            giannicic Gianni Ciccarelli
            Participants:
            Component watchers:
            Andrew Nicols, Jun Pataleta, Michael Hawkins, Shamim Rezaie, Simey Lameze
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated: