Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="stylesheet" href="mq.css">
    <script src='https://cdnjs.cloudflare.com/ajax/libs/Chart.js/3.9.1/chart.min.js'></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-annotation/2.0.1/chartjs-plugin-annotation.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/2.1.0/chartjs-plugin-datalabels.min.js"></script>
    <title>Document</title>
</head>
<body>





    
    <div id="MQ" class="flex-it">
      <canvas id="myChart"></canvas>
    </div>
  </body>  
 
              
            
!

CSS

              
                *{
    box-sizing: border-box;
    font-family: 'DM Sans';
}

main{
    margin: auto ;
}

.MQ_flex-con{
    max-width: 1136px;
    margin: auto;
    display: flex;
    padding-top: 50px;
    gap: 50px;
    background-color: white;
    justify-content: space-around;
}

.heading-MQ{
    font-size: 32px;
    line-height: 32px;
    font-weight: 700;
    opacity: 1 !important;
}

.MQ-product-list-link{
    color: inherit;
    text-decoration: none;
}

.MQ-product-list-link:hover{
    color: #57A3F9;
}

.flex-it{
    
    font-size: 16px;
    line-height: 24px;
    font-weight: 400;
}

.description-MQ{
    flex-basis: 500px;
    opacity: 0.7;
    
}

#update-date{
    line-height: 16px;
}

#MQ{
    height: 500px;
    width: 500px;
   
    /*margin-top: -70px;*/
}

.MQ-product {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    list-style-position: inside;
}

#myChart{
    background-image: url("BVR Logo - Magic Quadrant.png");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 112px 107px;
    padding-right: 20px;
}

@media screen and (max-width: 1000px) {
    .MQ_flex-con{
        display: flex;
        flex-direction: column;
        max-width: 1136px;
        gap: 50px;
        justify-content: space-around;
        align-items: center;
    }
    .MQ-product {
        display: grid;
        grid-template-columns: repeat(1, 1fr);
    }

  }

@media screen and (max-width: 500px) {
.MQ_flex-con{
    display: flex;
    flex-direction: column;
    max-width: 1136px;
    gap: 50px;
    justify-content: space-around;
    align-items: center;
}
.MQ-product {
    display: grid;
    grid-template-columns: repeat(1, 1fr);
}

#MQ{
    height: 320px;
    width: 320px;
}
#myChart{
    background-image: url("BVR Logo - Magic Quadrant.png");
    background-position: center;
    background-repeat: no-repeat;
    background-size: 71.25px 67.94px;
    padding-right: 20px;
}

}
              
            
!

JS

              
                Chart.defaults.font.size = 14;
        var p4 = 4;
        var p8 = 8;
        var p20 = 20;
        if(window.outerWidth < 501){
          Chart.defaults.font.size = 9;
          p8 = 5.12;
          p4 = 2.56;
          p20 = 5;
        }
        
          var ctx = document.getElementById("myChart").getContext('2d');

      // Define the data 
      var data = [{
                      x: 5,
                      y: 4,
                      label: 'OnePlus 10T',
                      data:'Google - Pixel 3a with 64GB Memory '
                  },
                  {
                      x: -2,
                      y: 4,
                      label: 'Apple iphone 13',
                      data:'Google - Pixel 3a with 64GB Memory '
                  },
                  {
                      x: -8,
                      y: 2,
                      label: 'Samsung Galaxy A70',
                      data:'Google - Pixel 3a with 64GB Memory '

                  },
                  {
                      x: 2,
                      y: 0,
                      label: 'Moto G7 play ',
                      data:'Google - Pixel 3a with 64GB Memory '

                  },
                  {
                      x: 1,
                      y: -3,
                      label: 'Xiaomi Redmi Note 8 Pro',
                      data:'Google - Pixel 3a with 64GB Memory '

                  },
                  {
                      x: -3,
                      y: 5,
                      label: 'Huawei P30 Pro',
                      data:'Google - Pixel 3a with 64GB Memory '

                  },
                  {
                      x: -3,
                      y: -8,
                      label: 'Samsung S22',
                      data:'Google - Pixel 3a with 64GB Memory '

                  },
                  {
                      x: -6,
                      y: -2,
                      label: 'Xiomi MI 6',
                      data:'Google - Pixel 3a with 64GB Memory '

                  }
                ]; 
                
      var options = {
        responsive: true, 
          maintainAspectRatio: true,
          aspectRatio: 1,
          plugins: {
              legend: {
                  display: false
              },
              autocolors: false,
              tooltip: {
                backgroundColor: 'white',
                borderColor: 'black',
                borderWidth: 1,
                cornerRadius: 0,
                xAlign: 'center',
                yAlign: 'bottom',
                callbacks: {
                  label: function(context) {
                    return context.raw.data;
                  },
                  labelTextColor: function(context) {
                    return '#2C2D31';
                  },
                  labelColor: function(context) {
                    return {
                        borderColor: 'white',
                        backgroundColor: 'white',
                        cornerRadius: 0
                    };
                  },
                  labelPointStyle: function(context) {
                    return {
                        pointStyle: 'line',
                        rotation: 0
                    };
                  }
                }
              },
              annotation: {
                annotations: {
                  label1: {
                    type: 'label',
                    xValue: -7.25,
                    yValue: -9.45,
                    backgroundColor: '#F0F4F8',
                    content: ['CHALLENGERS'],
                    borderRadius: 2,
                    color: '#314863',
                    padding: {
                      left: 10,
                      top: 4,
                      right: 10,
                      bottom: 4
                    },
                    font: {
                      
                      weight: 700,
                      family: 'DM Sans'
                    }
                  },
                  label2: {
                    type: 'label',
                    xValue: -7.4,
                    yValue: 9.45,
                    backgroundColor: '#F0F4F8',
                    content: ['GREAT VALUE'],
                    borderRadius: 2,
                    color: '#314863',
                    padding: {
                      left: 10,
                      top: 4,
                      right: 10,
                      bottom: 4
                    },
                    font: {
                      
                      weight: 700,
                      family: 'DM Sans'
                    }
                  },
                  label3: {
                    type: 'label',
                    xValue: 7.6,
                    yValue: -9.45,
                    backgroundColor: '#F0F4F8',
                    content: ['RISING STAR'],
                    borderRadius: 2,
                    color: '#314863',
                    padding: {
                      left: 10,
                      top: 4,
                      right: 10,
                      bottom: 4
                    },
                    font: {
                      
                      weight: 700,
                      family: 'DM Sans'
                    }
                  },
                  label4: {
                    type: 'label',
                    xValue: 8.28,
                    yValue: 9.42,
                    backgroundColor: '#F0F4F8',
                    content: ['LEADER'],
                    borderRadius: 2,
                    color: '#314863',
                    padding: {
                      left: 10,
                      top: 4,
                      right: 10,
                      bottom: 4
                    },
                    font: {
                      
                      weight: 700,
                      family: 'DM Sans'
                    }
                  },
                  line1: {
                    type: 'line',
                    yMin: 10,
                    yMax: 10,
                    borderColor: '#A7A7A7',
                    borderWidth: 1,
                  },
                  line2: {
                    type: 'line',
                    xMin: 10,
                    xMax: 10,
                    borderColor: '#A7A7A7',
                    borderWidth: 1,
                  },
                  line3: {
                    type: 'line',
                    yMin: 0,
                    yMax: 0,
                    borderColor: '#A7A7A7',
                    borderWidth: 1,
                    borderDash: [2,2]
                  },
                  line4: {
                    type: 'line',
                    xMin: 0,
                    xMax: 0,
                    borderColor: '#A7A7A7',
                    borderWidth: 1,
                    borderDash: [2,2]
                  }
                } 
              } 
              
          },
          scales: {
            x:{
                ticks:{
                  display: false
                },
                grid: {
                  display: false,
                },
                min: -10,
                max: 10,
                title: {
                  color: '#6A6A6A',
                  display: true,
                  text: 'Price',
                  padding: {
                    top: 6
                  },
                  font: {
                    
                  }
                }
              },
            y:{
              ticks:{
                display: false
              },
              grid: {
                display: false
              },
              min: -10,
              max: 10,
              title: {
                color: '#6A6A6A',
                display: true,
                text: 'Popularity',
                padding: {
                  top: 6
                },
                font: {
                  
                }
              }
            } 
          
        }
      };

      var link = ['https://www.amazon.com/dp/B07WLNZB78/?tag=bvr-testing-20','https://www.amazon.com/dp/B09G9FPHY6/?tag=bvr-testing-20','https://www.amazon.com/dp/B08DK9X3R1/?tag=bvr-testing-20','https://www.amazon.com/dp/B07K1RZWMC/?tag=bvr-testing-20','https://www.amazon.com/dp/B09G96P9RM/?tag=bvr-testing-20','https://www.amazon.com/dp/B07SN47MG9/?tag=bvr-testing-20','https://www.amazon.com/dp/B08FR5Y2GQ/?tag=bvr-testing-20','https://www.amazon.com/dp/B08J5FPW6S/?tag=bvr-testing-20']
      var myChart = new Chart(ctx, {
          type: 'scatter',
          data: {
              datasets: [{
                     
                data: data, 
                borderColor: 'rgba(87, 163, 249, 0.2)',          
                backgroundColor: '#57A3F9', 
                borderWidth: p8,
                radius: p8,
                hoverRadius: p8,
                hoverBackgroundColor: 'white',
                hoverBorderColor: '#57A3F9',
                hoverBorderWidth: p4,
                datalabels: {
                  color: '#2C2D31',
                  align: 'right',
                  padding: {
                    left:  p20
                  },
                  font:{
                    weight: 200
                  },
                  listeners: {
                    click: function(context)
                    {
                      window.open(link[context.dataIndex], '_blank');
                    },
                    enter: function(context, event) {
                      context.hovered = true;
                      context.chart.canvas.style.cursor = 'pointer';
                      return true;
                    },
                    leave: function(context, event) {
                      context.hovered = false;
                      context.chart.canvas.style.cursor = 'default';
                      return true;
                    }
                    
                  },
                  color: function(context) {
                    
                    return context.hovered ? "#343538" : "#2C2D31";
                  },
                  
                }

              }],
              

          },
          options: options,
          plugins: [ChartDataLabels],
          
      });
              
            
!
999px

Console