user7136014
user7136014

Reputation:

How to pass the string in Morris Donut value

How to pass the string in morris donut under data array value. i have a morris donut like this Donut 1 And this is my code. I want like this Donut. Donut 2

Morris.Donut({
  element: 'donut-example',
  data: [
    <?php foreach ($pay as $r_pay): ?>
      {label: 'Level Name: <?= $r_pay['level_id']; ?>',value: '<?=$r_pay['total']; ?>'},
    <?php endforeach; ?>
  ]
});

Upvotes: 2

Views: 1274

Answers (1)

WEBjuju
WEBjuju

Reputation: 6581

In the Morris Documentation it indicates that along with element and data one may also add formatter which

will translate a y-value into a label for the centre of the donut.

Here is an example:

Morris.Donut({
  element: 'donut-example',
    data: [
      {label: "Download Sales", value: 12},
      {label: "In-Store Sales", value: 30},
      {label: "Mail-Order Sales", value: 20}
    ],
  formatter: function (y, data) { return 'Due Amount: ' + y }
});

Which produces this:

enter image description here

Upvotes: 4

Related Questions