cssAudio - Activefile-genericCSS - ActiveGeneric - ActiveHTML - ActiveImage - ActiveJS - ActiveSVG - ActiveText - Activefile-genericVideo - Activehtmlicon-personicon-teamoctocatspinnerstartv

Pen Settings

CSS Base

Vendor Prefixing

Add External CSS

These stylesheets will be added in this order and before the code you write in the CSS editor. You can also add another Pen here, and it will pull the CSS from it. Try typing "font" or "ribbon" below.

Quick-add: + add another resource

Add External JavaScript

These scripts will run in this order and before the code in the JavaScript editor. You can also link to another Pen here, and it will run the JavaScript from it. Also try typing the name of any popular library.

Quick-add: + add another resource

Code Indentation

     

Save Automatically?

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.

            
              <html><head>

    <meta charset="UTF-8">
    <link href="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js"></script>
    <script type="text/javascript" src="https://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
    <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/highstock/1.3.7/highstock.js"></script>
    <!-- <script type="text/javascript" src="https://bitcoinaverage.com/js/lib/jquery.formatCurrency.js"></script> -->
  <link href='https://fonts.googleapis.com/css?family=Open+Sans' rel='stylesheet' type='text/css'>

    <style type="text/css">
        #small-chart{height:320px;}
        body {
          background-color: black;
        }
        .chartWithOverlay {
            position: relative;
            width: 100%;
          padding: 0px;
        }
        .overlay {
            position: absolute;
            top: 2px;   /* chartArea top  */
            left: 35px; /* chartArea left */
        }
        .overlayPriceShift {
            position: absolute;
            bottom: 2px;   /* chartArea top  */
            left: 35px; /* chartArea left */
        }
        .currentPrice {
            font-family: 'Open Sans';
            font-size: 11em;
            opacity: 0.6;
            position: relative;
            color: #5a5a5a;
            left: 20px;
            top: 40px;
        }

        .main-price-shift{
            padding: 1.5em 1em;
        }
        .main-price-highlow {
            padding: 1.5em 0;
        }

        .main-price-shift .price-shift-title,
        .main-volume .volume-title {
            color: #999;
        }

        .main-price-shift[data-trend="up"] {
            color: green;
        }

        .main-price-shift[data-trend="down"] {
            color: red;
        }

        .main-price-shift .price-arrow,
        .main-price-shift .price-shift,
        .main-price-shift .price-shift-prc {
            display: inline-block;
            margin-right: 10px;
        }

        .main-price-highlow .price-high-title,
        .main-price-highlow .price-low-title,
        .main-market-avg .market-cur-avg-title,
        .main-market-avg .market-24h-avg-title {
            color: #999;
            float: left;
            padding-right: 5px;
            text-align: right;
            width: 50%;
        }

        .main-price-highlow .price-high,
        .main-price-highlow .price-low,
        .main-market-avg .market-cur-avg,
        .main-market-avg .market-24h-avg {
            float: right;
            padding-left: 5px;
            text-align: left;
            width: 50%;
        }

    </style>
</head>
<body style="padding:0;margin:0; overflow: hidden">

<div class="chartWithOverlay col-md-12 text-center">
    <div id="small-chart"></div>
    <div class="overlay" onclick="toggleDateFrame('USD');">
        <div class="currentPrice"><span id="lastPrice">...</span></div>
    </div>

    <div class="row strip active overlayPriceShift" onclick="toggleDateFrame('USD');">
        <div class="col-md-6 col-xs-6 main-price-shift">
            <div class="price-shift-title">24h price change</div>
            <div class="price-arrow"></div>
            <div class="price-shift"></div>
            <div class="price-shift-prc"></div>
        </div>

        <div class="col-md-6 col-xs-6 main-price-highlow">
            <div class="price-high-title">high</div>
            <div class="price-high"></div>
            <div class="price-low-title">low</div>
            <div class="price-low"></div>
        </div>
    </div>
</div>

<script type="text/javascript">

    var config = {"refreshRate": "15000", "exchangesColors": {"btcchina": "#b90c67", "loyalbit": "#b1d9c5", "rocktrading": "#f54840", "coinsecure": "#e1b8df", "bter": "#700daa", "bitstamp": "#c854a4", "gatecoin": "#8dac8b", "coinmate": "#ba5da0", "quickbitcoin": "#86f5eb", "clevercoin": "#7232d6", "bitkonan": "#685d43", "btcgreece": "#d1c8a0", "okcoinintl": "#f3bd1a", "btcxindia": "#fbcba6", "coinfloor": "#32092f", "btcmarkets": "#28df64", "bitcoin_co_id": "#ca1581", "btce": "#14e58c", "bitx": "#889a56", "quadrigacx": "#d44e96", "okcoin": "#547831", "bitso": "#da5d79", "huobi": "#7bb9ca", "independentreserve": "#1e9174", "bitbargain": "#84ce21", "gdax": "#062a60", "bit2c": "#db009f", "foxbit": "#57e79a", "ccedk": "#d5ebda", "taurus": "#ebf25e", "hitbtc": "#524a6d", "mercado": "#5bd053", "btc38": "#a5a76e", "kraken": "#80cd46", "cex": "#4fccab", "localbitcoins": "#7ea049", "paymium": "#ea6835", "bitonic": "#54c2e0", "bitfinex": "#af3e20", "bittylicious": "#89dca5", "bitbay": "#64c44e", "campbx": "#69d989", "bitex": "#c2ff4a", "bitcoin_de": "#108b53", "itbit": "#464afd"}, "currencyOrder": ["USD", "EUR", "CNY", "GBP", "CAD", "PLN", "RUB", "AUD", "SEK", "BRL", "NZD", "SGD", "ZAR", "NOK", "ILS", "RON", "MXN", "IDR", "JPY", "INR", "HKD"], "scaleDivizer": 1, "majorCurrencies": 5, "legendSlots": 20, "precision": 2, "currencySymbols": {"USD": ["0024"], "IDR": [], "ILS": ["20aa"], "GBP": ["00a3"], "CAD": ["0024"], "JPY": ["00a5"], "RON": [], "SEK": ["006b", "0072"], "SGD": ["0024"], "HKD": ["0024"], "AUD": ["0024"], "CHF": [], "CNY": ["00a5"], "TRY": [], "NZD": ["0024"], "EUR": ["20ac"], "NOK": ["006b", "0072"], "RUB": [], "INR": ["20B9"], "MXN": [], "BRL": ["0052", "0024"], "PLN": ["007a", "0142"], "ZAR": ["0052"]}, "apiUsers": [{"image": "./img/bitcoin-wallet.png", "href": "https://play.google.com/store/apps/details?id=de.schildbach.wallet", "name": "Bitcoin Wallet"}, {"image": "./img/Purse.png", "href": "https://app.purse.io/signup?_a=BitcoinAverage", "name": "Purse.io"}, {"image": "./img/bitbond.png", "href": "https://www.bitbond.com/?a=2Q7N9H4XTZ", "name": "Bitbond"}, {"image": "./img/mycelium.png", "href": "https://play.google.com/store/apps/details?id=com.mycelium.wallet", "name": "Mycelium"}, {"image": "./img/localbitcoins.png", "href": "https://localbitcoins.com/?ch=22yh", "name": "Localbitcoins"}, {"image": "./img/kryptokit.png", "href": "http://www.kryptokit.com/", "name": "KryptoKit"}, {"image": "./img/lamassu.png", "href": "https://lamassu.is/", "name": "Lamassu"}, {"image": "./img/greenaddress.png", "href": "https://greenaddress.it", "name": "GreenAddress"}, {"image": "./img/kitco.png", "href": "http://www.kitco.com/finance/bitcoin/", "name": "Kitco"}], "chartType": "linear", "apiIndexUrl": "https://api.bitcoinaverage.com/", "apiHistoryIndexUrl": "https://api.bitcoinaverage.com/history/"};

    var currencyCode = 'USD';

    var global_avg_url = 'https://api.bitcoinaverage.com/history/';
    var data_24h_URL = global_avg_url + currencyCode + '/per_minute_24h_sliding_window.csv';
    var monthly_URL  = global_avg_url + currencyCode + '/per_hour_monthly_sliding_window.csv';
    var all_time_URL = global_avg_url + currencyCode + '/per_day_all_time_history.csv';

    var loadDataFrom = data_24h_URL;
    var chartTitle = ' 24h price movement';

    function toggleDateFrame(currencyCode) {
        if(loadDataFrom == data_24h_URL) {
            loadDataFrom = monthly_URL;
            chartTitle = ' monthly price movement';
        //}else if(loadDataFrom == monthly_URL) {
        //    loadDataFrom = all_time_URL;
        //    chartTitle = ' all time price movement';
        }else if(loadDataFrom == monthly_URL) {
            loadDataFrom = data_24h_URL;
            chartTitle = ' 24h price movement';
        }
        renderSmallChart(currencyCode);
    }

    function getCurrencySymbol(curCode) {
        var symbol = '';
        var codes = config.currencySymbols[curCode];
        if (codes) {
            for (var i = 0; i < codes.length; i++) {
                symbol += String.fromCharCode(parseInt(codes[i], 16));
            }
        }
        return symbol;
    }

     let theme = {
      colors: ["steelblue"],
      chart: {
         backgroundColor: {
            linearGradient: { x1: 0, y1: 0, x2: 1, y2: 1 },
            stops: [
               [0, '#2a2a2b'],
               [1, '#3e3e40']
            ]
         },
         style: {
            fontFamily: "'Unica One', sans-serif"
         },
         plotBorderColor: '#606063'
      },
      subtitle: {
         style: {
            color: '#E0E0E3',
            textTransform: 'uppercase'
         }
      },
      xAxis: {
         gridLineColor: '#707073',
         labels: {
            style: {
               color: '#E0E0E3'
            }
         },
         lineColor: '#707073',
         minorGridLineColor: '#505053',
         tickColor: '#707073',
         title: {
            style: {
               color: '#A0A0A3'
            }
         }
      },
      yAxis: {
         gridLineColor: '#707073',
         labels: {
            style: {
               color: '#E0E0E3'
            }
         },
         lineColor: '#707073',
         minorGridLineColor: '#505053',
         tickColor: '#707073',
         tickWidth: 1,
         title: {
            style: {
               color: '#A0A0A3'
            }
         }
      },
      tooltip: {
         backgroundColor: 'rgba(0, 0, 0, 0.85)',
         style: {
            color: '#F0F0F0'
         }
      },
      plotOptions: {
         series: {
            dataLabels: {
               color: '#B0B0B3'
            },
            marker: {
               lineColor: '#333'
            }
         },
         boxplot: {
            fillColor: '#505053'
         },
         candlestick: {
            lineColor: 'white'
         },
         errorbar: {
            color: 'white'
         }
      },
      legend: {
         itemStyle: {
            color: '#E0E0E3'
         },
         itemHoverStyle: {
            color: '#FFF'
         },
         itemHiddenStyle: {
            color: '#606063'
         }
      },
      credits: {
         style: {
            color: '#666'
         }
      },
      labels: {
         style: {
            color: '#707073'
         }
      },

      drilldown: {
         activeAxisLabelStyle: {
            color: '#F0F0F3'
         },
         activeDataLabelStyle: {
            color: '#F0F0F3'
         }
      },

      navigation: {
         buttonOptions: {
            symbolStroke: '#DDDDDD',
            theme: {
               fill: '#505053'
            }
         }
      },

      navigator: {
         handles: {
            backgroundColor: '#666',
            borderColor: '#AAA'
         },
         outlineColor: '#CCC',
         maskFill: 'rgba(255,255,255,0.1)',
         series: {
            color: '#7798BF',
            lineColor: '#A6C7ED'
         },
         xAxis: {
            gridLineColor: '#505053'
         }
      },

      scrollbar: {
         barBackgroundColor: '#808083',
         barBorderColor: '#808083',
         buttonArrowColor: '#CCC',
         buttonBackgroundColor: '#606063',
         buttonBorderColor: '#606063',
         rifleColor: '#FFF',
         trackBackgroundColor: '#404043',
         trackBorderColor: '#404043'
      },

      // special colors for some of the
      legendBackgroundColor: 'rgba(0, 0, 0, 0.5)',
      background2: '#505053',
      dataLabelsColor: '#B0B0B3',
      textColor: '#C0C0C0',
      contrastTextColor: '#F0F0F3',
      maskColor: 'rgba(255,255,255,0.3)'
}

    var renderSmallChart = function(currencyCode){

        $.get(loadDataFrom, function(csv){
            var data = [];
            $.each(csv.split('\n'), function(i, line){
                var values = line.split(',');
                if(i == 0 || line.length == 0){
                    return;
                }

                var chartDailyValue = parseFloat(values.slice(-1)[0]) / config.scaleDivizer;
                var dateStr = values[0];
                var dateData = dateStr.split(' ');
                dateData[0] = dateData[0].split('-');
                dateData[1] = dateData[1].split(':');
                var dateInt = Date.UTC(dateData[0][0], dateData[0][1] - 1, dateData[0][2], dateData[1][0], dateData[1][1], dateData[1][2]);
                data.push([dateInt, chartDailyValue]);
            });
            data.sort(function(a,b){
                if (a[0] > b[0]){
                    return 1;
                } else if (a[0] < b[0]){
                    return -1;
                } else {
                    return -0;
                }
            });

            var priceShift = data[data.length - 1][1] - data[0][1];
            var priceShiftPercentage = priceShift / data[0][1] * 100;
            $('.main-price-shift .price-arrow').text(priceShift < 0 ? '▼' : '▲');
            $('.main-price-shift').attr('data-trend', priceShift < 0 ? 'down' : 'up');
            // $('.main-price-shift .price-shift').text(priceShift).formatCurrency({
            //     symbol: getCurrencySymbol(currencyCode),
            //     positiveFormat: '%s%n ' + currencyCode,
            //     negativeFormat: '%s%n ' + currencyCode,
            //     roundToDecimalPlace: config.precision
            // });
            $('.main-price-shift .price-shift-prc').text(Math.abs(priceShiftPercentage).toFixed(2) + '%');

            var prices = $.map(data, function (e, i) { return e[1]; });
            $('.main-price-highlow .price-high')
                    .text(Math.max.apply(Math, prices))
                    // .formatCurrency({
                    //     symbol: getCurrencySymbol(currencyCode),
                    //     positiveFormat: '%s%n ' + currencyCode,
                    //     roundToDecimalPlace: config.precision
                    // });
            $('.main-price-highlow .price-low')
                    .text(Math.min.apply(Math, prices))
                    // .formatCurrency({
                    //     symbol: getCurrencySymbol(currencyCode),
                    //     positiveFormat: '%s%n ' + currencyCode,
                    //     roundToDecimalPlace: config.precision
                    // });

            $('#lastPrice').text(parseInt(data[data.length-1][1]));

            $('#small-chart').html('');

            $('#small-chart').highcharts('StockChart',  Object.assign(theme, {
                chart : {
                    animation : false,
                    events: {
                        click: function(e){
                            toggleDateFrame(currencyCode);
                        }
                    },
                    spacingBottom: 5,
                    spacingLeft: 0,
                    spacingRight: 0,
                    spacingTop: 0,
                    marginTop: 0,
                    //backgroundColor: '#000000'
                },
                rangeSelector: {enabled: false},
                title: {text: currencyCode+chartTitle},
                scrollbar: {enabled: false},
                navigator: {enabled: false},
                exporting: {enabled: false},
                tooltip: {
                    enabled : true,
                    valueDecimals: 2
                },
                credits: {enabled : false},
                series : [{
                    animation: false,
                    name: currencyCode,
                    data: data,
                    cursor: 'pointer',
                    events: {
                        click: function(event){
                            toggleDateFrame(currencyCode);
                        }
                    }
                }]

            }));
        });
    };

    renderSmallChart('USD');
    setInterval(function(){renderSmallChart('USD')}, 1000*60);
</script></body></html>

            
          
!
999px
Close

Asset uploading is a PRO feature.

As a PRO member, you can drag-and-drop upload files here to use as resources. Images, Libraries, JSON data... anything you want. You can even edit them anytime, like any other code on CodePen.

Go PRO

Loading ..................

Console