I'm trying to format nicely this Combo Chart, so that the vertical axes on both sides share the same gridlines. However, the second Y-axis (right side) isn't formatted as viewWindowMode: 'pretty' automatically. The result is that the values start from 0 instead of 10,000.
By setting the min and max values:
viewWindowMode: 'explicit',
viewWindow: {
max: 14000,
min: 10000}
the outcome is nice, but the line touches top and bottom of the chart. So I tried giving it some padding by setting max: 15000and min: 9000, but then the number of gridlines increases and gridlines: {count: 6}doesn't seem to have an effect.
Is there a way to force viewWindowMode: 'pretty' on the second vertical axis?
The 'pretty' mode for an axis is going to result in unpredictable values, depending on where your data falls within the gridlines. So if you wish to coordinate the gridlines for both the left and right axes, you need to be more explicit about the viewWindow min and max for both, and the number of gridlines, or explicit ticks. You could do it like this: http://jsfiddle.net/dlaliberte/pyAz5/316/ Which uses these options:
var options = {
series: {
1: { targetAxisIndex: 1 }
},
vAxes: {
0: {
viewWindow: { min: 0, max: 1500 }
},
1: {
viewWindow: { min: 0, max: 1500 }
}
}
};
The gridlines.count option is not a guarantee in all cases because it could conflict with the heuristics for nice tick values.
Related
My formula is as follows:
=ARRAYFORMULA(IFS(AND(H2:H >= -B39, H2:H <= B40), 100, H2:H > B37, 0))
However this line keeps throwing the error:
IFS has mismatched range sizes. Expected row count: 1. column count: 1. Actual row count: 1000, column count: 1.
Any idea how to fix this?
I have similar formulaes like this one that works:
=ARRAYFORMULA(IFS(F2:F <= 0, 100, F2:F >= B19, 0, true, (B19 - F2:F) / B19 * 100))
Not sure what I'm doing so differently with the first formula that would cause the issue.
AND is not supported under ARRAYFORMULA
=ARRAYFORMULA(IFS((H2:H >= -B39)*(H2:H <= B40), 100, H2:H > B37, 0))
and IFS is in some cases not suited for ARRAYFORMULA as well
try:
=ARRAYFORMULA(IF((H2:H >= -B39)*(H2:H <= B40), 100, IF( H2:H > B37, 0, )))
Can someone explain what the percent parameter is for on the min_mas_grey() operator in Halcon?
min_max_gray(Regions, Image : : Percent : Min, Max, Range)
The documentation for this operator can be found here:
https://www.mvtec.com/doc/halcon/2005/en/min_max_gray.html
To elaborate a little on the explanation if you are having trouble following it:
calculates the number of pixels Percent corresponding to the area of
the input image. Then it goes inwards on both sides of the histogram
by this number of pixels and determines the smallest and the largest
gray value
Essentially, if percent is 0 you will obtain min/max as you'd expect however if you give a percentage it will subtract this percentage (as a pixel value) from either side of the histogram and give these values as min and max instead. If percent is 50 that then means min and max are the same and signify the median.
Let's look at a simplified example:
image in an image with 10 pixels who have the following values:
[0, 0, 1, 2, 3, 3, 3, 3, 4, 5]
The histogram would be like this:
0: 2
1: 1
2: 1
3: 4
4: 1
5: 1
If percent is 0 then min = 0 and max = 5.
Percent 10 would mean you take one pixel away at the edges of the histogram, thus min = 0 and max = 4...
percent 20, equals 2 pixels and thus min = 1 max = 3
percent 30, equals 3 pixels thus min = 2, max = 3
percent 50, min=max=3 which is the median
First of all, I realize there are existing questions about converting an RGB image to an HSV image out there; I used one of those questions to help me write my code. However, I am getting values for HSV that don't make sense to me.
What I know about HSV I have gotten from this website. From this colorpicker, I have inferred that H is a number ranging from 0-360 degrees, S is a number ranging from 0-100%, and V is a number ranging from 0-100%. Therefore, I had assumed that my code (as follows) would return an H value between 0 and 360, and S/V values between 0 and 100. However, this is not the case.
I plugged my program's output into the above color picker, which all S/V values down to 100 when they exceeded 100. As you can see, the output is close to what it should be, but is not accurate. I feel like this is because I am interpreting the HSV values incorrectly.
For contex, I am going to establish a range for each color on the cube and from there look at the other faces and fill out the current setup of the cube in another program I have.
My code:
void get_color(Mat img, int x_offset, int y_offset)
{
Rect outline(x_offset - 2, y_offset - 2, 5, 5);
rectangle(img, outline, Scalar(255, 0, 0), 2);
Rect sample(x_offset, y_offset, 1, 1);
Mat rgb_image = img(sample);
Mat hsv_image;
cvtColor(rgb_image, hsv_image, CV_BGR2HSV);
Vec3b hsv = hsv_image.at<Vec3b>(0, 0);
int hue = hsv.val[0];
int saturation = hsv.val[1];
int value = hsv.val[2];
printf("H: %d, S: %d, V: %d \n", hue, saturation, value);
}
Output of the program:
H: 21, S: 120, V: 191 // top left cubie
H: 1, S: 180, V: 159 // top center cubie
H: 150, S: 2, V: 142 // top right cubie
H: 86, S: 11, V: 159 // middle left cubie
H: 75, S: 12, V: 133 // middle center cubie
H: 5, S: 182, V: 233 // middle right cubie
H: 68, S: 7, V: 156 // bottom left cubie
H: 25, S: 102, V: 137 // bottom center cubie
H: 107, S: 155, V: 69 // bottom right cubie
Starting image (pixel being extracted # center of each blue square):
Resulting colors (as the above color picker gave):
As you can see, the red and white is fairly accurate, but the orange and yellow are not correct and the blue is blatantly wrong; it is impossible for the pixel I looked at to actually be that color. What am I doing wrong? Any help would be greatly appreciated.
OpenCV has a funny way of representing its colors.
Hue - Represented as a number from 0-179 instead of 0-360. Therefore, multiply the H value by two before plugging it into a traditional color picker.
Saturation/Value - Represented as a number from 0-255. To get a percentage, divide given answer by 255 and multiply by 100 to get a percentage.
Everything works much more sensibly now. See this website for more details on OpenCV and HSV.
I was working on a bugfix with Google visualizations for a combo (column/line) chart when one of the axes went strange and started repeating numbers ( ie: 1, 1, 2, 2 instead of 1, 2, 3, 4). Please see the image below
(source: rackcdn.com)
Here are the chart option settings:
// Instantiate and draw our chart, passing in some options.
var frequency_by_day_options = {
vAxes: [
{format:'#,###', title:"Call Volume"},
{format: '#%', title:'Missed Call Rate',
viewWindow:{
max:1,
}}
],
legend: {position: 'none'},
chartArea: { height:'60%', width:'60%'},
width: 800,
height: 350,
backgroundColor: 'transparent',
bar: { groupWidth: '90%'},
isStacked: true,
seriesType: 'bars',
series: {0: {type:'bar', targetAxisIndex:0}, 1: {type:'line', targetAxisIndex:1},},
colors: ['blue', 'green'],
animation:{
duration: 1000,
easing: 'out',},
};
I have no idea what's going on here. Even when I comment out all of the vAxis options I still observe this behavior. Any ideas on what i'm doing wrong? This is driving me nuts :)
I was facing same issue when we have less number of boxes (let say 1 or 2). I resolved it with maxValue option.
Just add maxValue = 4 option in your vaxis. It will add 5 (0 to 4) gridlines at all times. If your maxValue is more that 4, it will adjust automatically.
Mine is working fine with options (title : 'No of boxes', format : '#', minValue:0, maxValue :4). minValue = 0 will not allow negatives as its no of boxes.
I am going to guess that the left-side vAxis is not 4, but actually 2. The 5 labels are 0, 0.5, 1, 1.5, 2.
Since you have format set as "#,###" it will not show decimals. If you change it to "#,###.#" then it will show 0, 0.5, 1, 1.5, 2.
There are a dozen ways to solve it, but the easiest may be to make sure that your axis values are only whole number values with a javascript function like this:
// Take the Max/Min of all data values in all graphs
var totalMax = 3;
var totalMin = -1;
// Figure out the largest number (positive or negative)
var biggestNumber = Math.max(Math.abs(totalMax),Math.abs(totalMin));
// Round to an exponent of 10 appropriate for the biggest number
var roundingExp = Math.floor(Math.log(biggestNumber) / Math.LN10);
var roundingDec = Math.pow(10,roundingExp);
// Round your max and min to the nearest exponent of 10
var newMax = Math.ceil(totalMax/roundingDec)*roundingDec;
var newMin = Math.floor(totalMin/roundingDec)*roundingDec;
// Determine the range of your values
var range = newMax - newMin;
// Calculate the best factor for number of gridlines (2-5 gridlines)
// If the range of numbers divided by 2 or 5 is a whole number, use it
for (var i = 2; i <= 5; ++i) {
if ( Math.round(range/i) = range/i) {
var gridlines = i
}
}
I have a question about the following demo - http://raphaeljs.com/hand.html.
Here is code from the sample...
var r = Raphael("holder", 640, 480), angle = 0;
while (angle < 360) {
var color = Raphael.getColor();
(function(t, c) {
r.circle(320, 450, 20).attr({
stroke : c,
fill : c,
transform : t,
"fill-opacity" : .4
}).click(function() {
s.animate({
transform : t,
stroke : c
}, 2000, "bounce");
}).mouseover(function() {
this.animate({
"fill-opacity" : .75
}, 500);
}).mouseout(function() {
this.animate({
"fill-opacity" : .4
}, 500);
});
})("r" + angle + " 320 240", color);
angle += 30;
}
Raphael.getColor.reset();
var s = r.set();
s.push(r.path("M320,240c-50,100,50,110,0,190").attr({
fill : "none",
"stroke-width" : 2
}));
s.push(r.circle(320, 450, 20).attr({
fill : "none",
"stroke-width" : 2
}));
s.push(r.circle(320, 240, 5).attr({
fill : "none",
"stroke-width" : 10
}));
s.attr({
stroke : Raphael.getColor()
});
The question I have is about the following line of code...
("r" + angle + " 320 240", color);
In the anonymous function the circle is initially drawn at 320, 450 with a radius of 20. Then a transform is applied, for example ("r30 320 240") when the angle is 30.
How does this transform work? The way I read this transform is to rotate the circle 30 degrees around 320,450 , then move 320 horizontally (to the right) and 240 vertically down.
But i'm obviously reading this transform wrong because this is not what is happening.
What am i missing?
Thanks
The transform "r30 320 240" sets the rotation of the object about the point (320,240) by 30 degrees. It does not add to the rotation. It overrides any previous transformations.
If you look at this example:
http://jsfiddle.net/jZyyy/1/
You can see that I am setting the rotation of the circle about the point (0,0). If you consider the point (0,0) to be the centre of a clock, then the circle begins at 3 o'clock. If I use the transform "r90 0 0" the circle will be rotated from 3 o'clock to 6 o'clock. If I then later set the transform to be "r30 0 0" the circle will be at 4 o'clock, rotated 30 degrees from the original 3 o'clock position about the point (0,0).