ashiguruma / patternomaly

Easily generate patterns for use in data graphics
MIT License
524 stars 37 forks source link

I can´t create a combination between solid colors and patterns in the same chart #16

Open Mareteo-zz opened 6 years ago

Mareteo-zz commented 6 years ago

i´m trying to create a donut chart using a pattern and solid color inside it, but i see that´s not possible, maybe someone or creator has a solution for this or maybe a little trick to make it work. thanks for your help regards

JoeKuhns commented 6 years ago

You can define a new shape called solid without a path in it. Something like this (admittedly poorly done, but it works.

var Solid = function (_Shape) {
  inherits(Solid, _Shape);

  function Solid() {
    classCallCheck(this, Solid);
    return possibleConstructorReturn(this, (Solid.__proto__ || Object.getPrototypeOf(Solid)).apply(this, arguments));
  }

  createClass(Solid, [{
    key: 'drawTile',
    value: function drawTile() {
      var halfSize = this._size;
      this._context.beginPath();
      this.setFillProps();
      this._context.fill();
      return this._canvas;
    }
  }, {
    key: 'drawSolid',
    value: function drawSolid() {

      this._context.closePath();
    }
  }]);
  return Solid;
}(Shape);

then in var shapes, add'solid': Solid