My need is to implement following graph
I know about stacked chart, but here there are axis points labels (In my need there is no any axes point labels), and this is from Y-axis.
I am confused how can I implement it.
Can you please help me? Any link will also be helpful.
Update :
I am trying a code snippet
<script type="text/javascript" language="javascript">
$(document).ready(function(){
var line1 = [14];
var line2 = [77];
var plot4 = $.jqplot('test2', [line1, line2], {
title: '1 Mobility Test Graph',
animate: !$.jqplot.use_excanvas,
stackSeries: true,
seriesDefaults: {
renderer: $.jqplot.BarRenderer,
rendererOptions:{barPadding : 0, barMargin : 5, barDirection: 'horizontal'},
pointLabels:{location : 'e', edgeTolerance : 0, hideZeros: true, show : true},
shadowAngle : 135,
lineWidth : 0,
showLine: true
},
axesDefaults : {
show : false,
tickOptions : {
show : false
}
},
axes: {
yaxis:{renderer:$.jqplot.CategoryAxisRenderer}
},
grid:{
borderWidth:0,
shadow:false
},
legend: {
renderer: $.jqplot.EnhancedLegendRenderer,
show:true,
rendererOptions:{
numberRows:1,
numberColumns: 3,
disableIEFading: false
},
location: 'n',
placement : 'outsideGrid',
marginTop: '5px',
showSwatch:false
}
});
$(".jqplot-xaxis-tick").hide();
$(".jqplot-yaxis-tick").hide();
});
</script>
But this doesn't give me any output. When I remove barDirection: 'horizontal' its working fine. Please help me, what is wrong...
Here I got jsfiddle , but it works for two graphs..... how can I make for one.
Are you after something like this? You have a single stacked horizontal bar there.
As per examples in doc with horizontal bar chart you must give the chart an array of series where each one has values as two values arrays ([x,y]) where x is value and y is series id.
Or another option would be to give the chart a single array of single value arrays, as shown here.
Related
Short Background
I'm working on a SceneManager which allows the creation of SceneNode objects. Each SceneNode contains information about position, scaling, and rotation. To make an object appear in the scene, it simply gets attached to a SceneNode and the transforms contained in the SceneNode are applied to it. For example, to get a camera to look at a sphere in the scene, we could write:
Camera cam = sceneManager.createCamera("MainCamera", Camera.ProjectionType.PERSPECTIVE);
Entity sphere = sceneManager.createEntity("Sphere", "sphere_mesh.obj");
SceneNode camNode = sceneManager.createSceneNode(cam.getname() + "Node");
SceneNode sphereNode = sceneManager.createSceneNode(sphere.getname() + "Node");
// turns camera node towards the sphere node as expected
camNode.lookAt(sphereNode);
The simplified example above should give the general idea, and would produce the expected result, i.e. I have no problems getting things to appear on screen and making the camera look at them.
The Problem
I want to make a SceneNode containing an Entity point towards another SceneNode containing another Entity, not the Camera, but it ends up pointing in the opposite direction I intended it to look at.
For example, if we have our target node at position [0, 0, -5] and some other observer node at position [0, 0, 5], we want object the observer node's forward vector to be [0, 0, -1], but instead it ends up as [0, 0, 1], looking away from the target.
I discovered this bug recently after attaching a Light to a SceneNode and telling it to lookAt the cube's SceneNode to illuminate it, but it did not get lit.
This pic shows the problem, where the center cube should be lit, but isn't.
The white sphere marks the position of the spot light, and it should be looking at the center cube, but it's not getting lit because it's actually looking in the opposite direction. In other words, I tried: lightNode.lookAt(cubeNode);
While debugging, I can see that the resulting rotation matrix looks like this:
s u f = side, up, forward; column-major matrix
[1 0 0]
[0 1 0]
[0 0 1] <-- wrong: looking down the +Z axis, towards viewer
Instead, it should look like this:
s u f
[1 0 0]
[0 1 0]
[0 0 -1] <-- good: looking down the -Z axis, into screen
(Yes, the underlying rendering system is OpenGL-based, which means that "front" is actually down the -Z axis.)
If I modify the code above to look at the negative of the actual location, i.e. lightNode.lookAt(cubeNode.getRelativePosition().mult(-1));, then it looks at the cube and lights it up, as shown below.
So, to make it look towards the "front", I had to tell it to look "back". I've been hunting this bug down for the last several days, even double-checking that the look-at matrix is being built correctly. Based on my references, it seems to be correct, but I've included it below anyway because it was a possible suspect at one point.
public static Matrix4 createLookAtMatrix(Vector4 eyePosition, Vector4 targetPosition, Vector4 upDirection) {
Vector4 f = targetPosition.sub(eyePosition).normalize();
Vector4 s = f.cross(upDirection).normalize();
Vector4 u = s.cross(f).normalize();
float[][] values = new float[][] {
{ s.x(), s.y(), s.z(), -s.dot(eyePosition) },
{ u.x(), u.y(), u.z(), -u.dot(eyePosition) },
{-f.x(), -f.y(), -f.z(), -f.dot(eyePosition) },
{ 0f , 0f , 0f , 1f }
};
return createFrom(values);
}
I'm currently out of ideas and would appreciate the any help leading to the capture and execution of this bug.
I really don't know if it could be related to an older question I posted several months ago or not, which is still unresolved, but it's included here just in case it turns out to be relevant.
I assume you created the look_at function to work with the camera. That's why it doesn't work with other objects. The cameras z axis is always point away from what you are looking at which is why you added the minus signs to the third row of the matrix I assume.
One way to solve it would be to have a createLookAtMatrix and createCameraLookAtMatrix. The ladder like the one you have now and the other without the minus signs on the third row.
Another way to do it would be to always have the camera under a "camera control" node in the scene graph. You would have the cameras local transformation always rotated 180 degrees in the y axis and then set the look at matrix to the parent node instead.
In any case, this should work for objects other than the camera:
public static Matrix4 createLookAtMatrixForObjects(Vector4 eyePosition, Vector4 targetPosition, Vector4 upDirection) {
Vector4 f = targetPosition.sub(eyePosition).normalize();
Vector4 s = f.cross(upDirection).normalize();
Vector4 u = s.cross(f).normalize();
float[][] values = new float[][] {
{ s.x(), s.y(), s.z(), -s.dot(eyePosition) },
{ u.x(), u.y(), u.z(), -u.dot(eyePosition) },
{ f.x(), f.y(), f.z(), -f.dot(eyePosition) },
{ 0f , 0f , 0f , 1f }
};
return createFrom(values);
}
I'm trying to get a javascript spinner to work on submitting a from. I'm using spin.js, and code that I found here as a starting point.
We have 2 options to trigger that java:
when the form is submitted #submit-form
when the button is clicked for the last time: button's unique class is .next-submit.
I'm not sure where I'm going wrong.
And the other thing that I don't understand is whether I need a div #spinner in the html of the page, or if that is generated dynamically.
<script src="http://www.purevisionmethod.com/js/spin.min.js"></script>
<script>
$(function() {
// Remember to use 'var'
var spinner_div = $('#spinner').get(0),
spinner,
opts = {
lines: 16, // The number of lines to draw
length: 23, // The length of each line
width: 5, // The line thickness
radius: 30, // The radius of the inner circle
corners: 100, // Corner roundness (0..1)
rotate: 0, // The rotation offset
direction: 1, // 1: clockwise, -1: counterclockwise
color: '#000', // #rgb or #rrggbb or array of colors
speed: 1, // Rounds per second
trail: 100, // Afterglow percentage
shadow: true, // Whether to render a shadow
hwaccel: true, // Whether to use hardware acceleration
className: 'spinner', // The CSS class to assign to the spinner
zIndex: 2e9, // The z-index (defaults to 2000000000)
top: '50%', // Top position relative to parent
left: '50%' // Left position relative to parent
},
showSpinner = function() {
// Add 'lightbox-is-open' and 'lightbox-is-fixed' classes to HTML
$('html').addClass('lightbox-is-open lightbox-is-fixed');
// Remove 'hidden' class from '.glasspane'
$('.glasspane').removeClass('hidden');
// Show spinner
if(spinner == null) {
spinner = new Spinner(opts).spin(spinner_div);
} else {
spinner.spin(spinner_div);
}
// Submit form after 500ms
var timer = window.setTimeout(function() {
$('form').submit();
}, 500);
};
// Bind events
$('form').on('submit', function(e) {
e.preventDefault();
showSpinner();
});
$('.next-sbumit').on('click', function(e) {
e.preventDefault();
showSpinner();
});
$('select').on('change', showSpinner);
});
</script>
Thanks for your help!!
I'm not seeing any errors, but one thing I noticed is a spelling mistake here:
$('.next-sbumit').on('click', function(e) {
e.preventDefault();
showSpinner();
});
next-sbumit should likely be next-submit - correct?
Assume that I have a JFreeChart 's line chart with points (0,0) and (3,3). So the line from (0,0) to (3,3) is shown. However when I zoom X-Axis so that to see the data between x=1 and x=2 no data (no line) is shown.
The problem occurs for me in two cases:
JFreeChart chart = org.jfree.chart.ChartFactory.createTimeSeriesChart("Example",
"", "test", null, false, true, false);
and for:
JFreeChart chart = org.jfree.chart.ChartFactory.createXYStepChart
("Example", "", "test", null,PlotOrientation.VERTICAL, true, true, false);
However in the second additionally I am getting the following exception:
Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Requires xLow < xHigh.
at org.jfree.chart.renderer.RendererUtilities.findLiveItemsLowerBound(RendererUtilities.java:76)
at org.jfree.chart.renderer.RendererUtilities.findLiveItems(RendererUtilities.java:261)
at org.jfree.chart.plot.XYPlot.render(XYPlot.java:3845)
at org.jfree.chart.plot.XYPlot.draw(XYPlot.java:3389)
at org.jfree.chart.JFreeChart.draw(JFreeChart.java:1237)
at org.jfree.chart.ChartPanel.paintComponent(ChartPanel.java:1677)
The main question is:
How can I set the renderer up to see the data (line) even if I zoom between 'passed data points'?
I need to be able to change the appearance of a Libgdx Button when some of my events are triggered.
Here is the declaration of my button:
Button googleButton = new Button(skin.getDrawable("google_sign_in"));
Here are the things I tried:
googleButton.setBackground(skin.getDrawable("google_sign_out"));
googleButton.invalidate();
googleButton.setChecked(true);
googleButton.invalidate();
googleButton.getStyle().up = skin.getDrawable("google_sign_out");
googleButton.invalidate();
I have done a lot of searches but I can't find the answer. Could somebody show me the right way of doing this?
I think the problem is that you're changing the contents of the skin/style after initializing the Button, but the button object does not reference the style after it has been initialized. I'm also not entirely clear on what you're going for. I assume you want to show a "sign in" button, until the user is signed in, and then you want that button to be a "sign out" button.
The invalidate method just triggers a re-layout (to re-compute the size/location of the Actor).
Maybe try forcing the style with setStyle, like this:
googleButton.getStyle().up = ... whatever;
googleButton.setStyle(googleButton.getStyle());
That said, I think you would be better off having two (?) different Button objects (one for logging in, and one for logging out). Pack them in a Stack, and just make one or the other invisible (see Actor.setVisible)
I managed to get this to work. In my Actor, a dice that have 6 possible images:
public Dice(int options) {
super(new Button.ButtonStyle());
}
And when I want to change the face:
public void setValue(int value) {
this.value = value;
Button.ButtonStyle style = getStyle();
style.up = new TextureRegionDrawable(
Assets.instance.dices.facesUp[value]);
style.down = new TextureRegionDrawable(
Assets.instance.dices.facesDown[value]);
style.checked = new TextureRegionDrawable(
Assets.instance.dices.facesChecked[value]);
setSize(getPrefWidth(), getPrefHeight());
}
I think the trick is at the
setSize(getPrefWidth(), getPrefHeight());
If I omit it, the dice doesn't get displayed. And there's no need for setStyle or invalidate().
Use CheckBox class instead;
1- make a .json file for the skin
{
com.badlogic.gdx.graphics.g2d.BitmapFont: { default-font: { file: fontfile.fnt } },
com.badlogic.gdx.graphics.Color: {
green: { a: 1, b: 0, g: 1, r: 0 },
white: { a: 1, b: 1, g: 1, r: 1 },
red: { a: 1, b: 0, g: 0, r: 1 },
black: { a: 1, b: 0, g: 0, r: 0 }
},
com.badlogic.gdx.scenes.scene2d.ui.CheckBox$CheckBoxStyle: {
google-loggin: { checkboxOn: google_sign_in, checkboxOff: google_sign_out, font: default-font, fontColor: white }
},
}
2- make a skin
skin = new Skin(Gdx.files.internal("your.json-file.json"), new TextureAtlas("textureAtlas-file.pack"));
3- create the button ignoring the first argument:
CheckBox loginButton = new CheckBox("", skin, "google-loging");
Just for anyone searching for this through google. To change the style of the button from a style already added to your skin file, after already initialising:
btn.setStyle(skin.get("YOUR BTN STYLE",TextButton.TextButtonStyle.class));
You must add image to button button_1.addActor(image). This image will cover the button origin skin. And then you can switch off and on this image image.setVisible(false)
I have some data representing answered questions in particular time e.g.
Question 1 answered in 00:00:20.
I am trying to use AChartEngine to represent this but with no luck.
First of all I can't have Y values as this format for a reason, guess it's not supported or needs customization which couldn't find a way till now to achieve.
My chart should have in the end the X-Axis with values 1, 2, 3, 4, 5.... and Y-Axis with
00:00:20, 00:00:15, 00:00:05, 00:00:10....
The time achieved in each question is saved in a Time object field.
I try this approach:
private void fillData() {
int i = 0;
for (Answer answer : getAnswers()) {
i++;
if (answer.getEstimatedAnswerTime() != null) {
Log.d(TAG, String.valueOf(answer.getEstimatedAnswerTime()));
myQuestionsTimeSeries.add(new Date(DateTimeHelper.getMillisFromTime(answer.getEstimatedAnswerTime())), i);
}
}
}
First problem, can't get the time values to Y-Axis and not shown correctly anyway. See screenshot below.
I guess you get my point so far.
Thank you in advance.
The TimeChart displays formatted date labels on the X axis. It seems like you need to do that on the Y axis.
Just create a regular LineChart and add custom labels on the Y axis:
// disable the default Y labels first
renderer.setYLabels(0);
// add several custom labels
renderer.addYTextLabel(y, "label");