Exporting a highchart from the cmdline with phantomjs - highcharts

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.

Related

Jest test sometimes fails (DynamoDB integration tests)

I have Serverless application (node:14.19.1-bullseye-slim) with almost 400 tests. There are mostly functional tests with using of local DynamoDb. The problem is Bitbucket pipeline sometimes fail with message:
thrown: "Exceeded timeout of 10000 ms for a test.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
The bad thing of this the issue that is not reproducible on local machine. It's green in 9/10 runs. Also on Bitbucket pipeline not every run fails and not in the same test suite.
Here is my configuration:
package.json
"devDependencies": {
"#aws-sdk/client-lambda": "3.58.0",
"#aws-sdk/client-s3": "3.58.0",
"#aws-sdk/client-ssm": "3.58.0",
"#aws-sdk/node-http-handler": "3.58.0",
"#fast-csv/format": "4.3.5",
"aws-sdk": "2.1001.0",
"axios-curlirize": "1.3.7",
"axios-mock-adapter": "1.20.0",
"chalk": "4.1.2",
"eslint": "8.12.0",
"eslint-config-airbnb-base": "15.0.0",
"eslint-plugin-import": "2.25.4",
"eslint-plugin-jest": "26.1.3",
"ion-js": "4.2.2",
"jest": "27.5.1",
"jest-junit": "13.0.0",
"js-yaml": "4.1.0",
"jsbi": "4.2.0",
"prettier": "2.6.1"
},
"scripts": {
"ci": "npx jest --coverage --colors --ci"
}
jest.config.js
module.exports = {
collectCoverageFrom: [
'src/**',
],
coverageReporters: [
'text',
'html',
],
maxWorkers: 1,
testEnvironment: 'node',
testTimeout: 10000,
verbose: true,
};
docker-compose.yml
dynamo:
image: amazon/dynamodb-local:1.18.0
command: '-jar DynamoDBLocal.jar -inMemory -sharedDb'
ports:
- "8000:8000"
More logs didn't help
I tried to get more information about failing test. I prepared "custom" DynamoDB docker image and turned-on AWS-SDK logs but it didn't help me a lot. I also tried latest LTS version of Node and AWS-SDK. I also found Jest issue and tried "guaranteed workarounds" but without chance.
Questions
Does someone resolved similar problem?
What I can do more for finding the problem?
The last thing what I have is rewrite tests to not directly using of dockerized DynamoDB but this will be the last try.
I suppose the problem is not on any DynamoDB side.
I have made some research on the problem and found the next thread with a discussion of the error like you. And the error has been appeared after upgrading jest to v.27
https://github.com/facebook/jest/issues/11607
They have assumptions about some bugs in the jest timer. So the solutions can be is:
to increase the timer value above 10 000.
or use jest.useFakeTimers('legacy') setting if possible.
if applicable switch the jest version back to v26.
Assuming Jest is configured correctly there could be a few reasons why this is happening:
Stateful tests whereby the order of the tests matters, and tests are not being executed in the same order each time, or between runs tables have changed
Throughput Capacity problems, as many tests are executed in a very quick manor this may mean that your table does not have enough WCU RCU to handle the requests
Tables not being cleaned correctly before each run
I have had a lot of problems when running tests with DynamoDB because I'd typically be using a test Table which is not provisioned with a high capacity because it is not needed normally. But when you run many tests really quickly even if it is only on your machine this can happen.

How to set the url of moment.min.js to local js file when highcharts exporting png file

When I am using 'hicharts-export-server' as local service module in node.js to rendering and exporting images, i got these error message after 7 hours :
Tue Mar 19 2019 13:31:33 GMT+0800 (China Standard Time) [error]
phantom worker 631 error - worker.js resource error - {
"errorCode": 3,
"errorString": "Host cdnjs.cloudflare.com not found",
"id": 2,
"status": null,
"statusText": null,
"url": "https://cdnjs.cloudflare.com/ajax/libs/moment-timezone/0.5.13/moment-timezone-with-data-2012-2022.min.js"
}
Tue Mar 19 2019 13:31:33 GMT+0800 (China Standard Time) [error]
phantom worker "Host cdnjs.cloudflare.com not found",
"id": 1,
"status": null,
"statusText": null,
"url": "https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.18.1/moment.min.js"
}
I think the phantom worker was trying download js files from external server but failed, so I want to save these js files to local disk and the phantom worker do know download each time.
How to solve this problem?
Thank a lot !
Since version 2.0.9, in highcharts-export-server you can enable moment.js
by running npm install interactively, or by setting the environment variable HIGHCHARTS_MOMENT to 1.
Related issue: https://github.com/highcharts/node-export-server/issues/119
Never mind please, I found these scripts and changed the url to local file, problem was solved.
sorry for my disturbing.

Every time I try to deploy I get - (gcloud.preview.app.deploy) Error Response: [4] DEADLINE_EXCEEDED

I'm new to Google cloud and I'm trying to do my first deploy to it. My first deploy is a Ruby on Rails project.
I'm basically following this guide in the google cloud documentation. The only difference being that I'm using my own project instead of the 'hello world' project they supply.
This is my app.yaml file
runtime: custom
vm: true
entrypoint: bundle exec rackup -p 8080 -E production config.ru
resources:
cpu: 0.5
memory_gb: 1.3
disk_size_gb: 10
When I go to my project directory and run gcloud preview app deploy it starts the deploy but appears to eventually time out. It gives the error (gcloud.preview.app.deploy) Error Response: [4] DEADLINE_EXCEEDED.
Doing some research I found running gcloud preview app deploy with --verbosity debug gives extra debug info but it doesn't help me find whats causing it to timeout.
Here is the last chunk of the console log.
Bundle complete! 35 Gemfile dependencies, 102 gems now installed.
Bundled gems are installed into ./vendor/bundle.
Post-install message from rdoc:
Depending on your version of ruby, you may need to install ruby rdoc/ri data:
<= 1.8.6 : unsupported
= 1.8.7 : gem install rdoc-data; rdoc-data --install
= 1.9.1 : gem install rdoc-data; rdoc-data --install
>= 1.9.2 : nothing to do! Yay!
Post-install message from compass:
Compass is charityware. If you love it, please donate on our behalf at http://umdf.org/compass Thanks!
DEBUG: Operation [operations/build/guidir-1286/MmFkZjNmOGYtZDhhZi00NTJmLTk0YWEtMmQzMjBmM2JkOTg2OlVT] complete. Result: {
"metadata": {
"#type": "type.googleapis.com/google.devtools.cloudbuild.v1.BuildOperationMetadata",
"build": {
"finishTime": "2016-04-20T01:55:44.961635Z",
"status": "TIMEOUT",
"timeout": "600.000s",
"projectId": "guidir-1286",
"id": "2adf3f8f-d8af-452f-94aa-2d320f3bd986",
"source": {
"storageSource": {
"object": "us.gcr.io/guidir-1286/appengine/default.20160420t110030:latest",
"bucket": "staging.guidir-1286.appspot.com"
}
},
"steps": [
{
"args": [
"us.gcr.io/guidir-1286/appengine/default.20160420t110030:latest"
],
"name": "gcr.io/cloud-builders/dockerizer"
}
],
"startTime": "2016-04-20T01:45:43.216420Z",
"logsBucket": "staging.guidir-1286.appspot.com",
"images": [
"us.gcr.io/guidir-1286/appengine/default.20160420t110030:latest"
],
"createTime": "2016-04-20T01:45:41.861657Z"
}
},
"done": true,
"name": "operations/build/guidir-1286/MmFkZjNmOGYtZDhhZi00NTJmLTk0YWEtMmQzMjBmM2JkOTg2OlVT",
"error": {
"message": "DEADLINE_EXCEEDED",
"code": 4
}
}
DEBUG: (gcloud.preview.app.deploy) Error Response: [4] DEADLINE_EXCEEDED
Traceback (most recent call last):
File "/Users/Robert/google-cloud-sdk/lib/googlecloudsdk/calliope/cli.py", line 654, in Execute
result = args.cmd_func(cli=self, args=args)
File "/Users/Robert/google-cloud-sdk/lib/googlecloudsdk/calliope/backend.py", line 1401, in Run
resources = command_instance.Run(args)
File "/Users/Robert/google-cloud-sdk/lib/surface/preview/app/deploy.py", line 507, in Run
config_cleanup)
File "/Users/Robert/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/deploy_command_util.py", line 195, in BuildAndPushDockerImages
storage_client)
File "/Users/Robert/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/deploy_command_util.py", line 245, in _BuildImagesWithCloudBuild
image.tag, cloudbuild_client)
File "/Users/Robert/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/cloud_build.py", line 181, in ExecuteCloudBuild
retry_callback=log_tailer.Poll)
File "/Users/Robert/google-cloud-sdk/lib/googlecloudsdk/api_lib/app/api/operations.py", line 69, in WaitForOperation
encoding.MessageToPyValue(completed_operation.error)))
OperationError: Error Response: [4] DEADLINE_EXCEEDED
ERROR: (gcloud.preview.app.deploy) Error Response: [4] DEADLINE_EXCEEDED
This is the furthest its gone, but sometimes its mid way through installing the gems before it times out and other times it doesn't even get upto installing the gems.
How can I stop this from occurring?
There's a 10 minute default timeout for Docker builds (the mechanism by which runtime: custom App Engine builds work). You can increase this by running gcloud config set app/cloud_build_timeout [NUMBER OF SECONDS].
You could also work around by performing the build yourself:
docker build . -t gcr.io/myapp/myimage
gcloud docker push gcr.io/myapp/myimage
gcloud preview app deploy app.yaml --image-url=gcr.io/myapp/myimage
However, in general, your Docker builds shouldn't be taking this long. It's usually better to have a base image with all of your dependencies already built in, and just have the final build derive from that image and install your app. This way, your builds will be much quicker.
This error is raised when the overall request times out.
The execution limit is 10 minutes for task queue requests.
You can increase this timeout limit on google cloud shell, by typing gcloud config set app/cloud_build_timeout [TIMEOUT_SECONDS]
Example
gcloud config set app/cloud_build_timeout 1000

Can't deploy Visual Studio Cordova app to iPhone using remote agent: CordovaModuleLoadError

I am trying to deploy my Cordova app to my iPhone using Visual Studio 2015 RC by Remote Agent > Local Device. I have successfully installed, ran and connect the remote agent to my Visual Studio. According to this link, when I run Local Device, iTunes should pop up on my Windows PC and install the app to my iPhone:
https://msdn.microsoft.com/en-us/library/dn757056.aspx
New build request submitted:
/build/tasks?command=build&vcordova=4.3.0&cfg=debug&options=--device
{ 'accept-language': 'en-US',
host: '192.168.0.9:3000',
connection: 'keep-alive',
'transfer-encoding': 'chunked' }
New build request submitted for cordovaVersion: 4.3.0; buildCommand: build; configuration: debug
Build will be executed under: /Users/JP/remote-builds/builds/3563
Saving build request payload to : /Users/JP/remote-builds/builds/3563
Saved upload to /Users/JP/remote-builds/builds/3563/upload_3563.tgz
Extracting /Users/JP/remote-builds/builds/3563/upload_3563.tgz to /Users/JP/remote-builds/builds/3563/cordovaApp...
POST /build/tasks?command=build&vcordova=4.3.0&cfg=debug&options=--device 202 5123ms - 487b
GET /build/tasks/3563 200 0ms - 487b
Extracted app contents from uploaded build request to /Users/JP/remote-builds/builds/3563/cordovaApp. Requesting build.
Taking 3563 as current build
Building cordova app CordovaApp2 at appDir /Users/JP/remote-builds/builds/3563/cordovaApp
Opened build log file /Users/JP/remote-builds/builds/3563/build.log
Done building 3563 : error CordovaModuleLoadError [ '4.3.0' ]
Done with currentBuild. Checking for next build in queue.
GET /build/tasks/3563 200 4ms - 142.31kb
GET /build/tasks/3563/log 200 1ms
Additionally, from Visual Studio I get the error:
EACCES, open '/Users/JP/.npm/_locks/cordova-46ce3f50013cb5f4.lock' CordovaApp2 C:\Users\J\Documents\Visual Studio 2015\Projects\CordovaApp2\CordovaApp2\MDAVSCLI 1
Remote build error from the build server undefined: {1} CordovaApp2 C:\Users\J\Documents\Visual Studio 2015\Projects\CordovaApp2\CordovaApp2\MDAVSCLI 1
When running remote test:
$ vs-mda-remote test --device
Initializing self test for https
downloading cert for pin 360583
Downloading client cert for selftest from https://Jamess-Mac-mini.local:3000/certs/360583 to /Users/JP/remote-builds/selftest/selftest-client.pfx
pfxPath: /Users/JP/remote-builds/selftest/selftest-client.pfx
serverUrl: https://Jamess-Mac-mini.local:3000
buildUrl: https://Jamess-Mac-mini.local:3000/build/tasks?vcordova=4.3.0&cfg=release&command=build&options=--device
Response statusCode: 202
{ 'x-powered-by': 'Express',
'content-type': 'application/json',
'content-location': 'https://jamess-mac-mini.local:3000/build/tasks/3570',
'content-length': '489',
date: 'Tue, 09 Jun 2015 22:05:58 GMT',
connection: 'close' }
Response: {
"buildNumber": 3570,
"status": "uploaded",
"cordovaVersion": "4.3.0",
"buildCommand": "build",
"configuration": "release",
"options": "--device",
"buildDir": "/Users/JP/remote-builds/builds/3570",
"serverDir": "/Users/JP/remote-builds",
"submissionTime": "2015-06-09T22:05:58.691Z",
"changeList": null,
"tgzFilePath": "/Users/JP/remote-builds/builds/3570/upload_3570.tgz",
"statusTime": "2015-06-09T22:05:58.763Z",
"message": "Uploaded build request payload."
}
buildingUrl: https://Jamess-Mac-mini.local:3000/build/tasks?vcordova=4.3.0&cfg=release&command=build&options=--device
[1] Response: {
"buildNumber": 3570,
"status": "error",
"cordovaVersion": "4.3.0",
"buildCommand": "build",
"configuration": "release",
"options": "--device",
"buildDir": "/Users/JP/remote-builds/builds/3570",
"serverDir": "/Users/JP/remote-builds",
"submissionTime": "2015-06-09T22:05:58.691Z",
"changeList": null,
"tgzFilePath": "/Users/JP/remote-builds/builds/3570/upload_3570.tgz",
"messageId": "CordovaModuleLoadError",
"statusTime": "2015-06-09T22:05:59.752Z",
"appDir": "/Users/JP/remote-builds/builds/3570/cordovaApp",
"appName": "HelloCordova",
"messageArgs": [
"4.3.0"
]
}
You are likely encountering the following Known Issue. Basically there's a file somewhere in your npm cache that was added while running as an administrator (sudo). As a result, vs-mda-remote cannot access it. The commands below resolve that issue (and in fact this is what recent versions of npm do by default).
iOS Build Related Known Issues
After installing the latest version of vs-mda-remote package, you may need to run the following commands before you start up the remote agent. These commands ensure your user has permissions to the contents of the npm package cache in your home directory when using older versions of Node.js and npm. Newer versions of Node.js and npm will do this for you automatically.
sudo npm cache clear
sudo chown -R `whoami` ~/.npm

Highcharts Server not loading infile correctly

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

Resources