Comments (23)
Interesting, I'm in Chrome 64bit Windows 10. Definitely different to what I'm seeing. I'll take a deeper look tomorrow amd update here.
from d3plus-text.
@davelandry thanks! Yeah, I understand being swamped! I just realized our latest build had the potential to break as a result of an upgrade of d3plus-text
which suddenly reminded me.
I'll try and get on it at some point.
from d3plus-text.
@davelandry This is something I'd like to help out fixing, but I probably need a little guidance on first. I found it a little difficult to follow all the internals and understand what they were actually trying to do.
from d3plus-text.
We actually chose to switch to this behavior, because in use testing in visualizations we found that showing no text was more desirable than to show ...
all over the place.
In your example, you could restore the old behavior by changing your ellipsis function to the following:
.ellipsis(text => text.replace(/\.|,$/g, "") + "...")
from d3plus-text.
@davelandry I still don't find the ellipsis
function working. Could you take a look see what I'm doing wrong? https://jsfiddle.net/IPWright83/uscw0Lh6/2/
from d3plus-text.
@IPWright83 that example jsfiddle looks right to me. What are you expecting to happen? It is resizing the string to fit within the circles.
on a different note, have you seen the d3plus-shape module? makes drawing those circles a lot easier: https://jsfiddle.net/Lz9naLws/
from d3plus-text.
The behavior of the fiddle I posted... The first circle has the reduced size text (great!) but the second circle is just blank just as it was before modifying the ellipsis function. I need to find a way to render some text and ellipsis in that 2nd circle.
I haven't seen the d3plus-shape module, but honestly I prefer the more verbose d3 approach as I know exactly what's going on!
from d3plus-text.
@IPWright83 what is your browser and OS? I see both lines of text in your fiddle using Chrome and macOS:
from d3plus-text.
Took me a while to take a look at this. There must be something different between the measurement in Chrome on Windows because the text isn't even in the DOM for me:
The output is also consistent for me - FireFox, Edge, Chrome all exhibit exactly the same behavior.
from d3plus-text.
@IPWright83 very strange. Would you mind try running this fiddle and share the output and console messages? I think you're right in thinking it might be a different with DOM management.
from d3plus-text.
@davelandry Sure - so the output is the same as the image I shared with you before. The console output is as follows:
The content isn't copying well as a string unfortunately. I logged the outer HTML of each <g>
after the TextBox
function had ran:
from d3plus-text.
@davelandry Just wondering - anything more I can do to help out here?
from d3plus-text.
@IPWright83 clone the repo and start hacking! 😜
but seriously: if I were to start looking somewhere, I would probably start by testing the textWidth
function here: https://github.com/d3plus/d3plus-text/blob/master/src/textWidth.js
from d3plus-text.
@davelandry Yeah sure, I've already got a clone. As per my 2nd comment on the issue - it's quite difficult trying to work out what the internals are actually trying to achieve, hence me not having looked at this already.
Appreciate the suggestion of looking at textWidth
though.
from d3plus-text.
So I've started looking at this again, managed to put aside a couple of days all being well. Interesting thing to note firstly is that the data join inside TextBox.js
to the boxes
variable yields an empty selection the 2nd time through (the circle that displays no text).
from d3plus-text.
@IPWright83 I removed the word truncation, as it was producing some unexpected results in further testing. I may have misunderstood your PR, but we don't want strings like "China" being truncated to "C" or even "C..." when there is very little space. It becomes very confusing to not see the entire word.
Please confirm that this specific issue, subsequent renders on Windows, is still fixed with the latest release.
from d3plus-text.
Hi @davelandry - can I just check, what you expect to see? I find that if I have a single word e.g. "China" that's too long - then what happens is it'll just display nothing (which looks like something broke). In our case we have words that may be quite long "Applications" and we need something there e.g. "App..." to give an indication that there is a value there - you just might not be able to see the entire thing. What sort of unexpected results were you seeing? As this logic only kicks in if there's a single word I believe - to ensure that something renders.
from d3plus-text.
@IPWright83 in that case, I would make it an optional parameter. In the case of Bar Charts, we were seeing a lot of "B...", "A...", "C..." values, and that is not desired.
from d3plus-text.
@davelandry aah I see what you mean.
I did start down that route originally. I was going to use whether the ellipsis
function had been defined to dictate whether or not text should be not visible, or truncated. But discovered it was always defined so changed my mind on that one.
I'll have to take a look at another point in time (and fix our version to .29
) for now, unless you're able to revert/stick an extra flag on it? I guess a truncateSingleWord(bool)
?
from d3plus-text.
@IPWright83 how about just truncateWord(bool)
?
from d3plus-text.
@davelandry Sure - I'm pretty easy. This is your API and as long as it allows a single truncated word I'm happy! :D
from d3plus-text.
@davelandry Just to check - where you planning on adding truncateWord(bool)
to the interface?
from d3plus-text.
@IPWright83 apologies for not being clear enough. It shouldn't be too hard to add (pretty much just putting your original logic behind a boolean), but I'm pretty swamped right now. I've made this separate issue for one of us to grab when either of us has the time. 👍
from d3plus-text.
Related Issues (20)
- add support for italic labels HOT 1
- An in-range update of d3-array is breaking the build 🚨 HOT 1
- Latest changes for 0.9.36 cause text not to render
- An in-range update of d3plus-common is breaking the build 🚨 HOT 1
- detect data from pre-existing DOM elements HOT 3
- Improve wrapping behavior - break mid-word
- textSplit should not filter out all emoji unicode chars HOT 1
- textbox split property should pass through into textWrap.
- D3 and existing SVGs HOT 1
- Pipe character "|" stripped from text
- textWrap issue with overflow and long text HOT 12
- Text is not rendered in IE11 HOT 3
- Click event on wrapped text not triggering on Safari
- add macron detection to textStrip
- Docs and examples seems to be offline HOT 2
- error: transition 1 not found HOT 3
- fontExists always returning false with custom fonts HOT 1
- implement tuncateWord method
- Japanese language should be included in noSpaceRange HOT 2
- add ability to selectively turn off fontExists caching as part of TextBox HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from d3plus-text.