首页 \ 问答 \ jupyter笔记本无法在GitHub中呈现(jupyter notebook not rendering in GitHub gist)

jupyter笔记本无法在GitHub中呈现(jupyter notebook not rendering in GitHub gist)

我使用Jupyter笔记本创建并保存了一个笔记本。 然后我开始创建这个笔记本的github要点。 但是,笔记本没有在要点中呈现。 我只能看到原始代码。 我在下面列出了我的要点的链接:

https://gist.github.com/adikamath/26ae33d4fd613d716cdf01697130e675

我知道GitHub从一段时间以来就为ipnyb提供了高级支持,而且我不必使用像nbviewer这样的服务来查看它。 任何帮助表示赞赏。


I created and saved a notebook using Jupyter notebooks. I then proceeded to create a github gist of this notebook. However, the notebook is not being rendered in the gist. I can only see the raw code. I have included the link to my gist below:

https://gist.github.com/adikamath/26ae33d4fd613d716cdf01697130e675

I know that GitHub provides advanced support for ipnyb since some time now and I don't have to use a service like nbviewer to see it rendered. Any help is appreciated.


原文:https://stackoverflow.com/questions/47868625
更新时间:2023-03-26 09:03

最满意答案

听起来你可能需要按顺序而不是并行地进行ajax调用。

首先,将您的四个部分包装在function() {...}并从每个部分返回jqXHR

function make_zero_rate_graph() {
    /*================================
    =            Zero Rate           =
    ==================================*/
    // 1-31 days
    return $.ajax({url: '/api/timebase/'+'{{ $cpe_mac }}/zero-rate'}).then(function(data) {
        if(data) {
            var gragh_ubb_0_rate = new FusionCharts({
                'type': 'bar2d',
                'renderAt': 'gragh_ubb_0_rate',
                'width': '100%',
                'dataFormat': 'json',
                'dataSource': {
                    'chart': $.extend({}, graph_ubb_configs, {
                        'caption': 'Zero Rated Traffic',
                        'subcaption': [data.m, data.d, data.y].join('/'),
                        'xaxisname': 'Bandwidth'
                    }),
                    'data': [
                        { 'label': 'Uplink', 'value': +data.zero_rate_vlan.up_bytes / 1000000 }, 
                        { 'label': 'Downlink', 'value': +data.zero_rate_vlan.down_bytes / 1000000 }
                    ],
                    'trendlines': t_line
                }
            });
            gragh_ubb_0_rate.render();
        }
    });
}

function make_hour_graph() {
    /*===========================
    =            Hour           =
    =============================*/
    return $.ajax({url: '/api/timebase/'+'{{ $cpe_mac }}/hour'}).then(function(data) {
        var gragh_ubb_hour = new FusionCharts({
            'type': 'column2d',
            'renderAt': 'gragh_ubb_hour',
            'width': '100%',
            'dataFormat': 'json',
            'dataSource': {
                'chart': $.extend({}, graph_ubb_configs, {
                    'caption': 'Daily Network Usage',
                    'subcaption': data.m + '/' + data.d + '/' + data.y + ' ( '+data.time+' )',
                    'xaxisname': 'Hours of Day'
                }),
                'data': data.hour_p_ubb.slice(0, 24).map(function(item, i) {
                    return {
                        'label': (i%12 || 12) + ' ' + ((i<12)?'AM':'PM'),
                        'value': (+item.up_bytes + +item.down_bytes) / 1000000
                    });
                }),
                // 'trendlines': t_line
            }
        });
        gragh_ubb_hour.render();
    });
}

function make_day_graph() {
    /*===========================
    =            DAY            =
    =============================*/
    // 1-31 days
    return $.ajax({url: '/api/timebase/'+'{{ $cpe_mac }}/day'}).then(function (data) {
        var c_val = 0;
        var gragh_ubb_day = new FusionCharts({
            'type': 'msline',
            'renderAt': 'gragh_ubb_day',
            'width': '100%',
            'dataFormat': 'json',
            'dataSource': {
                'chart': $.extend({}, graph_ubb_configs, {
                    'caption': 'Monthly Network Usage',
                    'subcaption': data.m + '/' + data.d + '/' + data.y,
                    'xaxisname': 'Days of Month'
                }),
                'categories': [{
                    'category': data.day_p_ubb.map(function(_, i) {
                        return { 'label': String(i+1) };
                    })
                }],
                'dataset': [{
                    'data': data.day_p_ubb.map(function(item, i) {
                        c_val += (i > 0 && i <= data.d) ? ((+item.up_bytes + +item.down_bytes) / 1000000) : 0;
                        return { 'value': c_val };
                    })
                }],
                'trendlines': t_line
            }
        });
        gragh_ubb_day.render();
    });
}

function make_month_graph() {
    /*============================
    =            Month           =
    ==============================*/
    var months = ['January', 'Febuary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November','December'];
    return $.ajax({url: '/api/timebase/'+'{{ $cpe_mac }}/month'}).then(function (data) {
        var graph_month = new FusionCharts({
            'type': 'column2d',
            'renderAt': 'graph_month',
            'width': '100%',
            'dataFormat': 'json',
            'dataSource': {
                'chart': $.extend({}, graph_ubb_configs, {
                    'caption': 'Yearly Network Usage',
                    'subcaption': [data.m, data.d, data.y].join('/'),
                    'xaxisname': 'Months of Year'
                }),
                'data': data.month_p_ubb.slice(0,12).map(function(data, i) {
                    return {
                        'label': months[i],
                        'value': (+data.up_bytes + +data.down_bytes) / 1000000
                    };
                }),
                'trendlines': t_line
            }
        });
        graph_month.render();
    });
}

函数内的代码已整理但未经过测试

有了这些功能,按顺序调用是微不足道的:

// List the functions in an array 
var fns = [ make_zero_rate_graph, make_hour_graph, make_day_graph, make_month_graph ];

// And build a then() chain by reducing the array,
// see http://stackoverflow.com/documentation/javascript/231/promises/5917/#t=201612121359154320486
fns.reduce(function(jqPromise, fn) {
    return jqPromise.then(fn);
}, $.when());

Sounds like you might need to make the ajax call sequentially instead of in-parallel.

First, wrap your four parts in function() {...} and return jqXHR from each.

function make_zero_rate_graph() {
    /*================================
    =            Zero Rate           =
    ==================================*/
    // 1-31 days
    return $.ajax({url: '/api/timebase/'+'{{ $cpe_mac }}/zero-rate'}).then(function(data) {
        if(data) {
            var gragh_ubb_0_rate = new FusionCharts({
                'type': 'bar2d',
                'renderAt': 'gragh_ubb_0_rate',
                'width': '100%',
                'dataFormat': 'json',
                'dataSource': {
                    'chart': $.extend({}, graph_ubb_configs, {
                        'caption': 'Zero Rated Traffic',
                        'subcaption': [data.m, data.d, data.y].join('/'),
                        'xaxisname': 'Bandwidth'
                    }),
                    'data': [
                        { 'label': 'Uplink', 'value': +data.zero_rate_vlan.up_bytes / 1000000 }, 
                        { 'label': 'Downlink', 'value': +data.zero_rate_vlan.down_bytes / 1000000 }
                    ],
                    'trendlines': t_line
                }
            });
            gragh_ubb_0_rate.render();
        }
    });
}

function make_hour_graph() {
    /*===========================
    =            Hour           =
    =============================*/
    return $.ajax({url: '/api/timebase/'+'{{ $cpe_mac }}/hour'}).then(function(data) {
        var gragh_ubb_hour = new FusionCharts({
            'type': 'column2d',
            'renderAt': 'gragh_ubb_hour',
            'width': '100%',
            'dataFormat': 'json',
            'dataSource': {
                'chart': $.extend({}, graph_ubb_configs, {
                    'caption': 'Daily Network Usage',
                    'subcaption': data.m + '/' + data.d + '/' + data.y + ' ( '+data.time+' )',
                    'xaxisname': 'Hours of Day'
                }),
                'data': data.hour_p_ubb.slice(0, 24).map(function(item, i) {
                    return {
                        'label': (i%12 || 12) + ' ' + ((i<12)?'AM':'PM'),
                        'value': (+item.up_bytes + +item.down_bytes) / 1000000
                    });
                }),
                // 'trendlines': t_line
            }
        });
        gragh_ubb_hour.render();
    });
}

function make_day_graph() {
    /*===========================
    =            DAY            =
    =============================*/
    // 1-31 days
    return $.ajax({url: '/api/timebase/'+'{{ $cpe_mac }}/day'}).then(function (data) {
        var c_val = 0;
        var gragh_ubb_day = new FusionCharts({
            'type': 'msline',
            'renderAt': 'gragh_ubb_day',
            'width': '100%',
            'dataFormat': 'json',
            'dataSource': {
                'chart': $.extend({}, graph_ubb_configs, {
                    'caption': 'Monthly Network Usage',
                    'subcaption': data.m + '/' + data.d + '/' + data.y,
                    'xaxisname': 'Days of Month'
                }),
                'categories': [{
                    'category': data.day_p_ubb.map(function(_, i) {
                        return { 'label': String(i+1) };
                    })
                }],
                'dataset': [{
                    'data': data.day_p_ubb.map(function(item, i) {
                        c_val += (i > 0 && i <= data.d) ? ((+item.up_bytes + +item.down_bytes) / 1000000) : 0;
                        return { 'value': c_val };
                    })
                }],
                'trendlines': t_line
            }
        });
        gragh_ubb_day.render();
    });
}

function make_month_graph() {
    /*============================
    =            Month           =
    ==============================*/
    var months = ['January', 'Febuary', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November','December'];
    return $.ajax({url: '/api/timebase/'+'{{ $cpe_mac }}/month'}).then(function (data) {
        var graph_month = new FusionCharts({
            'type': 'column2d',
            'renderAt': 'graph_month',
            'width': '100%',
            'dataFormat': 'json',
            'dataSource': {
                'chart': $.extend({}, graph_ubb_configs, {
                    'caption': 'Yearly Network Usage',
                    'subcaption': [data.m, data.d, data.y].join('/'),
                    'xaxisname': 'Months of Year'
                }),
                'data': data.month_p_ubb.slice(0,12).map(function(data, i) {
                    return {
                        'label': months[i],
                        'value': (+data.up_bytes + +data.down_bytes) / 1000000
                    };
                }),
                'trendlines': t_line
            }
        });
        graph_month.render();
    });
}

Code within the functions is tidied but not tested

With those functions in place, calling in sequence is trivial :

// List the functions in an array 
var fns = [ make_zero_rate_graph, make_hour_graph, make_day_graph, make_month_graph ];

// And build a then() chain by reducing the array,
// see http://stackoverflow.com/documentation/javascript/231/promises/5917/#t=201612121359154320486
fns.reduce(function(jqPromise, fn) {
    return jqPromise.then(fn);
}, $.when());

相关问答

更多
  • 请求中有几件事要注意你正在做的事情。 您需要将status添加到200因为它是OK状态。 意味着您的请求会通过。 所以这部分将完全变成(this.readyState == 4 && this.status == 200) 。 您还需要从使用三重等号===更改为==因为您没有按TYPE进行比较,因为在JS中使用三重等号。 使用事件处理程序xhttp.onreadystatechange而不是xmr.readySate 。 这是一个Mozilla文档的链接 。 所以它应该成为: const xhttp = n ...
  • 我想通过添加一个回调函数并在成功函数中调用它,如下所示: success: function (response) { // callback(response); // }, I figured this out by adding a callback function and calling it within the success function, like so: success: function (response) { // callback(response); // ...
  • 来自.trigger()上的jQuery文档: “事件对象总是作为第一个参数传递给事件处理程序,但是如果在.trigger()调用期间指定了其他参数,那么这些参数也会传递给处理程序。” 他们给出的例子是: $('#foo').bind('custom', function(event, param1, param2) { alert(param1 + "\n" + param2); }); $('#foo').trigger('custom', ['Custom', 'Event']); 所以我更新了: . ...
  • 有两种解决方案: 1)将输入按钮类型从提交更改为按钮并再次尝试,因为您也通过单击提交表单,这可能导致问题。 2)在按钮单击上尝试event.preventDefault()。 Two solutions can be possible: 1) Change input button type from submit to button and try again, as you are also submitting form by clicking on it as well which might be ...
  • 听起来你可能需要按顺序而不是并行地进行ajax调用。 首先,将您的四个部分包装在function() {...}并从每个部分返回jqXHR 。 function make_zero_rate_graph() { /*================================ = Zero Rate = ==================================*/ // 1-31 days return $.a ...
  • 这一切都取决于你的后端是什么以及它是如何配置的。 它可以是VPS,它可以是专用服务器,也可以是云。 它可以有一个节点或几个节点。 它可以使用一个数据库,也可以分发数据库。 由于您注意到请求未同时处理,因此在您的情况下,服务器看起来像一个节点/一个进程/一个数据库。 或者它可能无法并行运行这两个操作,因为第二个请求的结果取决于第一个请求的结果。 It all depends on what your backend is and how it's configured. It could be a VPS, ...
  • 有时在服务器端“准备”JavaScript代码更方便。 您可以使用服务器的编程或脚本语言来生成代码,您可以使用数据库中的值填充它。 这样,大多数逻辑都发生在服务器上而不是客户端上。 但这真的是品味问题。 好吧,那不是一个真实世界的案例,但也许我的意见无论如何都是有帮助的。 Sometimes it is more convenient to "prepare" the JavaScript code on the server side. You can use the server's programmi ...
  • 铬人们承认这是他们应该解决的问题: https : //code.google.com/p/chromium/issues/detail?id = 244910 ,但与此同时我使用jquery defer / resolve实现了限制以保持线程数低。 The chromium folks acknowledge this is something that they should fix: https://code.google.com/p/chromium/issues/detail?id=244910, ...
  • 在其他帖子中,人们建议使用Chrome CORS扩展程序,但自Chrome 48以来,所有CORS扩展程序似乎都停止了工作。 我在Visual Studio,Ripple Emulator和CORS / Cross Domain Ajax上发布了这个解决方法,但我将在下面再次概述: 在您的Chrome安装目录中 - 可能是C:\ Program Files(x86)\ Google \ Chrome \ Application - 创建chrome.exe的快捷方式 右键单击此快捷方式并选择“属性” 在“快 ...

相关文章

更多

最新问答

更多
  • h2元素推动其他h2和div。(h2 element pushing other h2 and div down. two divs, two headers, and they're wrapped within a parent div)
  • 创建一个功能(Create a function)
  • 我投了份简历,是电脑编程方面的学徒,面试时说要培训三个月,前面
  • PDO语句不显示获取的结果(PDOstatement not displaying fetched results)
  • Qt冻结循环的原因?(Qt freezing cause of the loop?)
  • TableView重复youtube-api结果(TableView Repeating youtube-api result)
  • 如何使用自由职业者帐户登录我的php网站?(How can I login into my php website using freelancer account? [closed])
  • SQL Server 2014版本支持的最大数据库数(Maximum number of databases supported by SQL Server 2014 editions)
  • 我如何获得DynamicJasper 3.1.2(或更高版本)的Maven仓库?(How do I get the maven repository for DynamicJasper 3.1.2 (or higher)?)
  • 以编程方式创建UITableView(Creating a UITableView Programmatically)
  • 如何打破按钮上的生命周期循环(How to break do-while loop on button)
  • C#使用EF访问MVC上的部分类的自定义属性(C# access custom attributes of a partial class on MVC with EF)
  • 如何获得facebook app的publish_stream权限?(How to get publish_stream permissions for facebook app?)
  • 如何防止调用冗余函数的postgres视图(how to prevent postgres views calling redundant functions)
  • Sql Server在欧洲获取当前日期时间(Sql Server get current date time in Europe)
  • 设置kotlin扩展名(Setting a kotlin extension)
  • 如何并排放置两个元件?(How to position two elements side by side?)
  • 如何在vim中启用python3?(How to enable python3 in vim?)
  • 在MySQL和/或多列中使用多个表用于Rails应用程序(Using multiple tables in MySQL and/or multiple columns for a Rails application)
  • 如何隐藏谷歌地图上的登录按钮?(How to hide the Sign in button from Google maps?)
  • Mysql左连接旋转90°表(Mysql Left join rotate 90° table)
  • dedecms如何安装?
  • 在哪儿学计算机最好?
  • 学php哪个的书 最好,本人菜鸟
  • 触摸时不要突出显示表格视图行(Do not highlight table view row when touched)
  • 如何覆盖错误堆栈getter(How to override Error stack getter)
  • 带有ImageMagick和许多图像的GIF动画(GIF animation with ImageMagick and many images)
  • USSD INTERFACE - > java web应用程序通信(USSD INTERFACE -> java web app communication)
  • 电脑高中毕业学习去哪里培训
  • 正则表达式验证SMTP响应(Regex to validate SMTP Responses)