style images in chart flags? - Javascript highcharts

Javascript examples for highcharts:Chart Image

Description

style images in chart flags?

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <title>Highcharts Stock Demo</title> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> 
      <style id="compiled-css" type="text/css">

.highcharts-markers image {/*www  . ja  va  2s  .  co m*/
   border: 1px solid black;
}


      </style> 
      <script type="text/javascript">
$(function () {
    var H = Highcharts;
    function drawBorder() {
        var chart = this;
        H.each(chart.series[1].points, function(p) {
              var bbox,
                rect,
                fontSize = 13, // it's used as default font size offet, even for the images
                dim = 32; //width and height for the image
            if(p.graphic) {
                if(p.rectangle) {
                    p.rectangle.destroy();
                }
                bbox = p.graphic.getBBox();
                rect = chart.renderer.rect(p.plotX - dim/2, p.plotY - dim/2 - fontSize, dim, dim).attr({
                     "stroke": "black",
                    "stroke-width": 2,
                    "fill": "transparent"
                }).add(chart.series[1].markerGroup);
                p.rectangle = rect;
            }
        });
    }
    $('#container').highcharts('StockChart', {
        chart: {
             events: {
                load: drawBorder,
                redraw: drawBorder
            }
        },
        rangeSelector: {
            selected: 1
        },
        series: [{
            name: 'USD to EUR',
            id: 'dataseries',
            data: usdeur
        }, {
            type: 'flags',
            data: [{
                x: Date.UTC(2011, 2, 1),
                text: 'Shape: "circlepin"'
            }, {
                x: Date.UTC(2011, 3, 1),
                text: 'Shape: "circlepin"'
            }],
            y: -16, // half of images height
            shape: 'https://www.java2s.com/style/demo/Google-Chrome.png',
            title: ' '
        }]
    });
});

      </script> 
   </head> 
   <body> 
      <div id="container" style="height: 400px; min-width: 600px"></div> 
      <script src="https://code.highcharts.com/stock/highstock.js"></script> 
      <script src="https://code.highcharts.com/stock/modules/exporting.js"></script> 
      <script type="text/javascript" src="https://www.highcharts.com/samples/data/usdeur.js"></script>  
   </body>
</html>

Related Tutorials