Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 20 days ago.
Improve this question
I have a map of an events of a football game, who looks like this:
const gameEvents = new Map([
[17, '⚽ GOAL'],
[36, '🔁 Substitution'],
[47, '⚽ GOAL'],
[61, '🔁 Substitution'],
[64, '🟡 Yellow card'],
[69, '🔴 Red card'],
[70, '🔁 Substitution'],
[72, '🔁 Substitution'],
[76, '⚽ GOAL'],
[80, '⚽ GOAL'],
[92, '🟡 Yellow card'],
]);
And i need to take every key (that is the minute in the game when an event happened) and calculate the average of minutes when an event happens and log to the console a string like this: 'an event happened on average every 9 minutes'
I don't have a clear idea of what to do to solve the problem
The average time between events is the average value of the intervals between each event. This can be calculated by running a for loop, adding each time interval between the current and the next event, and dividing by the number of intervals at the end.
This can be made a little faster by observing that when summing successive differences, the middle terms cancel out. Therefore the sum of the intervals is just the difference between the final time and the initial time.
Note: Think twice what to use as the denominator.
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed last month.
Improve this question
I'm a beginner at Three JS and need some help with my code. Please, Could you help me for a second?
1| Button1 "increase + 1". After Clicking Button 1, ROOM1 will move to ROOM2 Location and so forth. Room8 will move to ROOM1 position.
2| Button2 "increase + 2". After Clicking Button 2, ROOM1 will move to ROOM3 Location and so forth. Room8 will move to ROOM2 position.
Here's an example of what I mean:
This is my Code in Sandbox.
https://codesandbox.io/s/threejs-code-3rlk8b?file=/src/components/PartOne.js
Please help me.
Thank You So much for Your Precious Time
I'm expecting the solution that how can I use a click button and move my 3d Objects(room)
Using react state changes i did this solution.
First, you have positioned every room at a fixed point. You need to rotate the rooms which means you need to change their positions.
For this, i changed the fixed points in Room components to take it from props.
Example: for room8,
export function Room8({position,...props}) {
const { nodes, materials } = useGLTF('./models/room8.glb')
return (
<group castShadow receiveShadow {...props} dispose={null}>
<group castShadow receiveShadow position={position} rotation={[Math.PI, 0, Math.PI]}>
...your code
</group>
</group>
)
}
do this for all rooms.
Then add those positions as array in your PartOne.js
const positions= useMemo(()=>[
[0,0,0],
[-4, -2.7, 0],
[-0.5, -2.7, 3.6],
[-7.6, -5.5, 0],
[-4.5, -5.5, 3.6],
[-0.4, -5.5, 7.2],
[-7.6, -8.3, 3.55],
[-4, -8.3, 7.2]
]);
In PartOne.js
add a state to have your rooms in order.
const [rooms,setRooms]=useState(
[RoomOne,Room2,Room3,Room4,Room5,Room6,Room7,Room8]
);
add your button and rotate the room array,
<button onClick={()=>{
let arr=[...rooms];
arr.unshift(arr.pop())
console.log("arr::",arr)
setRooms(arr)
}}>Rotate +1</button>
render the state rooms inside canvas,
<Canvas shadows camera={{ fov:70, position: [0,0,30] }} >
<Suspense fallback={null} >
<ambientLight intensity={0.3} />
<directionalLight castShadow receiveShadow intensity={2} position={[80,80,80]} />
{rooms.map((room,roomIndex)=>room({position:positions[roomIndex]}))}
<ContactShadows />
</Suspense>
<OrbitControls enablePan={true} enableZoom={true} enableRotate={true} />
</Canvas>
Adding the sandbox with above changes for your reference,
Code Sandbox
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
Check This ImageI want to Make a Circular Progress Bar for my Website.Which Change Its Starting Point With Button Click. For Example, When Button 1 Clicked It Should Rotate From 270 Degrees, When Button 2 Clicked It Should Rotate From 0 degree,When Button 3 clicked It Should Rotate From 90 degrees and When Button 4 Clicked It Should Start from 180 degrees.....
Please Help Me
Thanks In Advance..
Keep in mind first that this is not a clear answer, cause a right one would take me time of coding.
I recently used a open-source library from github. Here is the link.
https://github.com/kottenator/jquery-circle-progress
It is exactly what you want (with some modifications).
Here is the example. https://kottenator.github.io/jquery-circle-progress/
If you see the fourth progress circle, you see that you can set your own starting angle.
Let me here explain how can this achieve having Example four as my reference:
/*
* Example 4:
* - solid color fill
* - custom start angle
* - custom line cap
* - dynamic value set
*/
var c4 = $('.forth.circle');
c4.circleProgress({
startAngle: -Math.PI / 4 * 3,
value: 0.5,
lineCap: 'round',
fill: { color: '#ffa500' }
});
With StartAgle you can set the start value of the progress bar.
You can easy update your code to make the circle over and over again until the content you want load.
See the usage of the library here : https://github.com/kottenator/jquery-circle-progress#usage
See that answer too:
https://stackoverflow.com/a/13371976/4108694
I am using the Timeline in somewhat of an unconventional way. I have the typical day and week event/tasks working fine but I need an hour summary for the week. I cannot get marking/blocking to work for the life of me. The picture example on the bottom of this page gets it correct (http://docs.dhtmlx.com/scheduler/limits.html) but where do the IDs come from?
scheduler.addMarkedTimespan({
days: [0,3],
zones: "fullday",
css: "green",
sections: { timeline: 2}
});
To further explain, we have employees Sally, Bob and Jerry. Let's say Sally worked 7, 8, 9, 4, 8 hours from the beginning of the week, Bob worked 8,9,8,8,9 and Jerry was off all week (so 0,0,0,0,0). If they worked 8 hours, the cell should be yellow, if over 8 green, and under 8 red. I'd also like to display the number in the cell. These can be disabled or not, events will not be allowed on the Hours timeline. Any help is greatly appreciated, as I've been stuck on this for a while. http://jsfiddle.net/Ld9vZ/24/
The best way to do this is to switch timeline to Cell mode (you should set render: 'cell' in the timeline config).
To change cells background colors and text you can overwrite scheduler.templates.timeline_cell_class and scheduler.templates.timeline_cell_value methods.
(see http://docs.dhtmlx.com/scheduler/timeline_view_templates.html)
You can see example here: http://docs.dhtmlx.com/scheduler/snippet/6be2d971
I'm having trouble with axes on some dc-js plots.
The axis lines are overly-thick and brush-filters are appearing as black boxes.
For example, the lower portion of the attached figure is drawn with only the following commands:
lower_bar_chart
.height(100)
.dimension(week_dim) // a basic time-rounded-to-the-week dimension
.group(count_by_week_group) // counts of some events by week
.centerBar(true)
.x(d3.time.scale().domain([new Date(2010, 01, 01), new Date(2015, 01, 01)]))
.round(d3.time.week.round)
.alwaysUseRounding(true)
.xUnits(d3.time.weeks);
This is nearly identical to the Nasdaq dc-js example, but the rendering looks awful (not to mention the opaque black time brush selections).
Any idea what might be going on?
I figured it was a style issue, but I'm already including dc.css.
Solved. dc.css wasn't being served up by the CDN correctly... downloading a local copy fixed the issue.
pro.
What this expression use for => this.sizes = [53, 56, 66, 78, 90];? I found it from markercluster.js.
If I want to limit only 100 markers appear on map for every time the map load/ or onchange the zooming map, does it mean I need to change to => this.sizes = [100]?
And how to change cluster icon outside ClusterMarker.js? Based on default, cluster icon will change according cluster size. How to make the cluster icon constant and without showing the number of total marker in it?
Sorry about my question. Because I really not familiar on javascript.
Hope someone can guide me. Thank you
this.sizes = [53, 56, 66, 78, 90]; are the dimensions of the cluster image, and not the number of markers.
If you want to limit the number of markers you should limit them in the file you get them from.
You change the cluster icon by using cluster options.
What version of markerclusterer do you use?