I am having difficulty having the export feature to work on my server. I have tried searching and there is not much I can get specifically. I have tried both features and the same error shows up each time. This is the error I am getting
./phantomjs highcharts-convert.js -infile test.js -outfile chart.png
ReferenceError: Can't find variable: $
ERROR: the options variable was not available, contains the infile an syntax error? see ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
contents of test.js are :
{
xAxis: {
categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},
series: [{
data: [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
};
I have tried putting it in JSON format but it doesn't seem to be working...
I had the exact same error...
Make sure you have 3 important files in the same folder as highcharts-convert.js
highcharts.js -or- highstock.js
highcharts-more.js
jquery.js
Then, update the file names at the top of highcharts-convert.js to match these file names and save it.
var config = {
/* define locations of mandatory javascript files */
HIGHCHARTS: 'highcharts.js',
HIGHCHARTS_MORE: 'highcharts-more.js',
JQUERY: 'jquery.js',
TIMEOUT: 2000 /* 2 seconds timout for loading images */
},
Now you should have no more errors (or at least a different one, ha)
When I downloaded highcharts-convert.js it had a tiny typo in the config: instead of jquery-1.9.1.min.js it said jquery.1.9.1.min.js (note the . instead of a -)
Took me an hour of digging and experimenting to figure it out... Hope this can save others some time.
I was getting a similar error. When I had downloaded the HighCharts package, I ended up with highcharts-convert.js containing:
HIGHCHARTS: 'highstock.js'
rather than
HIGHCHARTS: 'highcharts.js'
Once I changed that filename, the chart was generated without issue.
There is an error in the jquery filename within highcharts-convert.js. The part that says JQUERY: 'jquery.1.9.1.min.js', should be jquery-1.9.1.min.js. Note the '-' instead of '.'.
Also if you are getting a bunch of errors other than ReferenceError: Can't find variable: $ make sure you comment out the file dependencies that you don't need in the top of highcharts-convert.js.
That was quite frustrating to figure out...
In highcharts-convert.js you have to define paths for:
Highcharts library
jQuery library
Otherwise it won't work.
Same issue here. I was invoking the command from shell_exec within PHP and Apache Web Server. The user that executed the command (www-data or apache) doesn't have read permissions on jquery.min.js so the execution fails (by the way apache was killed by phantomjs) and I had ReferenceError: Can't find variable: $ because jquery weren't included at all. Hope this helps
Related
At the beginning I got a problem with the french date in the antd calendar. I use vite so I install the antd_dayjs_vite_plugin to switch from Moment.js to Day.js. It worked well but this morning the vite build process is in error. I tried to update the antd_dayjs_vite_plugin version (was 1.1.4) and now I got the same problem when I try to lunch a yarn dev as you can see :
$ yarn dev
yarn run v1.22.15
$ vite
failed to load config from vite.config.ts
error when starting dev server:
TypeError: (0 , import_antd_dayjs_vite_plugin.default) is not a function [...]
Here is the code in vite.config.ts :
import reactRefresh from '#vitejs/plugin-react-refresh';
import antdDayjs from 'antd-dayjs-vite-plugin';
import { defineConfig } from 'vite';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [reactRefresh(), antdDayjs()],
server: {
host: process.env.HOST || '127.0.0.1',
},
resolve: {
alias: [{ find: '#', replacement: '/src' }],
},
define: {
__APP_VERSION__: JSON.stringify(process.env.npm_package_version),
},
build: {
commonjsOptions: {
transformMixedEsModules: true,
},
},
});
The problem also appears in antd-dayjs-vite-plugin 1.1.4 version or the 1.2.2. I also already tried to update vite to 3.1 (was in 2.5).
I don't understand the code seems to be exactly the same as the usage in the Readme package.
Thanks in advance for your help. 🙏🏻
Seams that a default export is expected by vite.js (tried to replace import statement with import {antdDayjs} from 'antd-dayjs-vite-plugin'; without success)
I was able to create a workaround using patch-package with the below steps:
modifiy node_modules/antd-dayjs-vite-plugin/dist-node/index.js
at the very end of that file, add exports.default = antdDayjs;
create a patch for antd-dayjs-vite-plugin
ensure you have the postinstall script (refer to patch-package doc)
I have a Rails 6 project with webpacker 4.2.2 configured to split vendor chunks into individual files:
# config/webpack/environment.js
const { environment } = require('#rails/webpacker')
const webpack = require('webpack')
environment.config.merge({
plugins: [
new webpack.HashedModuleIdsPlugin(),
],
optimization: {
minimize: true,
runtimeChunk: 'single',
splitChunks: {
chunks: 'all',
maxInitialRequests: Infinity,
minSize: 0,
cacheGroups: {
// #see https://hackernoon.com/the-100-correct-way-to-split-your-chunks-with-webpack-f8a9df5b7758
vendor: {
test: /[\\/]node_modules[\\/]/,
name(module) {
const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
return `npm.${packageName.replace('#', '')}`;
},
priority: 10,
},
}
}
}
})
module.exports = environment
When we precompile our assets, this produces fingerprinted files for each NPM dependency, which we upload for long-term caching and CDN-based distribution.
However, we're noticing that when we add a new library to the pack, this unexpectedly causes a rehash of many chunk files for dependencies that have not changed at all.
For example, this change in my app/javascript/packs/application.js:
require("#rails/ujs").start()
require("turbolinks").start()
require("#rails/activestorage").start()
require("channels")
import 'msr'
import copy from 'clipboard-copy'
+import axios from 'axios'
will produce the following change in my output chunks (produced from running bin/rails webpacker:compile):
--- a 2020-07-06 18:39:52.202440803 +0000
+++ b 2020-07-06 18:39:52.210440748 +0000
## -1,6 +1,8 ##
-application-1e8721172ae65f57286b.chunk.js
-npm.clipboard-copy-10b42ffbc97b4e927071.chunk.js
-npm.msr-01ea266e2c932167f10b.chunk.js
-npm.rails-a4564cfc542024efeb95.chunk.js
-npm.turbolinks-eeef46ff44962af9ac87.chunk.js
-npm.webpack-7226f5cf46a8c4e61c26.chunk.js
+application-bad0ed20808541f88894.chunk.js
+npm.axios-40b4b54ebace2b9e3907.chunk.js
+npm.clipboard-copy-79d2051f48603e0267e0.chunk.js
+npm.msr-f5a4252b7a7e0a94157f.chunk.js
+npm.process-cfe824ecbab5abe0eecc.chunk.js
+npm.rails-aa1c430d6ceee3ca6bd6.chunk.js
+npm.turbolinks-e28554dbfd4b75aa12e5.chunk.js
+npm.webpack-35f718d9a20b8bca2927.chunk.js
This is a double whammy because of unnecessary cache invalidation and additional CDN transfer costs.
My question is, is there a way to ensure the vendor chunk doesn't get rehashed because of dependency changes?
I don't know if this is a limitation with the way that webpack's SplitChunksPlugin works, but any advice is appreciated.
By the way, I've prepared a minimal Rails project that reproduces the situation I've described above: https://github.com/alextsui05/webpacker-vendor-chunks
A detailed summary is included in the README on the repository, and I invite any answerers to discuss based on that code.
Try setting the option moduleIds: 'hashed'
https://v4.webpack.js.org/configuration/optimization/#optimizationmoduleids
I am trying to set up VsCode to run my spec tests in debug mode.
I have added the following launch.json file to the project. I am using rvm and have installed the necessary gems in that location such as rspec.
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "RSpec - all",
"type": "Ruby",
"request": "launch",
"program": "<home>.rvm/gems/ruby-2.4.5/gems/rspec",
"args": [
"-I",
"${workspaceRoot}/spec/*_spec.rb"
]
}
]
}
When I run in debug mode the following displays in the console.
Uncaught exception: cannot load such file --
home-directory/.rvm/gems/ruby-2.4.5/gems/rspec
I've installed the necessary extension based on the documentation I found.
ruby, solargraph, and rubicon
Any help would be greatly appreciated.
Thank you,
Joe
Set the output from which rspec command as "program" parameter.
The problem is that the path "home-directory/.rvm/gems/ruby-2.4.5/gems/rspec" is not a valid path. You can test that theory by simply pasting into your console and executing.
In order to locate the actual rspec binary, you can use run which rspec. However, while it is possible to hard code this path into your launch config, you don't want to do that because when you upgrade the version, the path will change and you'll have problems running your tests again.
A better way is to use the environment variable that points to the GEM_HOME that includes rspec.
Here are the settings that worked for me, on ruby 3.0.3 managed by rvm on OSX.
Gemfile includes:
group :development do
gem 'ruby-debug-ide'
gem 'debase', "~> 0.2.5.beta2"
end
(the stable version of debase didn't support ruby v3, hence the beta)
Launch config use the GEM_HOME environment variable to specify the rspec binary:
{
"name": "RSpec - all",
"type": "Ruby",
"request": "launch",
"program": "${env:GEM_HOME}/bin/rspec",
"args": [
"-I",
"${workspaceRoot}"
]
}
For the javascripts translations in Rails 4 I used the following library.
I did:
Gemfile:
gem "i18n-js", ">= 3.0.0.rc11"
In assets/javascripts/application.rb:
//= require i18n/translations
and finally I worked on the config/locales/en.yml data
Example:
en:
save:
text1: value1
independency:
text2: value2
In the view I used this for the translations, as in Rails.
series: [{
name: '',
data: [
["<%=t 'independency.text1' %>", independency],
["<%=t 'save.text2' %>", 100-independency],
]
}]
The thing is that I have to run this command rake i18n:js:export after doing any change in the translation file that involved the javascript part.
Moreover, the next day after starting the PC and opening again my application (localhost:3000) the javascript translations did not work at all. I had to run again the command rake i18n:js:export.
Is there any option to avoid executing this command every time? For me is difficult to understand the documentation.
I'm trying to export a highchart graph from the command line, following the steps the highchart website gives here: http://www.highcharts.com/docs/export-module/render-charts-serverside
It always fails with this error:
ReferenceError: Can't find variable: Highcharts
In more detail, the steps they are give are just these:
Download and install phantomjs
Save these files all to one location: highcharts-convert.js, highcharts.js, highcharts-more.js, jquery
Good to go.
So, I followed the above steps as shown here:
First, install phantomjs:
>npm install -g phantomjs
verify install:
>phantomjs -v
1.9.7
Second, save indicated files in one location, as you can see here I have:
>ls
data.js highcharts-convert.js highcharts.js map.js options.json
highcharts-3d.js highcharts-more.js jquery.1.9.1.min.js readme.md
Third, I should be good to go, but ... :
A. their sample command requires an "options.json" file to provide the options in. I couldn't find documentation for this on their site, but googling it, my options.json file looks like this:
>more options.json
{
"xAxis": {
"categories": ["Jan", "Feb","Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
},
"series": [{
"data": [29.9, 71.5, 106.4, 129.2, 144.0, 176.0, 135.6, 148.5, 216.4, 194.1, 95.6, 54.4]
}]
}
B. run the example command line provided on the highcharts page:
>phantomjs highcharts-convert.js -infile options.json -outfile chart.png -scale 2.5 -width 300
ReferenceError: Can't find variable: Highcharts
highcharts-more.js:51
ReferenceError: Can't find variable: Highcharts
data.js:16
ReferenceError: Can't find variable: Highcharts
phantomjs://webpage.evaluate():81
phantomjs://webpage.evaluate():150
phantomjs://webpage.evaluate():150
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
waiting
ERROR: While rendering, there's is a timeout reached
Note that I also tried editing the highcharts-convert.js script to provide the full path for the highcharts and jquery files, but this didn't help.
In the highcharts-convert.js you have list of all files which are loaded by server, if you have missing highcharts-more and others you receive errors. I advice you to comment files which you dont use.