# Plot: displaying "sum" in text mark

**URL:** <https://talk.observablehq.com/t/plot-displaying-sum-in-text-mark/6493>\
**Category:** Help\
**Created:** [April 28, 2022, 8:23pm UTC](https://talk.observablehq.com/t/plot-displaying-sum-in-text-mark/6493 "2022-04-28T20:23:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mferro64](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mferro64/32/6421_2.png) [@mferro64](https://talk.observablehq.com/u/mferro64)\
**Post date:** [April 28, 2022, 8:23pm UTC](https://talk.observablehq.com/t/plot-displaying-sum-in-text-mark/6493/1 "2022-04-28T20:23:34Z")

</div>

I have been trying to display the “sum” values of a group transform in the bar chart.  
Here is the plot code.

```auto
Plot.plot({
  marginLeft:125,
  marginRight:50,
  width: 600,
  height: 300,
  x: {
    grid: true
  },
  marks: [
    Plot.barX(dashboard_data, Plot.groupY({x: "sum"}, {x: "article_count", y: "topic"})),
    Plot.text(dashboard_data, Plot.groupY({x: "sum"}, {x: "article_count", y: "topic", text: "article_count", textAnchor: "end", dy: 10})),
    Plot.ruleX([0])
  ]
})

```

Thanks!

---

<div class="post-metadata">

**Author:** ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)\
**Post date:** [April 28, 2022, 8:59pm UTC](https://talk.observablehq.com/t/plot-displaying-sum-in-text-mark/6493/2 "2022-04-28T20:59:12Z")

</div>

You can add `text` to the output of the group transform:

```nohighlight
Plot.text(dashboard_data, Plot.groupY({text: "sum", x: "sum"}, {x: "article_count", y: "topic", text: "article_count", textAnchor: "end", dy: 10}))

```

---

<div class="post-metadata">

**Author:** ![mferro64](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mferro64/32/6421_2.png) [@mferro64](https://talk.observablehq.com/u/mferro64)\
**Post date:** [April 28, 2022, 9:27pm UTC](https://talk.observablehq.com/t/plot-displaying-sum-in-text-mark/6493/3 "2022-04-28T21:27:53Z")

</div>

Thanks - that worked great! I added a filter but do not see the sum text?

```auto
Plot.barX(dashboard_data.filter(d => d.time_period === timeselect), Plot.groupY({x: "sum"}, {x: "article_count", y: "topic", fill: "topic", fillOpacity: 1})),
Plot.barX(dashboard_data.filter(d => d.time_period === timeselect), Plot.groupY({text: "sum", x: "sum"}, {x: "article_count", y: "topic", text: "article_count", textAnchor: "start", dx: 10})),

```

---

<div class="post-metadata">

**Author:** ![mbostock](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbostock/32/9_2.png) [@mbostock](https://talk.observablehq.com/u/mbostock)\
**Post date:** [April 28, 2022, 10:52pm UTC](https://talk.observablehq.com/t/plot-displaying-sum-in-text-mark/6493/4 "2022-04-28T22:52:42Z")

</div>

Looks like you need Plot.text instead of Plot.barX in the second line?

---

<div class="post-metadata">

**Author:** ![mferro64](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mferro64/32/6421_2.png) [@mferro64](https://talk.observablehq.com/u/mferro64)\
**Post date:** [April 28, 2022, 11:38pm UTC](https://talk.observablehq.com/t/plot-displaying-sum-in-text-mark/6493/5 "2022-04-28T23:38:21Z")

</div>

That was it - thanks!
