Legend custom expresion

I have a legend for my chart where i want to make it look like this:

Field234 .......................7%


How would i make the   formula work so that it puts the dots and the percent fields are lined up even? This is what i tried but it did not work

=Fields!SectorName.Value & space(30 - Len(Fields!SectorName.Value))  & FormatPercent(Fields!PCT.Value, 1)

Open in new window

Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Nico BontenbalCommented:
As you can see in your example you had to type 5 more spaces behind Fileaa then behind Field234 to get the numbers (roughly) lined up. This is because not every character on a modern font takes up the same space. for example:
So you can't just replace a character with a space and expect everything to align nicely.

So you need to use a mono-spaced font like 'Courier New' or 'Lucida Sans Typewriter'.
vbnetcoderAuthor Commented:
is there some way that i could replace space with ....... the customer would prefer that anyway.
vbnetcoderAuthor Commented:
OK i was able to do that but it didn't solve the alignment issue for the reason you mentioned.
Nico BontenbalCommented:
Ah, my mistake. I interpreted the dots as placeholders for the spaces. You can use
StrDup(30 - len(Fields!SectorName.Value),".")

Open in new window

to use any character you want.
I think using another font (like  'Courier New' or 'Lucida Sans Typewriter') is the easiest way to solve the alignment issue.
Another way might be to create your own 'legend'. You could create a table with the information you now try to get in the legend. One problem there is that you need to 'know' the colors that are used in the chart. The easiest way to do this is by using a custom pallet. See:
That way you'll determine your own colors and then you can use the same colors in the table based on the row number.
The other problem is that this table is outside the chart.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
vbnetcoderAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.