ashiguruma / patternomaly

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

Pre-packaged .js file #9

Open Yobmod opened 7 years ago

Yobmod commented 7 years ago

Is it possible to get a packaged (post babel etc) single file version of this, that can just be included in the html?

I've tried installing and babelling/webpacking it myself, but every bundle results in a "pattern is not defined" error, even though it appears all the code is there. Same error whether i put the pattern.draw() in the bundle.js or as a separate file after the patternomaly.bundle.js.)

baterflyrity commented 6 years ago

i've found only this https://unpkg.com/patternomaly@1.3.0/dist/patternomaly.js

holypwnage commented 6 years ago

I ran the npm and these are the files created if anyone needs them. patternomaly.zip

gbrits commented 2 years ago

Just to expand on @baterflyrity's answer above, usage would be:

    <script src="https://unpkg.com/patternomaly@1.3.2/dist/patternomaly.js"></script>
    var colors = [
        '#1f77b4', 
        '#e377c2',
        '#ff7f0e',
        '#2ca02c'
    ];

    var patterns = pattern.generate(colors);

    const myChart = new Chart(ctx, {
            type: 'pie',
            data: {
                labels: [...

    // And then...

    myChart.data.datasets[0].backgroundColor = patterns;
    myChart.update();