3 thoughts on “Problem with other plugin

  1. That’s not obvious who is to blame: this conflict comes from the use of different color libraries (Color.js vs our fork of color) under the same global alias (Color.js & chartjs-color). Maybe we could use a different alias (e.g. Chart.Color) and so considerably reduce name collision probability:

    var Color = {
       // ...
    }
    
    if (typeof window !== 'undefined') {
        window.Chart = window.Chart || {};
        window.Chart.Color = Color;
    
        if (typeof window.Color === 'undefined') {
           // maintain backward compatibility ONLY if no other Color lib has been defined
           window.Color = Color;
        }
    }
  2. Hey, I’ve just run into this issue. Can confirm the fix seems to solve it, is it likely to get merged? thanks

  3. Same issue for me with Beaver Builder on a WordPress install. For anyone else with this problem, here’s my fix:

    1. Download Chart js from releases (full, not minified): https://github.com/chartjs/Chart.js/releases/
    2. Open the file and search for window.Color.
    3. Replace this code with what @simonbrunel posted above.
    if (typeof window !== 'undefined') {
    	window.Color = Color;
    }
    
    // is replaced with
    
    if (typeof window !== 'undefined') {
        window.Chart = window.Chart || {};
        window.Chart.Color = Color;
    
        if (typeof window.Color === 'undefined') {
           // maintain backward compatibility ONLY if no other Color lib has been defined
           window.Color = Color;
        }
    }

    After you do that, you can minify and include the file however you’d like. In my case, I ended up dropping the NPM build and just adding the file I created in a require. Not the best solution, but it was that or remove Chart.js for another library :/.

    Hope this helps @tareq1988!

Comments are closed.