I am trying to align the annotation provided by the achartengine according to a given condition but it doesn't seem to have any effect on the annotation's alignment. The alignment that takes affect is always the one that is provided in the first IF condition. Could anyone please point out the problem? Below is my code
int xaxis = 1;
for(int yaxis = 0; yaxis < scaleData.length; yaxis++)
{
factorsSeries.addAnnotation(annotationDate, xaxis,
scaleData[yaxis]+0.2);
if(xaxis == 1)
{
r.setAnnotationsTextAlign(Align.RIGHT);
Toast.makeText(Graphs_MulipleDatesAllinOne.this,
"setAnnotationsTextAlign(Align.RIGHT)",
Toast.LENGTH_SHORT).show();
}
else if(xaxis == 6)
{
r.setAnnotationsTextAlign(Align.LEFT);
Toast.makeText(Graphs_MulipleDatesAllinOne.this,
"setAnnotationsTextAlign(Align.LEFT)",
Toast.LENGTH_SHORT).show();
}
else
{
r.setAnnotationsTextAlign(Align.CENTER);
Toast.makeText(Graphs_MulipleDatesAllinOne.this,
"setAnnotationsTextAlign(Align.CENTER)",
Toast.LENGTH_SHORT).show();
}
xaxis++;
}
This is because xaxis in your code is always 1. Note that you are iterating on yaxis and the if conditions are on xaxis.
Related
I want to change the dynamic size of children according to its array count.
It is a way same like GridLayoutManger in android java.
What I did in android(java)
GridLayoutManager mng_layout = new GridLayoutManager(this, 4/*In my case 4*/);
mng_layout.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
#Override
public int getSpanSize(int position)
{
int mod = position % 6;
if (fullSizeGrid(position))
return 4; //one grid take space of four grid
else if (position == 0 || position == 1)
return 2;
else if (position < 6)
return 1;
else if (position<18)
{
return method1(mod);
}
else if (position>18)
{
return method2(position);
}
else
return 1;
}
});
By this I can change any grid size dynamically , I have my own formula for my layout.
So Is there any way to change size of any grid in Gridview Flutter?
Please Don't suggest staggered GridView it is not for me.
GridView does not support dynamic span, you can use spannable_grid
you can wrap you grid inside container and set size of container using height and width
See Image. The £12,845.63 is 1st columns label. I've tried running below code on a blank, fresh chart, with all default settings (white background too) it does the same thing.
I'm populating chart like this:
private void InitializeData()
{
chart1.Series.Clear();
double i = 0;
double spacing = 0.1;
foreach (DataRow rows in DailyBarChartT.Rows)
{
Series series = chart1.Series.Add(rows[0].ToString());
series.Points.AddXY(i, rows[1]);
series.IsValueShownAsLabel = true;
series.LabelFormat = "C";
series.LabelForeColor = Color.White;
i = i + spacing;
}
chart1.Update();
}
I'm guessing the number doesn't fit above the blue bar? how could I fix this?
I've tried setting label margins to 0 and a few other things.
EDIT:
setting my "spacing" variable to 0, sets the label to correct position.
How can I have it in a correct position with spacing?
You create a new series for every value, which is not how you are supposed to do it. The spacing works properly if you make one single series for all values.
Quick sample code (works on default chart):
string[] values =
{
"12845.63", "1174.89",
"344.04", "180.83",
"82.50", "55.00"
};
chart1.ChartAreas[0].BackColor = Color.Black;
chart1.Series.Clear();
Series series = new Series();
series.IsValueShownAsLabel = true;
series.LabelFormat = "C";
series.LabelForeColor = Color.White;
foreach (var value in values)
{
var pointIndex = series.Points.AddY(value);
series.Points[pointIndex].AxisLabel = "Custom label for each value here";
}
chart1.Series.Add(series);
Attempting to get the user's height in Unity using the xbox kinect.
Below is my code and I cannot get the height.
This uses the KinectV2 interface.
// get User's height by KinectV2 and unity3D `enter code here`
float GetUserHeightByLeft(long userid)
{`enter code here`
float uheight=0.0f;
int[] joints = new int[9];
int head = (int)KinectInterop.JointType.Head;
joints[0] = head;
joints[1] = (int)KinectInterop.JointType.Neck;
int shoudlderCenter = (int)KinectInterop.JointType.SpineShoulder;
joints[2] = shoudlderCenter;
joints[3] = (int)KinectInterop.JointType.SpineMid;
joints[4] = (int)KinectInterop.JointType.SpineBase;
joints[5] = (int)KinectInterop.JointType.HipLeft;
joints[6] = (int)KinectInterop.JointType.KneeLeft;
joints[7] = (int)KinectInterop.JointType.AnkleLeft;
joints[8] = (int)KinectInterop.JointType.FootLeft;
int trackedcount = 0;
for (int i = 0; i < joints.Length; ++i)
{
if (KinectManager.Instance.IsJointTracked(userid, joints[i]))
{
++trackedcount;
}
}
//if all joints that I need have been tracked ,compute user's height
if (trackedcount == joints.Length)
{
for (int i = 0; i < joints.Length-1;++i)
{
if (KinectManager.Instance.IsJointTracked(userid, joints[i]))
{
Vector3 start= 100*KinectManager.Instance.GetJointKinectPosition(userid,joints[i]);
Vector3 end = 100*KinectManager.Instance.GetJointKinectPosition(userid,joints[i+1]);
uheight += Mathf.Abs(Vector3.Magnitude(end-start));
}
}
//some height kinectV2 can't get so I add it
uheight += 8;
}
return uheight;
}
Given your code I do see a few issues
The summation to get the total height requires all joints to be tracked at that time.
Why do you need all joints to be tracked for the height to be tracked? You should only need the head and the feet
You double check if each joint is tracked
using the left for every foot/knee/hip joint is going to give you math errors. They are offset in one direction (because our feet aren't in the center of our body)
I would track both right and left foot/knee/hip and then find the center of the two on the x axis.
If you're using the magnitude of two vectors and one knee is far in front of your hip it's going to give it an inflated value.
I would only use the y positions of your kinect joints to calculate the height.
how can I
walk cycle for details subreport(2 textboxes) for make a second textbox strictly under the first but right allign.
Or how else would be a way to indicate that the second textbox has been located under the first but right(allign right)
example
good name
price
another good
name
price
`public void Goods_BeforePrint()
{
Section sec;
sec = rpt.Sections["Goods"];
for(int y= 0; y <= sec.Controls.Count - 1;y++)
{
if( y%2> 0)
{
sec.Controls[y].Height += sec.Controls[y-1].Height;
((TextBox)sec.Controls[y]).Text = System.Convert.ToString(sec.Controls.Count);
}
}`
For now I have 0.25 value of Height in every row.
Problem not in allign but in size of rows, because here not have iteration what I expect and each rows is same size = size of first row.
Your question is not very clear; however on the basis of the expected output, I would suggest you to handle the Format event of the SubReport's detail section and access the control which you want to change the alignment for. So if you want it to appear left aligned twice and right aligned for every third row, the following code should work:
int counter = 0;
private void detail_Format(object sender, EventArgs e)
{
counter++;
if (counter % 3 == 0)
{
this.txtCountry1.Alignment = GrapeCity.ActiveReports.Document.Section.TextAlignment.Right;
}
else
{
this.txtCountry1.Alignment = GrapeCity.ActiveReports.Document.Section.TextAlignment.Left;
}
}
Here is a screenshot from my machine showing a basic example with similar implementation.
I have a function which returns mouse event positions.
// returns the xy point where the mouse event was occured.
function getXY(ev){
var xypoint = new Point();
if (ev.layerX || ev.layerY) { // Firefox
xypoint.x = ev.layerX;
xypoint.y = ev.layerY;
} else if (ev.offsetX || ev.offsetX == 0) { // Opera
xypoint.x = ev.offsetX;
xypoint.y = ev.offsetY;
}
return xypoint;
}
I am capturing mouse events to perform drawings on html5 canvas. Sometimes I am getting -ve values for xypoint. When I debug the application using firebug I am getting really strange behavior. for example if I put my break point at the 4th line of this function with condition (xypoint.x<0 || xypoint.y<0), it stops at the break point and I can see that layer.x, layer.y was positive and correct. But xypoint.x or xypoint.y is negative. If I reassign the values using firbug console I am getting correct values in xypoint. Can anyone explain me what is happening.
The above works fine if I move mouse with normal speed. If I am moving mouse at very rapid speed I am getting this behavior.
Thanks
Handling mouse position was an absolute pain with Canvas. You have to make a ton of adjustments. I use this, which has a few minor errors, but works even with the drag-and-drop divs I use in my app:
getCurrentMousePosition = function(e) {
// Take mouse position, subtract element position to get relative position.
if (document.layers) {
xMousePos = e.pageX;
yMousePos = e.pageY;
xMousePosMax = window.innerWidth+window.pageXOffset;
yMousePosMax = window.innerHeight+window.pageYOffset;
} else if (document.all) {
xMousePos = window.event.x+document.body.scrollLeft;
yMousePos = window.event.y+document.body.scrollTop;
xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
yMousePosMax = document.body.clientHeight+document.body.scrollTop;
} else if (document.getElementById) {
xMousePos = e.pageX;
yMousePos = e.pageY;
xMousePosMax = window.innerWidth+window.pageXOffset;
yMousePosMax = window.innerHeight+window.pageYOffset;
}
elPos = getElementPosition(document.getElementById("cvs"));
xMousePos = xMousePos - elPos.left;
yMousePos = yMousePos - elPos.top;
return {x: xMousePos, y: yMousePos};
}
getElementPosition = function(el) {
var _x = 0,
_y = 0;
if(document.body.style.marginLeft == "" && document.body.style.marginRight == "" ) {
_x += (window.innerWidth - document.body.offsetWidth) / 2;
}
if(el.offsetParent != null) while(1) {
_x += el.offsetLeft;
_y += el.offsetTop;
if(!el.offsetParent) break;
el = el.offsetParent;
} else if(el.x || el.y) {
if(el.x) _x = el.x;
if(el.y) _y = el.y;
}
return { top: _y, left: _x };
}
Moral of the story? You need to figure in the offset of the canvas to have proper results. You're capturing the XY from the event, which has an offset that's not being captured in relation to the window's XY. Make sense?