spark-highcharts export to file (png or pdf) - apache-spark

I have been using spark-highcharts with zeppelin. Through simple examples like:
val chart = highcharts(dataFrame
.seriesCol("city")
.series("y" -> col("temperature")))
chart.plot()
But I do not know how to export the SVG or PDF of the same plot directly through my code to a file. I remember there was an example of it but sadly I cannot find it anymore!

There is a function html is designed for this case. It will generate a html page which include interaction function. It can be send and share with other users.
chart.html(path, filename, open)
after get the html file, you can save or print as PDF file.

Related

How to generate svg images using python 'quantstat' library

using quantstat library's report.py module, I am able to successfully generate .html images when I call quanstat.reports.html function, and quanstat.reports.full function to generate .png images for the various graphs, charts, reports.
https://github.com/ranaroussi/quantstats/blob/main/quantstats/reports.py
can someone help me at the earliest how to use the same 'report.py' module or other modules in this 'quantstat' library to generate images in .svg format so that they can be opened in any browser such as google-chrome.
Which files of this library need to be modified or enhanced with python code to successfully generate .svg files ?
following code is generating png images when I am passing file path to 'savefig' in my local. used VS Code as IDE
import quantstats as qs
stock1 = qs.utils.download_returns('XLE', period="1y")
stock2 = qs.utils.download_returns('SPY' , period="1y")
qs.reports.full(stock1, stock2)
how can I get images in .svg format using same qs.reports.full(stock1, stock2) ?

In python3.9.13, how to know which piece of code in 'quantstats' library is actually generating reports in .png format

I am using https://github.com/ranaroussi/quantstats/blob/main/quantstats/reports.py and calling its full() method to generate reports, charts, graphs etc, in .png format.
Any idea which piece of code in reports.py or it's other called module(s) is actually generating, or appending '.png' to image file ?
a quick help on this will be much appreciated. Thank you.
tried analyzing the reports.py & the functions report.py is calling for the full report as
quanstat.reports.full()
Eventually, the code calls matplotlib's savefig() function, which is the place where .png is appended to the filename.
For example, via the following sequence of calls:
full() -> plots()
plots() -> distribution()
distribution() -> plot_distribution()
plot_distribution() -> matplotlib.pyplot.savefig()
The docs for the savefig() function explain that if no format is explicitly provided, then png is the default and .png will be appended to the file name:
If format is not set, then the format is inferred from the extension of fname, if there is one. If format is not set and fname has no extension, then the file is saved with rcParams["savefig.format"] (default: 'png') and the appropriate extension is appended to fname.

How to open a binary file in my case .nii file using node.js

I want to open a binary file, or at least when I try to open this with the vscode editor, is say that, can't be opened, because is a binary file.
Can someone explain to me what I can do in order to open this type of files and read the content?
About the .nii file format. is a NIFTI1 and used on medical visualization like MRI.
What I trying to do is to read this file at the lowest level and then make some computations.
I will like to use Node.js for this, not any Python or C++.
More details about the file format can be found here.
https://nifti.nimh.nih.gov/
I don't know about how VScode handle binary file but for exemple with Atom (or with another text editor like vi), you can open and view the content of a binary file. This is not very usefull however as the content is not particularly human readable, except maybe some metadata at the top of the file.
$ vim yourniifile.nii
Anyway, it's all depends on what you want to do with that file, which "computation" you're planned to apply to it, and how you will use it after that.
Luckily, there are some npm packages that can help you with the task of reading and processing that kind of file, like nifti-reader-js or nifti-js, for exemple:
const fs = require('fs');
const niftijs = require('nifti-js');
let rawData = fs.readFileSync('yourniifile.nii');
let data = niftijs.parse(rawData);
console.log(data);

Why is bodymovin exporting PNG's and not SVG's?

I'm trying to use lottie to animate an SVG animation created in After Effects. I use the bodymovin extension to export the JSON data file. But, I also noticed the export includes some PNG images. I'm also getting console errors that said PNG's can not be found.
Why is it exporting PNGs as I'm using SVG (an AI file) in AE. Below is my code, and the error.
index.ts
import * as lottie from 'lottie-web';
import * as header from './assets/header.json';
import './css/base.sss';
var animation = lottie.loadAnimation({
container: document.getElementById('header'),
animationData: header,
renderer: 'svg/canvas/html',
autoplay: true
});
But I'm getting the following errors that the images can't be found. Why is bodymovin exporting/looking for pngs? I require SVG's.
Chrome console errors (sorry can't embed until 10 rep)
I found the problem. I have to convert paths to shapes in AI as noted here.
In Adobe After effect, you can use Create Shapes from vector layer
Another way I found was to search the exported .json file for the .png extension and replace the found extensions with .svg. Making sure to add the .svg files to the same directory.
I used this bodymovin render option:
I did my search in the .json file in Dreamweaver like so:
I hope this helps someone!!!

Is it possible to read a standard etherpad as a text document over the api?

I have a public etherpad containing an yaml-file. Using php I would like read this yaml and convert it to a json-string.
There are some great libraries for converting yaml to json. for example:
https://github.com/mustangostang/spyc/
What i'm looking for is an url that will return the contents of a pad as pure text.
You want the text export then. You can easily get the contents of a pad exported as raw text, using the following url:
//<yourdomain>.com/p/<yourpad>/export/txt

Resources