How can I format the axis/tick labels labels ?
What if I need to change the font-style and font-size ?
I referred to the following question but was unsuccessful:
Tickformatter not performing as expected in latest version of Flot
Please Help !!!
Thnx.
If you're using 0.8, just override .flot-tick-label in your stylesheet. You can get more specific via the flot-[x|y]-axis classes.
See the customizing the axes section of the docs for more info.
I used the following:
CSS File/SCSS File
#graph_label .tickLabel{
font-size: 50%;
}
Index.html or place where you are plotting the graph area
$.plot($("graph_label"), [dataArrayReference], options);
PS: I am using Flot Version prior to 0.8.1 so I dont have any idea about how latest version would work
For my case I've fixed issue this way:
var _chart = $.plot($(element).find('[flot-placeholder]'), dataset, chartOptions);
$(element).find('.tickLabel').css('color', 'blue'); // fix
Related
I'm using Godot 4 beta. I want to skip to a specific frame in an AnimationPlayer, but I'm getting:
Invalid set index 'current_animation_position' (on base: 'AnimationPlayer') with value of type 'float'.
Here's the related documentation: https://docs.godotengine.org/en/latest/classes/class_animationplayer.html#class-animationplayer-property-current-animation-position
I currently have one AnimationPlayer in my scene, named 'animation', with an animation named 'Animation' with "Autoplay on Load". The animation 'Animation' has a length of 4.x seconds.
Here's my code attached to the scene:
func _process(_delta):
if Input.is_action_just_released("skip_intro"):
if animation_player.current_animation_position < 1.3:
animation_player.current_animation_position = 1.3
else:
skip_intro()
Update (2)
I know I can use animation_player.advance(), but it adds to the relative time. I'm looking for a way to go to a fixed frame, not a relative frame.
As you can read in the documentation you linked current_animation_position only has a getter. It is a read-only property.
If you want to go to an specific time you can use the seek method.
I found that I can use play() before advance() to go to an absolute frame. But I'd appreciate any other way to do it inliner.
animation_player.play("Animation")
animation_player.advance(1.3)
IMO it should be allowed to rewrite the current_animation_position property.
by using knitr::include_graphics with option out.height='50px' in a rmarkdown ioslides presentation the aspect ratio is not kept on my machine. Does anyone has an idea how to solve this problem?
Interestingly, this morning it worked. But not after I installed the
R packages ggsn, ggmap, plotKML. Later I removed them, but the problem remains.
I use: Ubuntu 16.04.4, R version 3.4.4, current rmarkdown
Minimal example is:
---
title: "Untitled"
author: "Me"
date: "May 24, 2018"
output: ioslides_presentation
---
```{r setup, include=FALSE}
knitr::opts_chunk$set(echo =T)
```
## R Markdown
setting out.height does NOT keep aspect ratio
```{r, out.height='50px', dpi=200}
knitr::include_graphics("rect_circ.png")
```
setting out.width keeps aspect ratio
```{r, out.width='50px', dpi=200}
knitr::include_graphics("rect_circ.png")
```
I guess you installed the png package by chance (it may be a dependency of the packages you mentioned). When png is available, include_graphics() will try to set the chunk option out.width to match your dpi setting. In your case, you set the out.height option, which leads to the problem of a distorted aspect ratio (the automatically calculated width is 96, and your manual height is 50).
If you have a desired figure size in the output, you may call
knitr::include_graphics("rect_circ.png", dpi = NA)
to avoid the automatic adjustment of out.width. If you have a desired DPI, you should leave out out.height, e.g.,
```{r}
knitr::include_graphics("rect_circ.png", dpi = 200)
``
Within in my ioslides_presentation I created a row of jpg-graphics. For this to look nice I needed to set the out.height option, so that the pictures build a rectangular block. Usually this worked:
```{r, out.height="200px",dpi=200}
maps=c("map_1.jpg","map_2.jpg","map_3.jpg")
knitr::include_graphics(maps)
```
But with the png package installed the aspect ratio of the pictures was not kept. Applying the above mentioned changes, the chunk which workes looks like this:
```{r, out.height="200px"}
maps=c("map_anthroms_full.jpg","map_anthroms_rangelands.jpg")
knitr::include_graphics(maps, dpi=NA)
```
Note: Setting a resolution within include_graphics() or ```{r, ...} produces the same error.
so here's the thing.
I've got plenty of persisted "Snapshots" containing a java.sql.Timestamp and (for the sake of simplicity) an int as data.
I have a JSF page containing a primefaces 3.4.1 <p:lineChart> and behind that a ManagedBean that contains the model for the chart.
Let's say I then select a time range and fetch all the Snapshots in between that range.
and populate the data model for the chart with all the Timestamps (x-axis) and all the integers (y-axis).
So what i do while populating is:
data = new HashMap<Object, Number>();
List<Snapshot> allSnapshots = persistenceService.getAllSnapshots();
for(int i = 0; i < allSnapshots.size(); i++) {
Snapshot s = allSnapshots.get(i);
data.put(new Date(s.getTimestamp().getTime()), s.getData());
}
chartModel.getSeries().get(0).setData(data);
(Note: in the example code I just fetch all Snapshots, as I quickly just generated a hundred or so).
I set up the chart like this:
<p:lineChart id="chart" value="#{backingBean.chartModel}" xaxisAngle="-90">
<f:convertDateTime pattern="HH:mm:ss"/>
</p:lineChart>
It works ok but when the model contains a hundred data points, the xaxis is just overcrowded with all the tickmarks.
What I then did is to use the primefaces' option to use a jqplot extender function.
So I just add extender="extend" as attribute for the chart, where extend is the following js function :
function extend() {
this.cfg.axes = {
xaxis: {
renderer: $.jqplot.DateAxisRenderer,
rendererOptions: { tickRenderer: $.jqplot.CanvasAxisTickRenderer },
tickOptions: {
showGridline: true,
formatString: '%H:%M',
angle: -90
}
}
}
}
This is the current version of it..
After hours of reading and trial and error, I still cannot get it right, as the following things are just never right:
The tick marks never get rendered as the Date never gets converted.
At the moment this is just ignored and the formatString itself is
displayed...
Additional tick marks are created left and right of the actual data,
I dont want that.
When I only give autoscale: true as option for the jqplot extender,
I would expect just the spacing between the marks turn ok. But what
then happens is, that the spacing is cool but the original date
labels turn into just bare numbers starting from 0 to the amount of data available.. !?
I am getting a little tired from dealing with this.....maybe I am doing something fundamentally wrong. Otherwise I have no idea why this is so complicated..
Thanks for any advice!
Cheers
Chris
EDIT:
Ok thanks to perissf, I checked this one : https://stackoverflow.com/a/14287971/870122
With the suggested extender I get the following output :
http://www.abload.de/img/clipboard01y6sgj.png
(sorry I cannot post the image directly due to new user restrictions :-/ )
As you can see the tick marks are rendered correctly as HH:MM, thats very nice.
But as you also can see another quite weird problem occurs:
The given time range of the snapshots is
Start time: 2013-01-28 13:01:25.415
End time: 2013-01-28 13:14:32.145
I collected these as UTC timestamps with System.currentTimeMillis() while the JVM is set to UTC in the glassfish config.
As you notice, the datapoints in the plot are shifted one hour, they start at 14:01, which looks like the values have been auto-converted to my current timezone which is UTC+1. But the leftmost xaxis tick is placed at around the original UTC value at 13:00.
I collect the timestamps UTC as I dont know in which actual timezone the application will be running, but I'd like to display the "translated" time value. So the auto shift to my timezone is a nice feature, but the xaxis scaling is actually not nice and weird.
Any suggestions how I get rid of that ?
Cheers
Chris
EDIT2:
Ok while debugging the rendered page with Firebug I stumbled upon the jqplot internal variables in the plot object, which seem to contain the min and max values for the xaxis.
Min is set to the original min UTC value which is around 13:00, and max is set to the shifted UTC+1 value around 14:15.
Somehow the min value is not shifted accordingly to the automatic timezone adjustments.
All other values, that is dataBounds, data itself and so on, are all shifted nicely by one hour.
I opened a issue at Bitbucket jqplot issue tracker
Let's see.
Bye
Chris
i finally debugged the jqplot renderer and found some lines of code that cause this behaviour.
For anyone interested, please find the bugfix in the comment section here:
Bitbucket issue tracker
Thanks for any help
I'm very interested in this fix but the issues on BitBucket are in a restricted area so I cannot access it. So I had myself to try to fix this AxisDateRenderer and fortunately I did :)
So the Primefaces (6.0) chart uses an old version of the JQPlot library. A bug in this version sets the minimum date axis bound being not the first value exactly, but a time older according to the locale time zone of the user browser. For example, if the first value is at 12:00 and your GMT is GMT+1, then the date axis bound minimum will be at 11:00 instead of 12:00 !
The minVale
The following line (in createTicks function) should bed replaced (note the code is written minified below)
ad = ad.getTime() + ad.getUtcOffset();
By the next line:
ad = Math.floor((ad.getTime() - ad.getUtcOffset())/r) * r + ad.getUtcOffset();
Non minified line to replace:
min = min.getTime() + min.getUtcOffset();
With:
min = Math.floor((min.getTime() - min.getUtcOffset())/tempti) * tempti + min.getUtcOffset();
Note that I have tried to update the chart.js of Primefaces to an earlier version , but the chart do not work anymore. I will wait for the next update of Primefaces hoping that a newer version is used. I also don't know which version of JQPlot is used in Primefaces 6.0
Trying to get these 2 raphael elements to both change color when hovered over one or the other. Here is the code I have. Any help would be appreciated.
var loge_1 = rsr.set();
loge_1a = rsr.rect(235.457, 287.645, 32.523, 45.486),
loge_1b = rsr.rect(235.139, 277.626, 32.933, 6.701);
loge_1.push(loge_1a,loge_1b);
loge_1.attr(logeFill);
I assume you got the code from ReadySetRaphael .... no doubt they have a very good algorithm for Raphael conversion ... try some large SVG files sometime and they will give you a good result .... anyways try this ...
loge_1.mouseover(function(){
loge_1.attr({'fill':'your Desired Color'});
}
loge_1.mouseout(function(){
loge_1.attr({'fill':'original color'});
}
this should change the color of both your rects .... Hope it helps.
Well after searching I didn't find much on the subject. So I have read up on svg elements and changed my "rect" to "path". Here is the W3C svg documentation
And here is the jsfiddle with "path"
To find my rectangles paths I just opened the svg file in Adobe AI. Then made sure my documents units was set to pixels. From there I opened my info window and just copied the my anchor points of my rectangles x & y coordinates into my "path" and presto I have 2 shapes acting as one.
So I load a color .png file that has been taken with an iphone using cvLoadImage. And after it's been loaded, when I immediately display it in my X11 terminal, the image is definitely darker than the original png file.
I currently use this to load the image:
IplImage *img3 = cvLoadImage( "bright.png", 1);
For the second parameter I have tried all of the following:
CV_LOAD_IMAGE_UNCHANGED
CV_LOAD_IMAGE_GRAYSCALE
CV_LOAD_IMAGE_COLOR
CV_LOAD_IMAGE_ANYDEPTH
CV_LOAD_IMAGE_ANYCOLOR
but none of these have worked. Grayscale definitely made the image grayscale. But as suggested from http://www.cognotics.com/opencv/docs/1.0/ref/opencvref_highgui.htm, even using CV_LOAD_IMAGE_ANYDEPTH | CV_LOAD_IMAGE_ANYCOLOR to load the image as truthfully as possible resulted in a darker image being displayed in the terminal.
Does anyone have any ideas on how to get the original image to display properly?
Thanks a lot in advance.
Yes, OpenCV does not apply Gamma correction.
// from: http://gegl.org/
// value: 0.0-1.0
static inline qreal
linear_to_gamma_2_2 (qreal value){
if (value > 0.0030402477)
return 1.055 * pow (value, (1.0/2.4)) - 0.055;
return 12.92 * value;
}
// from: http://gegl.org/
static inline qreal
gamma_2_2_to_linear (qreal value){
if (value > 0.03928)
return pow ((value + 0.055) / 1.055, 2.4);
return value / 12.92;
}
It only happens when you load it in OpenCV? Opening with any other viewer doesn't show a difference?
I can't confirm this without a few tests but I believe the iPhone display gamma is 1.8 (source: http://www.colorwiki.com/wiki/Color_on_iPhone#The_iPhone.27s_Display). Your X11 monitor probably is adjusted for 2.2 (like the rest of the world).
If this theory holds, yes, images are going to appear darker on X11 than on the iPhone. You may change your monitor calibration or do some image processing to account for the difference.
Edit:
I believe OpenCV really does not apply gamma correction. My reference to this is here:
http://permalink.gmane.org/gmane.comp.lib.opencv.devel/837
You might want to implement it yourself or "correct" it with ImageMagick. This page instructs you on how to do so:
http://www.4p8.com/eric.brasseur/gamma.html
I usually load an image with:
cvLoadImage("file.png", CV_LOAD_IMAGE_UNCHANGED);
One interesting test you could do to detect if OpenCV is really messing with the image data, is simply creating another image with cvCreateImage(), then copy the data to this newly created image and save it to another file with cvLoadImage().
Maybe, it's just a display error. Of course, I would suggest you to update to the most recent version of OpenCV.