Caleb Faruki
Caleb Faruki

Reputation: 2725

getting additional value fields from data source for dx.chartjs doughnut chart

For my chart, I use pieChartDataSource as my doughnut chart's data source. I've been pouring over the documentation to figure out a way to, instead of labeling the segments with valueField, display an additional field that is not the argumentField.

In my console, I know that pieChartDataSource has the field I am looking for. It is an array of objects. Each object has several fields of which I have product as the argumentField and count as the valueField. My presumption is that I somehow have to use the tagField in order to pass additional properties.

To reiterate, I want to display owner (a third value), instead of product in the segment label of my chart. How would I customize the label so that it shows the owner?

// ...
dataSource: pieChartDataSource,
// ...
series: { type: 'doughnut',
          argumentField: 'product',
          valueField: 'count',
          tagField: 'owner',
          valueType: 'numeric',
          label: { visible: true,
                   font: {
                           family: 'sans-serif',
                         },
                   connector: { visible: false },
                   radialOffset: 0,
                   position: 'inside',
                   rotationAngle: 0,
                   customizeText: function () {/* use tagField here? */},
                 },
// ...

Upvotes: 0

Views: 1068

Answers (1)

Pavel Gruba
Pavel Gruba

Reputation: 2049

Can retrieve tag from point, that is an attribute of customizeText parameter

label: {
    customizeText: function () {
        return this.point.tag;
    }
}

Upvotes: 1

Related Questions