Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exposure statistics: bold out the asset class name for sector exposure #90

Closed
MonikaFu opened this issue Nov 29, 2024 · 4 comments · Fixed by #106
Closed

Exposure statistics: bold out the asset class name for sector exposure #90

MonikaFu opened this issue Nov 29, 2024 · 4 comments · Fixed by #106
Assignees
Labels
ADO Also Tracked on Azure DevOps plot

Comments

@MonikaFu
Copy link
Contributor

MonikaFu commented Nov 29, 2024

Making 'Corporate bonds' bold in this case would draw attention of the user more to the fact that the percentage is of the asset class portion of the portfolio and not the entire portfolio.

image

AB#12275

@MonikaFu MonikaFu added ADO Also Tracked on Azure DevOps plot labels Nov 29, 2024
@cjyetman
Copy link
Member

cjyetman commented Dec 3, 2024

I think if you add this

.style('font-weight', (d, i) => i == 2 ? 'bold' : 'normal')

to the end of this block

let label_sector = ['of the', asset_class, 'portion of portfolio'];
svg
.append('g')
.attr('transform', 'translate(' + [sector_position_x, text_position_y] + ')')
.selectAll('text')
.data(label_sector)
.enter()
.append('text')
.attr('transform', (d, i) => 'translate(0, ' + i * 15 + ')')
.text((d) => d)
.style('dominant-baseline', 'middle')
.style('text-anchor', 'end');

with the logic that the 2nd element of the data, asset_class, will get font-weight: bold added to its style attribute, and the first and third will get font-weight: normal leaving them unchanged (assuming there's no other CSS already changing them).

note that, I'm not 100% sure what is the intent of this issue...
I'm assuming that you want
of the Corporate Bonds of the portfolio
to be
of the Corporate Bonds of the portfolio (<- Corporate Bonds is bold here even though I can barely tell in GitHub's rendering)
where only "Corporate Bonds" (or whatever other value that bit of text is filled with) is bold and the rest if left normal

@jdhoffa
Copy link
Member

jdhoffa commented Dec 3, 2024

.style('font-weight', (d, i) => i == 2 ? 'bold' : 'normal')

Can I ask why we need both d and i there?

@jdhoffa
Copy link
Member

jdhoffa commented Dec 3, 2024

Implemented and it seems to work in #106

@cjyetman
Copy link
Member

cjyetman commented Dec 3, 2024

.style('font-weight', (d, i) => i == 2 ? 'bold' : 'normal')

Can I ask why we need both d and i there?

The first argument passed to the arrow function will be the element/item, and second will be the iterator/index. You don't really have a choice with that (that's what D3's .style() does), but you can name them whatever you want (though d and i are very common), e.g.

.style('font-weight', (elem, idx) => idx == 2 ? 'bold' : 'normal')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ADO Also Tracked on Azure DevOps plot
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants