server
{
listen :80 default_server;
server_name "";
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header remote_addr $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
location /
{
proxy_pass http://127.0.0.1:8080$request_uri;
}
}
let data,
chart,
result = {longRate: [], shortRate: [], exchangeName: []}, // объявляем сразу как объект
options = { series: [], chart: {}, plotOptions: {}, xaxis: {}}; // тоже объявляем сразу как объект
fetch("https://fapi.coinglass.com/api/futures/longShortRate?symbol=BTC&timeType=3")
.then(response => response.json()
)
.then (data => {
console.log(data['data'][0]);
if(data['data'].length > 0){ // нужно проверить хотя бы так
for (i = 0; i < data['data'][0]['list'].length; i++) {
result.longRate[i] = data['data'][0]['list'][i]['longRate'];
result.shortRate[i] = data['data'][0]['list'][i]['shortRate'];
result.exchangeName[i] = data['data'][0]['list'][i]['exchangeName'];
}
checkSales(result); // вызываем проверку #sales (внутри then )
}else{
console.log('no data');
}
});
function checkSales(result){ // это теперь отдельная функция
if ($('#sales').length) {
options.series: [{ // без var
name: 'Лонг',
data: result.longRate, // < -- result['longRate']
}, {
name: 'Шорт',
data: result.shortRate, // < -- result['shortRate']
},
];
options.chart: {
id: 'longshortratio',
type: 'bar',
height: 350,
stacked: true,
stackType: '100%'
};
options.plotOptions: {
bar: {
horizontal: true,
},
};
options.xaxis: {
categories: result.exchangeName, // < -- result['exchangeName']
labels: {
formatter: function (val) {
return val
}
}
};
chart = new ApexCharts( // без var
document.querySelector("#sales"),
options
);
chart.render();
}
}
<span class="handle" >
# HTTP redirect
server {
charset utf-8;
client_max_body_size 128M;
listen 80;
server_name *.somesite.ru;
return 301 https://somesite.ru$request_uri;
}
# HTTPS 443
server {
listen 443 ssl http2;
server_name somesite.ru *.somesite.ru;
ssl_certificate /etc/ssl/somesite.crt;
ssl_certificate_key /etc/ssl/somesite.key;
# reverse proxy
location / {
proxy_pass http://127.0.0.1:3000;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header remote_addr $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Port $server_port;
}
}
//custom.js
jQuery(document).ready(function() {
"use strict";
// Tooltip
jQuery('.tooltips').tooltip({ container: 'body'});
// Popover
jQuery('.popovers').popover();
// Show panel buttons when hovering panel heading
jQuery('.panel-heading').hover(function() {
jQuery(this).find('.panel-btns').fadeIn('fast');
}, function() {
jQuery(this).find('.panel-btns').fadeOut('fast');
});
// Close Panel
jQuery('.panel .panel-close').click(function() {
jQuery(this).closest('.panel').fadeOut(200);
return false;
});
// Minimize Panel
jQuery('.panel .panel-minimize').click(function(){
var t = jQuery(this);
var p = t.closest('.panel');
if(!jQuery(this).hasClass('maximize')) {
p.find('.panel-body, .panel-footer').slideUp(200);
t.addClass('maximize');
t.find('i').removeClass('fa-minus').addClass('fa-plus');
jQuery(this).attr('data-original-title','Maximize Panel').tooltip();
} else {
p.find('.panel-body, .panel-footer').slideDown(200);
t.removeClass('maximize');
t.find('i').removeClass('fa-plus').addClass('fa-minus');
jQuery(this).attr('data-original-title','Minimize Panel').tooltip();
}
return false;
});
jQuery('.leftpanel .nav .parent > a').click(function() {
var coll = jQuery(this).parents('.collapsed').length;
if (!coll) {
jQuery('.leftpanel .nav .parent-focus').each(function() {
jQuery(this).find('.children').slideUp('fast');
jQuery(this).removeClass('parent-focus');
});
var child = jQuery(this).parent().find('.children');
if(!child.is(':visible')) {
child.slideDown('fast');
if(!child.parent().hasClass('active'))
child.parent().addClass('parent-focus');
} else {
child.slideUp('fast');
child.parent().removeClass('parent-focus');
}
}
return false;
});
// Menu Toggle
jQuery('.menu-collapse').click(function() {
if (!$('body').hasClass('hidden-left')) {
if ($('.headerwrapper').hasClass('collapsed')) {
$('.headerwrapper, .mainwrapper').removeClass('collapsed');
} else {
$('.headerwrapper, .mainwrapper').addClass('collapsed');
$('.children').hide(); // hide sub-menu if leave open
}
} else {
if (!$('body').hasClass('show-left')) {
$('body').addClass('show-left');
} else {
$('body').removeClass('show-left');
}
}
return false;
});
// Add class nav-hover to mene. Useful for viewing sub-menu
jQuery('.leftpanel .nav li').hover(function(){
$(this).addClass('nav-hover');
}, function(){
$(this).removeClass('nav-hover');
});
// For Media Queries
jQuery(window).resize(function() {
hideMenu();
});
hideMenu(); // for loading/refreshing the page
function hideMenu() {
if($('.header-right').css('position') == 'relative') {
$('body').addClass('hidden-left');
$('.headerwrapper, .mainwrapper').removeClass('collapsed');
} else {
$('body').removeClass('hidden-left');
}
// Seach form move to left
if ($(window).width() <= 360) {
if ($('.leftpanel .form-search').length == 0) {
$('.form-search').insertAfter($('.profile-left'));
}
} else {
if ($('.header-right .form-search').length == 0) {
$('.form-search').insertBefore($('.btn-group-notification'));
}
}
}
collapsedMenu(); // for loading/refreshing the page
function collapsedMenu() {
if($('.logo').css('position') == 'relative') {
$('.headerwrapper, .mainwrapper').addClass('collapsed');
} else {
$('.headerwrapper, .mainwrapper').removeClass('collapsed');
}
}
});
&__item{
padding: 20px 13px 0px 13px;
border-top: 12px solid transparent; /* бордюр есть всегда, но прозрачный*/
&:hover{
border-top-color: red;
}
}