JSFiddle - React, Tailwind, and code Playground

by Kesav Telaprolu

HTML

<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<div id="container" style="width: 1240px;height:688px;border:1px solid #dbdbdb;border-radius:10px;position:relative"></div>

CSS

/*
 * Legal Disclaimer
 *
    print '\n', 'Note that the webfonts share the TT sources'
 * These Fonts are licensed for unlimited use on domains and their subdomains of The Kantar Group.
 * It is illegal to download or use them on other websites.
 *
 * While the @font-face statements below may be modified by the client, this
 * disclaimer may not be removed.
 *
 * Lineto.com, 2016
 */



@font-face {
    font-family: "KantarBrownWeb-LightItalic";
    src: url("https://riofontstorage.blob.core.windows.net/kantar-fonts/KantarBrownWeb-LightItalic.eot");
    src: url("https://riofontstorage.blob.core.windows.net/kantar-fonts/KantarBrownWeb-LightItalic.eot?#iefix") format("embedded-opentype"),
         url("https://riofontstorage.blob.core.windows.net/kantar-fonts/KantarBrownWeb-LightItalic.woff2") format("woff2"),
         url("https://riofontstorage.blob.core.windows.net/kantar-fonts/KantarBrownWeb-LightItalic.woff") format("woff");
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: "KantarBrownWeb-BoldItalic";
    src: url("https://riofontstorage.blob.core.windows.net/kantar-fonts/KantarBrownWeb-BoldItalic.eot");
    src: url("https://riofontstorage.blob.core.windows.net/kantar-fonts/KantarBrownWeb-BoldItalic.eot?#iefix") format("embedded-opentype"),
         url("https://riofontstorage.blob.core.windows.net/kantar-fonts/KantarBrownWeb-BoldItalic.woff2") format("woff2"),
         url("https://riofontstorage.blob.core.windows.net/kantar-fonts/KantarBrownWeb-BoldItalic.woff") format("woff");
    font-weight: normal;
    font-style: normal;
}

@font-face {
    font-family: "KantarBrownWeb-Italic";
    src: url("https://riofontstorage.blob.core.windows.net/kantar-fonts/KantarBrownWeb-Italic.eot");
    src: url("https://riofontstorage.blob.core.windows.net/kantar-fonts/KantarBrownWeb-Italic.eot?#iefix") format("embedded-opentype"),
         url("https://riofontstorage.blob.core.windows.net/kantar-fonts/KantarBrownWeb-Italic.woff2")...

JavaScript

(input => {
    var defaultHeight = 45;
    var rectPoints = [];

    var chartWrapper = $("<div></div>").appendTo("#container")
        .attr("id", "chart_wrapper");

    var chartDiv = $("<div></div>").appendTo("#chart_wrapper")
        .attr("id", "chart_div");

    var msv = input.cmpBrands.map(function (item) {
        return item.marketShare;
    })

    var pim = input.cmpBrands.map(function (item) {
        return item.powerInTheMind;
    })

    var maxChosenBrand = Math.max.apply(null, [input.chosenBrand.marketShare, input.chosenBrand.powerInTheMind, input.chosenBrand.equityGap]);
    var maxMSCmpBrands = Math.max.apply(null, msv);
    var maxProjectedCmpBrands = Math.max.apply(null, pim);
    var MaxBrandValue = Math.max(maxMSCmpBrands, maxProjectedCmpBrands, maxChosenBrand);
    //Declare the context
    var canvasComparison;
    var ctxComp;
    var canvasChosen;
    var ctxChosen;
    var constMaxSquareSize = 105;
    var pimSwitch = false;

    //Default display
    DisplayDefault();

    function DisplayDefault() {
        InitChart();
        displayAll();
        return;
    }

    //Display market share only
    function displayMSOnly() {
        pimSwitch = false;
        //Draw chosen brand based on the max size in series   
        DrawPlotForChosenBrand(input.chosenBrand.marketShare, 0, '', input.chosenBrand.name);

        var minimumGap = 0;

        //Comparision Brand Plot
        for (var i = 0; i < input.cmpBrands.length; i++) {
            //setting the projected values to 0 by default
            DrawPlotForComparisionBrands(input.cmpBrands[i].marketShare, 0, '', minimumGap, input.cmpBrands[i].name, i);
            minimumGap += 117;
        }
    }

    //Display power in mind only
    function displayPMOnly() {
        pimSwitch = true;
        //Draw chosen brand based on the max size in series   
        DrawPlotForChosenBrand(0, input.chosenBrand.powerInTheMind, '', input.chosenBrand.name);

        var minimumGap = 0;

       ...