Giter VIP home page Giter VIP logo

d3plus-text's Introduction

d3plus

D3plus is a JavaScript re-usable chart library that extends the popular D3.js to enable the easy creation of beautiful visualizations.

Installing

If using npm, npm install d3plus. Otherwise, you can download the latest release from GitHub or load from a CDN.

import modules from "d3plus";

d3plus can be loaded as a standalone library or bundled as part of D3plus. ES modules, AMD, CommonJS, and vanilla environments are supported. In vanilla, a d3plus global is exported:

<script src="https://cdn.jsdelivr.net/npm/d3plus@2"></script>
<script>
  console.log(d3plus);
</script>

Resources

Examples and documentation are published in a Storybook here. Each example has controls that are able to modified on the fly, documentation for each method used, and an example code output for the d3plus-react configurations.

Modules

D3plus 2.0 is a collection of modules that are designed to work together; you can use the modules independently, or you can use them together as part of the default build. The source and documentation for each module is available in its repository. Follow the links below to learn more.

Core Packages

React Usage

Examples and Documentation

d3plus-text's People

Contributors

cnavarreteliz avatar davelandry avatar greenkeeperio-bot avatar nbond211 avatar rbaheti avatar stocksr avatar t-ohtsuki-cognitee avatar vegertar avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

d3plus-text's Issues

An in-range update of d3plus-common is breaking the build 🚨

Version 0.6.15 of d3plus-common just got published.

Branch Build failing 🚨
Dependency d3plus-common
Current Version 0.6.14
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

As d3plus-common is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this 💪


Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details
Release Notes v0.6.15
  • updates d3-array to v1.1.1 (6f44c40)
  • fix(package): update i18next to version 7.1.2 (#72) (ef501ca)
  • chore(package): update d3plus-dev to version 0.3.1 (#71) (4ee5c5d)
Commits

The new version differs by 4 commits .

  • 6f44c40 updates d3-array to v1.1.1
  • ef501ca fix(package): update i18next to version 7.1.2 (#72)
  • 4ee5c5d chore(package): update d3plus-dev to version 0.3.1 (#71)
  • e93f795 compiles v0.6.14

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Replace includes with indexOf in fontExists to make it compatible with IE11

TypeError: Object doesn't support property or method 'includes' at fontExists

Expected Behavior

Replace includes(fam) in src/fontExists.js in l.29 with indexOf(fam) !== -1 as "includes" is not supported by IE11, current core-js polyfills don't seem to solve the issue for Angular 4 and 5.

Current Behavior

IE11 is not able to render the text nodes.

Your Environment

Angular Core: 4.4.6
Angular Compiler CLI: 4.4.6
Node: 8.11.1
Navigator Platform: Win32
Browser: Internet Explorer 11.0.9600

An in-range update of d3-selection is breaking the build 🚨

Version 1.0.5 of d3-selection just got published.

Branch Build failing 🚨
Dependency d3-selection
Current Version 1.0.4
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

As d3-selection is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this 💪


Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details
Release Notes v1.0.5
  • Update dependencies.
Commits

The new version differs by 3 commits .

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

TextBox issue? Some text being given wrong font size.

Expected Behavior

It appears that text that does not need to wrap lines is being given the font size of a previous TextBox.

Current Behavior

image

Steps to Reproduce (for bugs)

http://jsfiddle.net/cjk1g1kr/8/ takes a min to load all the data I'm throwing at it.

Your Environment

Chrome, W 7 Pro

It could very possibly be my code. But I'd appreciate any insight and ideas for a workaround.
Thanks

add ability to selectively turn off fontExists caching as part of TextBox

Expected Behavior

When you call .font('my custom font') and that font is defined in a @font-face rule in css. Then the font should be downloaded and used.

Current Behavior

When you call .font('my custom font') and that font is defined in a @font-face rule in the css. Then provided some the browser has already finished downloading the font, it works correctly. If however that font is not yet available then the font is blacklisted for the duration of page. (I am writing a SPA so this could be a very long time.)

Steps to Reproduce (for bugs)

  1. Add this css @font-face { font-family: 'X-Custom'; src: url(http://fonts.gstatic.com/s/dancingscript/v9/If2RXTr6YS-zF4S-kcSWSVi_szLgiuQHiC4W.ttf) ; }
  2. Create a text box as usual including .font('X-Custom')
  3. Note that the font is not used.
  4. Now add a

    Sample

    to the page
  5. Create the SVG text on page load and note that the font does not get used.
  6. Delay the SVG text until the font is loaded and note that it does work.

detect wrapping bounds based on a shape

The current version of text wrapping in D3Plus v1 will extract x, y, width, and height from a shape placed adjacent to the text (either a <rect> or a <circle>).

One of our goals with these new modules is to sort of "demystify" a lot of the magic that happens behind the scenes to allow better control over all aspects of the functions. That being said, this is a killer feature that should be migrated over.

My initial thought is to have the .select( ) method also support being passed a shape instead of a container, and in that case, extrapolate the values from that shape and insert the new text element immediately after it in the DOM. Shouldn't be too hard.

I think that this can also be coded in a way so that if the shape's properties change, the text will re-wrap if called again.

An in-range update of d3-transition is breaking the build 🚨

Version 1.0.4 of d3-transition just got published.

Branch Build failing 🚨
Dependency d3-transition
Current Version 1.0.3
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

As d3-transition is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this 💪


Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details
Release Notes v1.0.4
  • Fix string coercion in transition.style and transition.attr. Thanks, @sghall! (#67)
  • Update dependencies.
Commits

The new version differs by 4 commits .

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

implement tuncateWord method

Expected Behavior

Based on logic previously implemented by @IPWright83 here and the discussion here, users should be able to set .truncateWord(true) to enable truncating a string in the middle of a word.

Current Behavior

The current default behavior is to always show whole words.

An in-range update of d3-array is breaking the build 🚨

Version 1.0.3 of d3-array just got published.

Branch Build failing 🚨
Dependency d3-array
Current Version 1.0.2
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

As d3-array is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this 💪


Status Details
  • continuous-integration/travis-ci/push The Travis CI build could not complete due to an error Details
Release Notes v1.0.3
  • Update dependencies.
Commits

The new version differs by 6 commits .

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

TextBox with auto resize bug

Expected Behavior

When using the TextBox with the fontResize set to true and passing a width and height, I expect the text to be wrapped to that container. In some cases depending on the text length and having a small width and big height, that doesn't happen.

Current Behavior

The text is enlarged way to much and goes out of the container bounds.

Steps to Reproduce (for bugs)

Provided a JSFiddle that reproduced the bug here: https://jsfiddle.net/74pg8we4/10/
Note that the big ok is the wrong behaviour, the small okkkkkk is what should happen.

image

multiple define functions present when uglifying

Hi you are doing a great job creating this module. But I am unable to use this in my project as it always throws up the error box is undefined. Can you please provide us with some usage examples?

Also I am getting an error saying multiple define functions present when i uglifying my project with the help of grunt and require.js, It would be great if you could help me regarding this.

Japanese language should be included in noSpaceRange

Thank you so much for this awesome library!
Without TextBox I would have wasted several days :)
I was a bit confused when I used TextBox with Japanese text,
as the wrapping function seemed to be broken against it.
After looking into the source for a moment, I found the reason:
Japanese too should be included in noSpaceRange variable in src/textSplit.js !

Typical Japanese texts like "日本語は基本的にはスペースを含みません" have no space inside them!
See e.g., Japanese Wikipedia article like https://ja.wikipedia.org/wiki/JavaScript.

no text appearing in subsequent renders on Windows

With the font resizing on, if there isn't enough space instead of adding ellipsis on it simply doesn't add any text.

Expected Behavior

Ellipsis if there isn't space for the text. In this provided example I would expect the last 3 characters that can be rendered to be missed off ABCDEFGHIJKLMNOPQRSTUVWXY...

Current Behavior

No text is added to the DOM

Steps to Reproduce (for bugs)

https://jsfiddle.net/IPWright83/uscw0Lh6/1/

I'm using the following where radius = 150 and I'm using 2 strings:
ABCDEFGHIJKLMNOPQRSTUVWXYZ12 and ABCDEFGHIJKLMNOPQRSTUVWXYZ123

new d3plus.TextBox()
    .data([d])
    .select(elements[i])
    .fontResize(true)
    .height(radius)
    .width(radius)
    .text(d => d.name)
    .x(d => -radius / 2)
    .y(d => -radius / 2)
    .ellipsis((text, line) => line ? text.replace(/\.|,$/g, "") + "..." : "")
    .verticalAlign("middle")
    .textAnchor("middle")
    .render();  
  });

Cannot append d3plus-text word wrap inside d3 code.

I am currently using d3plus-text library for text wrapping and dynamic font-size rendering. But somehow it is not getting affected in the chart.

I have the following piece of code:
var paths = markets.append("text")
.text(function(d) { return d.market + ": " + n(d.value);})

              .attr("x",0)
              .attr("y", function(d) { return y(d.offset / d.parent.sum)+20; })
              .each(function(d){
            	  d3plusText.TextBox().select(d3.select(this)).fontsize([8,20])render();
              }) ;

Please suggest how to append a textbox layer using d3plus-text inside d3.js.

lineHeight not respected when using fontResize

Expected Behavior

When setting fontResize(true), the line-height should respect the difference between the default fontSize and the lineHeight value.

Current Behavior

Currently, it seems to be statically set.

Steps to Reproduce (for bugs)

https://jsfiddle.net/pemwzcc3/1/

Your Environment

  • Browser Name: Chrome
  • Operating System and Version: macOS High Sierra

An in-range update of d3plus-dev is breaking the build 🚨

Version 0.4.11 of d3plus-dev just got published.

Branch Build failing 🚨
Dependency d3plus-dev
Current Version 0.4.10
Type devDependency

This version is covered by your current version range and after updating it in your project the build failed.

As d3plus-dev is “only” a devDependency of this project it might not break production or downstream projects, but “only” your build or test tools – preventing new deploys or publishes.

I recommend you give this issue a high priority. I’m sure you can resolve this 💪

Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details

Release Notes v0.4.11
Commits

The new version differs by 35 commits.

There are 35 commits in total.

See the full diff

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Help : Use case with D3

Hello,

I am trying to make d3plus-text work with my circle packing (d3 v4) but I do not understand how to integrate it. Can you please help me understand how it works so that my texts are wrapped in their container.

Thank you

Actually :

  var text = g.selectAll("text")
    .data(nodes)
    .enter().append("text")
      .attr("class", "label")
      .attr('dy', '.35em')
      .style("fill-opacity", function(d) { return d.parent === root ? 1 : 0; })
      .style("display", function(d) { return d.parent === root ? "inline" : "none"; })
      .text(function(d) { 
            return d.data.name; 
        })
    ;

verticalAlign breaks with rotation

Expected Behavior

When rotating a TextBox, setting the verticalAlign should respect the rotation.

Current Behavior

Currently, it just moves the label down vertically.

Steps to Reproduce (for bugs)

https://jsfiddle.net/5hafqu6b/

Your Environment

  • Browser Name: Chrome
  • Operating System and Version: macOS High Sierra

text wrapping for double byte languages

Google Group: https://groups.google.com/forum/#!topic/d3plus/Mm0f2JW7asg

Does anyone have experience using the text wrapping functions with double-byte languages like simplified Chinese?

I am told they typically don’t use spaces so the wrapping functions do not know where to break and wrap. I get one long (unwrapped) line of characters.

Is there any way to detect word breaks? How do HTML div containers handle this? Should we just check for breaks between each character?

Max number of lines

In the same way that text-wraps but could truncate with an ellipsis, it would be good to have a maximum number of lines limit too, because even with wrapping sometimes the content is too long.

Instead of:
image

Producing:
image

I'm thinking of having a truncateLines(n) or similar function on the configuration.

advanced overflow options

Thank you for making this a standalone module. It took me some time to figure out the new API so perhaps I am missing something.

What I am seeing is that if a word is too long for the bounding box it is omitted completely. I believe this is happening here: https://github.com/d3plus/d3plus-text/blob/master/src/box.js#L189 . If I comment out this line the labels that are too long for the bounding box overflow. Not sure if this is by design, perhaps it should be an option at least.

I'm using the module like this:

      const box = d3plusText.box()
        .textAnchor('middle')
        .fontSize(14)
        .width(d => d.values.length * boxWidth + 5)
        .text(d => d.key.replace(/_/g, ' '))
        .height(45);

      subplot.append('g')
        .attr('class', 'boxLabelText')
        .attr('transform', 'translate(-5,0)')
        .each(function (d) {
          box
            .data([d])
            .select(this)();
        });

Please provide more usage examples

Hey!

I'm trying to swap my code from using the text-wrapping utility in d3plus to this module, but I'm struggling to understand how I'm supposed to use it. I'd be happy to contribute some docs once I get my head around it.

My current code has some circular nodes which have data associated with them. This is how I insert the labels:

nodeData
    .append('text')
    .text(function(node) {
        return node.name;
    })
    .each(function() {
        d3plus.textwrap()
            .container(d3.select(this))
            .shape('circle')
            .draw();
    });

How would I convert this to using d3plus-text? I have managed to get the box method to insert tspans into the page based on the data I give it (by passing through the full node data array at once), but I want to wrap text that is associated with individual nodes on my page (the nodeData array).

Thanks in advance,

Helen

long text issue

I got another issue with the long text rendering, the rendering text is: "建立客户信息反馈机制,跟踪解决过程,问题解决率达到80%以上", when run with TextBox().overflow(true), throwing the following error:

d3plus-text.js:210 Uncaught TypeError: Cannot read property 'trimRight' of undefined

if use with .overflow(false), the output only includes '...'
I'm using the version 0.9.8

further test shows the issue is related to Chinese symbols, such as ',' in the above sentance

text wrapping doesn't work properly when sentence contains both Chinese and English

Hi, I've read your blog post https://blog.datawheel.us/english-is-not-chinese-69b43959bb47, thanks for the work! But the example does not work when Chinese is combined with English, when putting an English sentence between, spaces between English words does not show up.

Expected Behavior

Spaces of English words show correctly

Current Behavior

Spaces between English words disappears

Steps to Reproduce (for bugs)

http://jsfiddle.net/gest45z9/12/

Your Environment

  • Browser Name: Chrome
  • Operating System and Version: MacOS Sierra v10.12.6

break line at newline escape character

Is this within the scope of the library? something I thought would be useful.

Here is an example use case:

  1. text string to split of string 1\nstring 2
  2. string 1 & string 2 will have separate tspan elements regardless of it they fit on the same line (ellipsis would still show if it overflows too far):

Result:

---------------
string 1
string 2
---------------

NOT

---------------
string 1 string
 2
---------------

An in-range update of d3-array is breaking the build 🚨

Version 1.1.1 of d3-array just got published.

Branch Build failing 🚨
Dependency d3-array
Current Version 1.1.0
Type dependency

This version is covered by your current version range and after updating it in your project the build failed.

As d3-array is a direct dependency of this project this is very likely breaking your project right now. If other packages depend on you it’s very likely also breaking them.
I recommend you give this issue a very high priority. I’m sure you can resolve this 💪


Status Details
  • continuous-integration/travis-ci/push The Travis CI build failed Details
Release Notes v1.1.1
  • Update dependencies.
Commits

The new version differs by 2 commits .

See the full diff.

Not sure how things should work exactly?

There is a collection of frequently asked questions and of course you may always ask my humans.


Your Greenkeeper Bot 🌴

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.