【发布时间】:2016-03-10 08:00:07
【问题描述】:
我在 Rails 4 中使用 plotly.js。现在我只有 lib 文件 /vendor/assets/javascripts/plotly.js 并在 application.js (//= require plotly) 中需要它。 Ploly.js 大约 1 mb,所以我想减小大小。在github页面上有一个instruction如何做到这一点:
// in custom-plotly.js
var plotlyCore = require('plotly.js/lib/core');
// Load in the trace types for pie, and choropleth
plotlyCore.register([
require('plotly.js/lib/pie'),
require('plotly.js/lib/choropleth')
]);
module.exports = plotlyCore;
// Then elsewhere in your code:
var Plotly = require('./path/to/custom-plotly');
我不知道应该把这段代码放在哪里,只为 lib 的一些模块提供服务,而不是为整个 lib 提供服务。
如果无法使用内置功能,您会建议如何解决问题?
【问题讨论】:
标签: ruby-on-rails plotly