jqplot not displaying graph when using a custom tickRenderer (CanvasAxisTickRenderer) - jqplot

I have a complex graph (using highlighter.js, dateAxisRenderer.js, canvasOverlay.js, and enhancedLegendRenderer.js)
I want to add a label to the y axis (rotated in 90 degrees)
I included jqplot.canvasAxisLabelRenderer.min.js file and this is what i added to the cose:
yaxis: {
labelRenderer: $.jqplot.CanvasAxisLabelRenderer,
angle: 90,
label: "y axis label"
}
When adding this, the whole graph disappear.
any suggestions?

Is the problem remains if you modify angle: 90 by :
tickOptions: { angle:90 }
An other option is to modify angle: 90 by :
angle: -90
as accepted values for angle may goes from -90 to 89.
Is a debug tool like Firebug says something?
Edit : Try to combine both if you still have your problem

Related

shadow and rippled-texture in threejs

I try to apply texture on ground (a THREE.BoxBufferGeometry) , with shadow of a sphere (sphere is animated by Ammo.js)
The presence of shadow seems to depends of two parameters:
the shadow.camera settings of the THREE.DirectionalLight :
thObject.shadow.camera.left = -d;
thObject.shadow.camera.right = d;
thObject.shadow.camera.top = d;
thObject.shadow.camera.bottom = -d;
the shadow.camera.far setting :
thObject.shadow.camera.far = 110;
(it seems to depend of light position regarding shadow projection on ground).
But "playing" with these two settings create the following situation :
ripples on texture
shadow or not shadow (see after a part of shadow).
How to set these parameters but not by trial-and-error ?
(This depends of light position too): for exemple if light is not pointing in vertical axle:
pos: { x: -20, y: 35, z: -20 },
lookAt: { x: 0, y: 0, z: 0 },

The camera moves around the scene when scrolling THREE.JS GSAP SCROLLTRIGGER

My problem is when I scroll camera works good but closer to the end its stopping moving smoothly.
At this video I will show how its should work.
I was inspired by this web-site :)
And as I said, I have some little problems..
My glitch code: https://glitch.com/edit/#!/field-polished-border
This how this think is work right now:
gsap.to(camera.position, {
x: 1,
ease: "none",
scrollTrigger:{
trigger: sections[8],
},
})
Your if statements are pretty disorganized, so they eventually start conflicting with each other.
if(scrollTop >= 1400){
// rotate to y: -11
}
else{
// rotate to y: -9.5
}
if(scrollTop >= 3700){
// rotate to y: -12.5
}
This means that when scrollTop reaches 3701, it is both greater than 1400 and 3700, so it'll try to execute both rotations, fighting with each other and giving you glitchy behavior. You should clean up your if statements and make them more organized so they don't contradict each other:
if (scrollTop < 1400){
// rotate to y: -9.5 when less than 1400
}
else if (scrollTop < 3700) {
// rotate to y: -11 when between 1400 and 3700
}
else {
// rotate to y: -12.5 when greater than 3700
}

How to find text bounds for multilined text in P5.js?

I need to create autosized text setting some box size:
text(textContent, textX, textY, textWidth, textHeight);
The problem is that the text is multilined because it can't place on one line. Ok, then I've tried to check textBounds - but it works only with one line of string. How to find bounds for text drawing in some box/rect (textWidth, textHeight)?
I am having a little difficulty understanding your question. But if you wanted to create a box that encompassed all the text you could implement something like the following:
Lets assume we have our text stored to objects like this to make the logic easier to read:
var text1 = {
"str" : "This Is Line One",
X1: 0,
Y1: 0,
X2: 300,
Y2: 100,
size:30
}
var text2 = {
"str" : "This Is Line 2",
X1: 0,
Y1: 30,
X2: 300,
Y2: 100,
size:20
}
X1,Y1 is the upper left coordinate, and X2,Y2 is the lower right.
Now we have a data model to work with. We simply have to combine the bounds into a single rectangle.
Remember:
Rectangles are Declared like this:
Rect(X,Y,Width,Height)
Which is exactly the information textBounds() gives us!
Here is a quick and dirty example of the math:
function draw() {
textSize(this.text1.size);
text(this.text1.str,this.text1.X1,this.text1.Y1,this.text1.X2,this.text1.Y2);
textSize(this.text2.size);
text(this.text2.str,this.text2.X1,this.text2.Y1,this.text2.X2,this.text2.Y2);
//Get Text Bounds object for each text
let text1box = this.font.textBounds(this.text1.str,this.text1.X1,this.text1.Y1,this.text1.size)
let text2box = this.font.textBounds(this.text2.str,this.text2.X1,this.text2.Y1,this.text2.size)
//Get the upper-left and lower-right coordinates of the bounding rectangle of all the text
let bounds = {
x1: min(text1box.X,text2box.X), //upper left x
y1: min(text1box.Y,text2box.Y), //uper left y
x2: max(text1box.x + text1box.w,text2box.x + text2box.w), //lower right x
y2: max(text1box.y + text1box.y,text2box.y + text2box.h) //lower right y
}
//if you want padding:
let padding = 2;
rect(
bounds.x1 - padding,
bounds.y1 - padding,
abs(bounds.x2, - bounds.x1) + padding, //Width of the bounding rectangle
abs(bounds.y2 - bounds.y1) + padding //Height of the bounding rectangle
)
}
To fully show the logic here is a quick diagram I made
The cool thing about this logic is that even if the text isn't lined up perfectly, it is still able to put a box around all the text.

Programmatically paint an illuminated section of a speedometer

I am trying to make a gauge in Qt Quick that has sections that "light up" from 0 to the needle's position.
One way I can think of doing this is by having an image of the segment and painting it and rotating it many times from code. However, I don't know how this can be done in QML.
It doesn't have to be QML and it doesn't have to be Qt Quick; it could be anything as long as I can use it with Qt and within Qt creator and preferably works accross platforms.
Edit: Made rough sketch but StackOverflow requires me to have 10 reputation to post them, so I am placing links.
No segments illuminated ---------------------------- Some segments illuminated
-
You could easily use a Canvas element to draw an arc stroke with control over its start and end position. Just compose that below the scale of the gauge.
Here is an example how to do that using a value from 0 to 1 to select how "full" the gauge is.
ApplicationWindow {
visible: true
width: 500
height: 500
Canvas {
id: canvas
anchors.fill: parent
rotation: -90
onPaint: {
var c = getContext('2d')
c.clearRect(0, 0, width, height)
c.beginPath()
c.lineWidth = 30
c.strokeStyle = "red"
c.arc(250, 250, 250 - 15, 0, Math.PI * 2 * circ.value)
c.stroke()
}
}
Slider {
id: circ
minimumValue: 0
maximumValue: 1
value: maximumValue / 2
onValueChanged: canvas.requestPaint()
}
}
As requested by Mitch, I explain - the canvas is rotated at 90 CCW degree because of the way Qt draws arcs - they do not start at "12 o'clock" but at 3. You can remove the rotation of the canvas just in case you might want to draw extra stuff, cuz you wouldn't want to make all your drawing offset at 90 degree just to sit right with the rotated canvas, all you need to do to get rid of the rotation is draw the arc in range -Math.PI * 0.5 to Math.PI * 1.5 to account for the art starting at 3 o'clock.

Place a label at coordinates in Titanium

I have created a label and would like to place it on certain coordinates. Is there a way I can directly set the x and y coordinates to place the label in Titanium.
Very simply, just set the top and left values to to your respective Y and X values. These are relative to the labels parent, and will not work as expected if you set the parents layout property to anything but composite:
var label1 = Ti.UI.createLabel({
color: '#900',
font: { fontSize:48 },
text: 'A simple label',
textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
top: 30, // Your Y coordinate
left : 20, // Your X coordinate
width: Ti.UI.SIZE, height: Ti.UI.SIZE
});
Check this guide for more information about views, and positioning.

Resources