I am not a jmeter expert, but I understand it can display graphs and save the data in .xml files.
Is there a way to have jmeter actually create JPG, GIF or PNG files (or whatever format that can be embedded in html?)
Added later: I need a solution that works in a batch run
A simple way would be to right click on a Graph Result to "Save Node as Image".
Use Loadosophia or jmeter-plugins
I would stand by #Andrey Pohilko in agreeing that Loadosophia is the best when it comes to graphs and also jmeter-plugins for addons for jmeter tool.
Check out the sample loadosophia graph here.
I would suggest saving as a CSV file, then using a graphing engine separately to generate graphs. If you want to create them dynamically you could use some open-source graphing tools and a workflow engine.
If you're happy with doing it by hand, Excel?
there is a list of ways to analyze logs on the wiki - http://wiki.apache.org/jakarta-jmeter/LogAnalysis
I use jmetergraph.pl for nice summary reports.
Note that there is a bug with the default jmetergraph.pl, you need to add this to line 313, at the end of the while loop:
close(IN);
}
$glabels{'entire'} = \%entire; # this line added.
print "Found $#labels labels\n" if $DEBUG;
Otherwise you can use the jmeterlog class to create your own images by writing custom code for it.....
Use JMeter-plugins and the listener called JP#GC Graphs Generator:
http://www.ubik-ingenierie.com/blog/automatically-generating-nice-graphs-at-end-of-your-load-test-with-apache-jmeter-and-jmeter-plugins/
In upcoming version 2.14 or 3.0, there will be this new feature that generate an HTML report with dynamic graphs, APDEX table and summary of errors:
http://jmeter.512774.n5.nabble.com/Donation-of-a-New-Dashboard-for-JMeter-Questions-and-more-td5723379.html
It is available in nightly build as of 20th january 2016:
http://jmeter.apache.org/nightly.html
Related
I am trying to embed a plotly graph I created in R on a wordpress website. It seems a lot more difficult than it should. Perhaps I am missing something obvious. Here is what I tried:
solution 1: saved the graph as an html using htmlwidgets::saveWidget(as_widget(Basic_Spending_Graph), file = "Basic_Spending_Graph.html"). Then use that html to either embed the whole file or html source code into the website. There are numerous problems with this approach. Firstly if I embed file it embeds a link to the file where you can open the page rather than fully embedding the graph within the page. Secondly the file is 3 Mbs, which over time could put a strain on website speed which is using shared hosting.
solution 2: export plotly graphs from R to chart studio which allows you to host graph on their server and generate an html embedding snippet. This seems like a great solution, but I am struggling to find an easy way to export from R to chart studio, since I already spent quite a lot of time creating the graphs in R. Apparently there is a way to export the charts to chart studio, but nobody seems to explain how?
I may be missing something very obvious considering plotly was designed with web in the mind! Any advice would be greatly appreciated. What is the best way of getting plotly charts on the webpage?
Thanks!
I can't help you with solution 1, but re: solution 2, while this is maddening to find, there is actually a pretty simple solution.
First, you need to register with chart studio online and generate your api key. For whatever reason, to generate your api key you need to view your "settings." (see here: https://chart-studio.plotly.com/settings/api)
Once you've got your api key, you can run the following code from R and it will upload your plotly chart to your profile.
#first we register to upload to plotly
key <- readLines("path/to/your/api/key")
Sys.setenv("plotly_username"="<your username>")
Sys.setenv("plotly_api_key"=key)
#now we post to plolty
plotly_POST(
x = last_plot(),
file = "<whatever you want to name your plot>",
fileopt = "overwrite",
sharing = c("public"),
world_readable=TRUE
)
#note that evidently, plotly_POST is depreciated, though it worked for me as of 11/2020
#use instead the call below, with the same arguments
api_create(
x = last_plot(),
file = "<whatever you want to name your plot>",
fileopt = "overwrite",
sharing = c("public"),
world_readable=TRUE
)
I am seeking a way to automate PDF form filling in R. I cannot find a package written to do this. Is there an option out there?
Alternative solutions I can think of:
Using R to overlay a PDF containing text onto an blank PDF template.
Using R to generate an FDF file that can be read by some other software or code in a different language.
All of these things seem doable in Python. However, my organization leans strongly towards R, and in the past has relied upon software devs to write C# to fill out the forms. I'm hoping to use R to skip over this step.
Thanks!
staplr package now supports this with get_fields and set_fields functions. Note that for this to work pdftk
server must be installed and in your path
get_fields returns a list of fields and their types from a pdf that you can modify
set_fields allows you to fill form according to your modifications. See below code for an example
pdfFile = system.file('testForm.pdf',package = 'staplr')
fields = get_fields(pdfFile)
# You'll get a list of fields that the pdf contains
# along with some additional information about the fields.
# You make modifications in any of the fields by
fields$TextField1$value = 'this is text'
# and apply the changes you have made in a new file
set_fields(pdfFile, 'newFile.pdf', fields)
Note: Currently github version of staplr has fixes that are yet to make into CRAN that affect staplr's ability to write in non-english alphabets. For best experience you may want to install it by doing
devtools::install_github('pridiltal/staplr')
I'm trying to capture a multi-plot pdf from a function. In R, this gives me a three page PDF:
pdf(file='test.pdf', onefile=TRUE)
lapply(1:3, 'plot')
dev.off()
Using OpenCPU:
$ curl http://localhost:6977/ocpu/library/base/R/lapply -H 'Content-Type: application/json' -d '{"X":[1,2,3], "FUN":"plot"}'
/ocpu/tmp/x0dc3dad0/R/.val
/ocpu/tmp/x0dc3dad0/graphics/1
/ocpu/tmp/x0dc3dad0/graphics/2
/ocpu/tmp/x0dc3dad0/graphics/3
/ocpu/tmp/x0dc3dad0/stdout
/ocpu/tmp/x0dc3dad0/source
/ocpu/tmp/x0dc3dad0/console
/ocpu/tmp/x0dc3dad0/info
I can get any of the individual pages as a single-page PDF file, but not as one combined file.
Two possible work-arounds, not without their share of problems:
Use par(mfrow), layout(), or a similar mechanism, though this will create a monster image in the end (I'm dealing with more than three images in my code).
Use tempfile, create an Rmd file on-the-fly, return the filename in the session (have not tested this yet), and use OpenCPU's processing of Rmd files. Unfortunately, this now uses LaTeX's geometries and page numbering (workarounds exist for this).
Are there other ways to do this?
Good question. OpenCPU captures graphics using evaluate which stores each graphic individually. The API itself doesn't support combining multiple graphics within a single file. I would personally do this sort of PDF post processing in the application layer (i.e. with non-R tools), but perhaps it would be useful to support this in the API.
Some suggestions:
Any file that your R function/script saves to the working directory (i.e. getwd()) will also become available through the API. So one thing you could do is in your R code manually create your combined pdf file and save it to the working directory and then download it through opencpu.
Graphics are actually recordedPlot objects, and besides png, pdf and svg, you can also retrieve the graphic as rds or rda. So you could write an R function that downloads the recordedPlot object from the API and then prints it. Not sure if that would be helpful in your use case.
I'm trying to build a webpage displaying a few graphs. I want to use R to build the graphs, and I want these graphs to automatically update themselves periodically. For example, a webpage showing a graph of the stock price of a particular company over time, which refreshes every day with new data.
what is the best way to approach this? Using Rook to run the R-scripts? can I use it along Markdown, for example, to make the html webpage? Or do you suggest something else?
You can make your plots in a R file and write your webpage in markdown in which you call your R objects and plots. Alternatively you can also run the R code directly in the markdown file. With the knit2html function of the knitr package you can create the html page with the desired output. You can find basic examples on the knitr webpage.
You can schedule these file(s) on your own computer or on a server to update the data of the html output every day. If you have a machine that runs on Windows you can use the Windows Task Manager to run the batch file.
EDIT:
Here you can find a worked out example.
I have a script that makes barplots, and opens a new window when 6 barplots have been written to the screen and keeps opening new graphic devices whenever necessary.
Depending on the input, this leaves me with a potential large number of openened windows (graphic devices) which I would like to write to a single PDF file.
Considering my Perl background, I decided to iterate over the different graphics devices, printing them out one by one. I would like to keep appending to a single PDF file, but I do not know how to do this, or if this is even possible. I would like to avoid looping in R. :)
The code I use:
for (i in 1:length(dev.list())
{
dev.set(which = dev.list()[i]
dev.copy2pdf(device = quartz, file = "/Users/Tim/Desktop/R/Filename.pdf")
}
However, this is not working as it will overwrite the file each time. Now is there an append function in R, like there is in Perl. Which allows me to keep adding pages to the existing pdf file?
Or is there a way to contain the information in a graphic window to a object, and keep adding new graphic devices to this object and finally print the whole thing to a file?
Other possible solutions I thought about:
writing different pdf files, combining them after creation (perhaps even possible in R, with the right libraries installed?)
copying the information in all different windows to one big graphic device and then print this to a pdf file.
Quick comments:
use the onefile=TRUE argument which gets passed through to pdf(), see the help pages for dev.copypdf and pdf
as a general rule, you may find it easier to open the devices directly; again see help(pdf)
So in sum, add onefile=TRUE to you call and you should be fine but consider using pdf() directly.
To further elaborate on the possibility to append to a pdf. Although, multiples graphs can be put easaly into one file it turns out that it is impossiple or at least not simple to really append a pdf once finished by dev.off() - see here.
I generate many separate pages and then join them with something like system('pdfjam pages.pdf -o output.pdf' )*