News for hackers. Stuff that matters.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by anoother on Wednesday March 18, 2015 @08:30AM (#9224928)
This is lovely. When I see this, I don't think 'patterns', rather, 'hatches'.

Makes me wonder what the state of modern SVG is w.r.t. real-world units - something like this really makes SVG look useful for for technical drawing, but pixels are not the best unit to draw to...

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by hardmath123 on Wednesday March 18, 2015 @04:03PM (#9228286)
Hmm, an Asymptote to SVG renderer would be pretty useful for displaying mathematical diagrams on the web.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by ttty on Wednesday March 18, 2015 @10:10AM (#9225550)
I never like how they chain methods. A better way would be:

    texture({lines: true, heavier: true, stroke: 'red'})
Is easier to configure if you need reusable textures.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by mbostock on Wednesday March 18, 2015 @02:02PM (#9227424)
Aren’t these textures already reusable? The constructed texture object (the result of textures.lines(), e.g.) can be called on as many selections as you like to reuse it.

I feel it’s a matter of taste, but one practical reason I prefer chaining to configuration objects is that you get a runtime error when you misspell a property, rather than it being silently ignored.

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by ttty on Wednesday March 18, 2015 @06:51PM (#9229183)
Image you have an UI which talks to this. For example you have a button on/off. How would you do?

    var t = texture().lines().stroke('red')
    if(this.button.on) t= texture.heavier()
Compare the previous with this one.

    var t = texture({lines: true, heavier: this.button.on, stroke: 'red'})
I also hate the non standard constructor: this should be like this

    var texture = new Texture({lines: true, heavier: this.button.on, stroke: 'red'});
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by siddboots on Wednesday March 18, 2015 @11:53PM (#9230118)
"heavier: this.button.on" has ambiguous semantics. Do libraries really use this pattern?

Also, use of the "new" keyword is contentious. You can hardly pretend that it is best practice.

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by ricsca on Thursday March 19, 2015 @10:50AM (#9232300)
It should be

    var t = texture().lines().stroke('red')
    if(this.button.on) t.heavier()
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by ricsca on Wednesday March 18, 2015 @10:23AM (#9225647)
Interesting point. I simply relied o this post of Mike Bostock http://bost.ocks.org/mike/chart/.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by wayfarer2s on Wednesday March 18, 2015 @10:59AM (#9225943)
An initial config object would probably be ideal, and then you could have the chaining to supplement those values. You could have the initial method take in the config and use the values in that in place of the defaults. So

  textures.circles()
    .radius(4)
    .fill("transparent")
    .strokeWidth(2);
could initially be

  var circles = textures.circles({
    radius: 4,
    fill: "transparent",
    strokeWidth: 2 
  });
and later updated to be

  circles.strokeWidth( 1 );
Which works rather nicely especially when the config object is generated dynamically.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by bkirwi on Wednesday March 18, 2015 @12:32PM (#9226680)
Yeah, it makes sense to mimic the D3 style: the only thing worse than a bad convention is two conventions.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by findjashua on Wednesday March 18, 2015 @10:38AM (#9225762)
imho, if the operations are to be performed in a certain order, use chaining. Otherwise, passing a config object is much cleaner
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by swayvil on Wednesday March 18, 2015 @10:24AM (#9225653)
That's so tasty. Like tomato soup for my eyeballs.

I encountered the same issue in my project : 2 levels of polygon-distinguishment. Made a set of 1 bit seamless textures.

http://glowinggreenhand.blogspot.com/2014/01/i-made-bunch-of...

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by ricsca on Wednesday March 18, 2015 @10:36AM (#9225744)
:D thanks! Very good point.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by bennstancil on Wednesday March 18, 2015 @04:56PM (#9228632)
This is pretty cool. I made a really basic example, but in doing it, I could imagine playing around with having the colors or orientation change with the data as well. And it might make for cool transitions too. That obviously get way too complicated pretty quickly, but it'd be fun to see what you could come up with that might work.

https://modeanalytics.com/benn/reports/a4515d9b9024

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by collyw on Wednesday March 18, 2015 @08:36AM (#9224957)
Looks just like the old Mac before they got colour.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by marxidad on Wednesday March 18, 2015 @10:16AM (#9225594)
Isn't this what Tufte refers to as "chartjunk"?
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by jweir on Wednesday March 18, 2015 @10:24AM (#9225654)
Tufte points out 1 + 1 is 3 or more visually. The two lines create two elements, then the space is another, then the space on either is potentially another.

http://csarven.ca/one-plus-one-equals-three-or-more

These textures are noisy. There can be occasions to use textures, but these examples would work just as well with shades of gray.

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by ricsca on Wednesday March 18, 2015 @10:45AM (#9225815)
Interesting point of view. Choices of style apart, there are situations where textures are useful. Like for example the case faced by swayvil (see the comment), or when you need b/w printable images. Another good reference is "Semiology of Graphics" of Jacques Bertin, he has a good opinion about textures.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by jweir on Wednesday March 18, 2015 @10:55AM (#9225904)
"Semiology of Graphics" is a great book, but this was published in the 1960s when those graphs where drafted by hand and color printing was probably not an option.

I am ignorant as to what tools a draft-mans hand for shading then, but I am sure hatching would be easier than creating a fine range of halftone grays.

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by jacobolus on Wednesday March 18, 2015 @06:39PM (#9229126)
Here’s what Tufte says:

> Can optical art effects ever produce a better graphic? Bertin exhorts: “It is the designer’s duty to make the most of this variation; to obtain the resonance [of moiré vibration] without provoking an uncomfortable sensation: to flirt with ambiguity without succumbing to it.” But can statistical graphics successfully “flirt with ambiguity”? It is a clever idea, but no good examples are to be found. The key difficulty remains: moiré vibration is an undisciplined ambiguity, with an illusive, eye-straining quality that contaminates the entire graphic. It has no place in data graphical design.

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by ncza on Wednesday March 18, 2015 @10:49AM (#9225848)
Tufte is not that omnipotent, did he even ever consider colorblindness? Hatches are awesome substitution for color.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by jacobolus on Wednesday March 18, 2015 @06:42PM (#9229141)
Of course he did consider color blindness.

Tufte recommends Imhof’s book Cartographic Relief Presentation on the subject of choosing colors for data graphics, and I’d second the recommendation.

Or for something online, take a look at Cynthia Brewer’s work.

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by jacobolus on Wednesday March 18, 2015 @06:35PM (#9229115)
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by Hytosys on Wednesday March 18, 2015 @08:42AM (#9224985)
Awesome for colorblind people! Looking forward to using this.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by jweir on Wednesday March 18, 2015 @10:25AM (#9225661)
Shades of gray would work as well.

Also checkout http://colorbrewer2.org/

It has an option for creating color sets which are "colorblind safe."

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by Fiahil on Wednesday March 18, 2015 @08:56AM (#9225063)
Very good attention to details! (like the position of circle patterns on edges of shapes)

Have a star, you deserve it :)

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by dylanrw on Wednesday March 18, 2015 @11:57AM (#9226381)
Masterful use of contrast and texture. Data vis can stand to have more of this.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by ricsca on Wednesday March 18, 2015 @12:03PM (#9226431)
Wow! Thanks.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by matt4077 on Wednesday March 18, 2015 @08:53AM (#9225042)
Loving the retro look. But I'm not sure if patterns are as good as colors in communicating data. As soon as the data has even an ordinal scale, gradients or hues should work better.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by detaro on Wednesday March 18, 2015 @08:56AM (#9225066)
Patterns are useful if it is intended to be printed (or for other b/w media). For good color prints or screen usage I agree, colors often can do a better job.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by kenbellows on Wednesday March 18, 2015 @10:10AM (#9225544)
You are probably right if the data you're representing is scaled, but this sort of solution is fantastic for categorical data. Also, see other comments re: accessibility for colorblindness. Not necessarily a silver bullet, but possibly a solid solution in some circumstances.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by Normangorman on Wednesday March 18, 2015 @10:07AM (#9225528)
Patterns are actually much better for colour-blind people like myself.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by ricsca on Wednesday March 18, 2015 @09:19AM (#9225198)
Textures and colors can be combined, for example if you need to select according two different group of categories/variables.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by swah on Wednesday March 18, 2015 @10:00AM (#9225476)
I wish we could have written the documentation for my current project in the browser instead of LaTeX.

But the need to produce good PDFs killed the idea.

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by gearhart on Wednesday March 18, 2015 @10:29AM (#9225687)
We've had good success with wkhtmltopdf

All of our invoices and reports are built for the web and then converted on the fly to pdfs and emailed out to clients who prefer them that way. You lose the interactivity, which is a shame for some d3 reports, and you have to be a little careful (design for page breaks, test it as if it's a slightly fickle browser that you have to support, ensure that everything is visible without requiring interaction) but it keeps all of your development within the same tool stack and gives you web versions of them all for free.

For reference, I ran it on the textures.js page and put the results here: https://drive.google.com/file/d/0B5BP6Na7GalZOXdWdlh6MElWTDQ...

It's pretty good.

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by reverius42 on Wednesday March 18, 2015 @11:56AM (#9226367)
Check out GitBook. They build from Markdown/HTML and can produce interactive HTML and/or PDF.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by swah on Wednesday March 18, 2015 @02:14PM (#9227510)
Oh, I looked into it, but if you compare with LaTeX, its pretty simple, but we need references, and footnoes, and complex tables, so we would need an extended version, and preprocess it, and.. might as well use LaTeX.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by sairion on Wednesday March 18, 2015 @12:16PM (#9226551)
It reminds me of Semiology of Graphics by Bertin. Nice work! I would like to work on React port, only if I have a spare time...
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by OliverM on Wednesday March 18, 2015 @08:43AM (#9224988)
This is lovely. I've hand-coded solutions before to show two variables by region simultaneously (e.g. voting patterns by socio-economic levels:http://imgur.com/ww1WV66). Colour and texture are nicely independent for showing this stuff.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by neumann on Wednesday March 18, 2015 @09:47AM (#9225388)
very nice. One tangential question, the example svg maps are not created in the browser. How are these typically created?

When I make SVGs they are typically either plots made with a plotting tool, or paths created from tracing or done purely by hand.

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by ricsca on Wednesday March 18, 2015 @09:54AM (#9225430)
I did it with d3.js and topojson, then I used the resulting svg image on the website. You can find the code here https://github.com/riccardoscalco/textures/blob/gh-pages/map...
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by ncza on Wednesday March 18, 2015 @10:52AM (#9225874)
In my opinion the "right" way for static things. Keeps the browser from computing, no need for the original data and libs. Of course being able to inspec other people's d3 code is fun on the other hand.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by neumann on Wednesday March 18, 2015 @11:50AM (#9226320)
Thanks for the update! I was unaware of the power of geoJSON (also githubs neat mapping of them) and access to data from places such as gadm.org. Is that where you source the data?
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by BaconJuice on Wednesday March 18, 2015 @08:26AM (#9224919)
Thank you for sharing this! Can't wait to use this soon :)

Slightly off topic but maybe some SVG expert can help me out with a quick question! Is there a way to identify and automatically recognize all numbers in an image.svg file?

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by ygra on Wednesday March 18, 2015 @09:04AM (#9225116)
What kind of numbers? Those appearing alone in attributes, such as <rect width='10' height='5'/>? Those appearing in path or polygon data are more complicated, as the syntax allows whitespace, commas, etc. as separators, but they're not needed in some cases. E.g.

    M0-1.2.5-3
is perfectly valid (AFAIR, not sure about the decimal points now), but not really nice to parse or extract.

The main point would be what your use case is? If you just need to transform something, e.g. translate or scale a shape it's easier to put a group around it and apply a transform on that.

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by mmf on Thursday March 19, 2015 @08:12AM (#9231333)
This library is fantastic. These patterns are essential in the production of print-ready and print-like contents.

With the high resolution screens available today these make for stunning graphical presentation.

Re:Show HN: Textures.js, SVG Patterns for Data Visualization by emehrkay on Wednesday March 18, 2015 @10:28AM (#9225682)
Thanks for this. I need to learn SVG for something that I am working on now, this library looks like it has a great interface for me to learn from.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by pdknsk on Wednesday March 18, 2015 @12:49PM (#9226820)
I just want to point out that many of the line textures can also be made with repeating-linear-gradient() from CSS, perhaps more efficiently so.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by jwiley on Wednesday March 18, 2015 @10:50AM (#9225849)
This is lovely, congrats to the author
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by jpatel3 on Wednesday March 18, 2015 @08:18PM (#9229524)
Wonderful! What are the best use case for using this patterns apart from geo graph representation?
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by rcazangi on Wednesday March 18, 2015 @12:30PM (#9226667)
Indeed, original and very useful. Exactly what I've been seeking... for some time.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by paulliwali on Wednesday March 18, 2015 @08:20AM (#9224899)
Wow, this is really sweet. Can't wait to use it in my next project.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by degroote on Wednesday March 18, 2015 @08:44AM (#9224994)
Great project, just needed such a texture for an app. Thanks!
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by ricsca on Wednesday March 18, 2015 @09:55AM (#9225444)
Many thanks for the good words! I am happy you like it.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by radiodario on Wednesday March 18, 2015 @08:15AM (#9224886)
this is awesome! excellent for monochrome.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by b4x on Wednesday March 18, 2015 @09:06AM (#9225126)
Lovely. Style from Italy.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by hackerews on Wednesday March 18, 2015 @03:42PM (#9228149)
Incredibly well done.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by kenrick95 on Wednesday March 18, 2015 @08:58AM (#9225076)
Very beautiful :D
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by bujatt on Wednesday March 18, 2015 @11:44AM (#9226287)
beautiful!
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by frik on Wednesday March 18, 2015 @01:08PM (#9226997)
Reminds me of the AutoCAD patterns, back in school.
Re:Show HN: Textures.js, SVG Patterns for Data Visualization by shiggerino on Thursday March 19, 2015 @10:04AM (#9231941)
For me, the patterns in HyperCard and MacPaint.