Still have questions?
Contact support

GraphicsJS Hatch Fill Settings


Some color printers print colors unpredictable and sometimes it is quite hard to identify similar colors as different. Also it is impossible to identify colors on prints of black and white (monochrome) printers and in e-books. AnyChart js charting library has very useful feature - hatch fills, ideal for differentiating elements for black and white display or for those who are color blind.

Hatch fill presets

We provide a list of hatch fill presets, full list of them is available in the API reference.

In case of graphic elements, you need to set hatchFill through the fill() method:


JsFiddle Playground


If needed, you can color the hatch pattern using Hex, RGB, HSL or HTML color name with the opacity. Color opacity can be set in two ways:

  • RGBA, HSLA modificators;
  • Dedicated parameter:
    • Call function with the parameters fill(color, opacity);
    • Single value fill('color opacity') (one string value separated by space).
ellipse.fill('plaid', 'gold 0.5'));

JsFiddle Playground


Hatch lines thickness is set using thickness parameter:

circle.fill('diagonal', 'red', 5.01));

JsFiddle Playground

Note that several types of hatchFill don't have stroke to define thickness.


Also, you can modify hatch using size parameter, which changes the size of the pattern:

ellipse.fill('horizontal', 'gold 1.5', 2, 5));

JsFiddle Playground


If you are not satisfied with presets, you can create your own pattern.


Here an example of Shapes based pattern:

stage ="container");

// pattern
var pattern = stage.pattern(new,0,20,20));, 10, 8).fill("none").stroke("1 blue 0.9");
pattern.star5(10, 10, 6).fill("1 blue 0.9");

Note that in case of using pattern you should create it as for a hatchFill, but define it as an object for the fill() settings:

// create chart
stage.rect(0, 0, 150, 50).fill(pattern);, 150, 50).fill(pattern);

Here is a sample:

JsFiddle Playground


The flexibility of GraphicsJS allows to create not only shapes-based patterns, but also font-based. An example of doing so with an Interdex font can be found in AnyChart Interdex Hatch Fill Sample.

Here is a simplified version of a font-based pattern fill:

var text =;
var pattern = stage.pattern(text.getBounds());

JsFiddle Playground