In the below image, is it possible to remove the “k” following the numbers in the hover text and/or the y-axis and replace it with the number and a comma? For example, 81.014k → 81,014.
Here’s an example of my trace code:
var trace3 = {
type: "scatter",
mode: "lines",
name: 'Massachusetts',
x: unpack(rows, 'year'),
y: unpack(rows, 'MA_adm'),
line: {
dash: 'solid',
color: colors[2]
}
}
Posted too soon–just figured out how to put in commas in the hover text. Any help with doing the same in the y-axes would be appreciated!
I believe you can change the yaxis tickformat to ‘g’ to get rid of the ‘k’ . There is more detail on the allowed formatting at the following link.
> [API Reference](API-Reference.md) ▸ [Core](Core.md) ▸ **Formatting**
**The [D3 4.0 API Reference](https://github.com/d3/d3/blob/master/API.md) has moved. This page describes the D3 3.x API.**
Formatting numbers is one of those things you don't normally think about until an ugly "0.30000000000000004" appears on your axis labels. Also, maybe you want to group thousands to improve readability, and use fixed precision, such as "$1,240.10". Or, maybe you want to display only the significant digits of a particular number. D3 makes this easy using a standard **number format**. For example, to create a function that zero-fills to four digits, say:
```javascript
var zero = d3.format("04d");
```
Now you can conveniently format numbers:
```javascript
zero(2); // "0002"
zero(123); // "0123"
```
In addition to numbers, D3 also supports formatting and parsing [dates](Time-Formatting.md), and [comma-separated values](CSV.md).
## Numbers
This file has been truncated. show original
How did you put commas in the hover text?
1 Like
Sorry for the late reply!
var layout = {
yaxis: {
tickformat: ",.0f",
}
}
1 Like
Use this
yaxis=dict(
tickformat=‘d’ # This removes the comma from the numbers
),