API中的描述令人困惑。我希望target该值是模拟停止滴答的值,但targetAPI中未定义。另外alpha本身没有在API中定义,但我发现,在其他网站:
https://roshansanthosh.wordpress.com/2016/09/25/forces-in-d3-js-v4/
模拟的一个重要方面是alpha。alpha是介于0和1之间的数字,它定义了模拟进行的程度。模拟开始时,alpha设置为1,并且此值根据alphaDecay速率缓慢衰减,直到达到模拟的alphaTarget为止。一旦alpha值小于alphaTarget,模拟就会停止。默认情况下,alphaTarget设置为0.1
现在使用官方API:
如果指定了min,则将最小alpha设置为[0,1]范围内的指定数字,并返回此模拟。如果未指定min,则返回当前的最小alpha值,默认为0.001。当前的alpha值小于最小alpha值时,模拟的内部计时器停止。〜0.0228的默认alpha衰减率对应于300次迭代。
如果指定了目标,则将当前目标alpha设置为[0,1]范围内的指定数字,并返回此模拟。如果未指定target,则返回当前的目标alpha值,默认为0。
我很难理解quicksort,大多数演示和解释都忽略了实际发生的事情(例如http://me.dt.in.th/page/Quicksort/).
维基百科说:
从数组中选择一个称为pivot的元素.分区:对数组进行重新排序,使得值小于枢轴的所有元素都在枢轴之前,而所有值大于枢轴的元素都在它之后(相等的值可以是任意一种).在此分区之后,枢轴处于其最终位置.这称为分区操作.递归地将上述步骤应用于具有较小值的元素的子数组,并分别应用于具有较大值的元素的子数组.
如何使用9,1,7,8,8的数组,例如以7为枢轴?9需要移动到枢轴的右侧,所有快速排序实现都是现场操作,所以我们不能在8,8之后添加它,所以唯一的选择是将9与7交换.
现在阵列是7,1,9,8,8.quicksort背后的想法是,现在我们必须递归地将部件分类到枢轴的左侧和右侧.枢轴现在位于数组的位置0,这意味着没有左侧部分,因此我们只能对正确的部分进行排序.这是没有用的7> 1所以枢轴最终在错误的地方.
在这个图像4是枢轴,那么为什么5几乎一直向左?它大于4!经过大量的交换后,它最终被排序,但我不明白这是怎么回事.
React Table 的文档非常稀疏,我无法理解这些示例。
例如这里: https: //react-table.tanstack.com/docs/examples/data-driven-classes-and-styles,我们看到这样的代码:
{row.cells.map(cell => {
return (
<td
// Return an array of prop objects and react-table will merge them appropriately
{...cell.getCellProps([
{
className: cell.column.className,
style: cell.column.style,
},
getColumnProps(cell.column),
getCellProps(cell),
])}
>
{cell.render('Cell')}
</td>
Run Code Online (Sandbox Code Playgroud)
我不清楚发生了什么。
GetCellProps被调用,并提供一个数组作为参数。该数组包含 1. 一个具有两个属性的对象,2. 一次调用getColumnProps(这有什么作用?),然后 3. 另一个调用,getCellProps但现在以单元格作为参数。
然后使用扩展运算符 (...) 对该调用的结果进行运算。
如果有人能帮助我理解这一切,非常感谢。
这已被问过100次,但在阅读了很多这些帖子后,我仍然不确定我做错了什么.该脚本仅在您按下按钮时执行(因此在执行代码时文本框应存在于DOM中),Visual Studio甚至允许我自动完成inputField的getElementByID参数.但不知怎的,它没有得到元素,我的屏幕上印有'null'.
我的代码是:
<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
<!-- input field + button, and an empty value field -->
<input type="text" id="inputField" value="" />
<input type="button" onclick="printType()" />
</body>
<script>
function printType() {
console.log(document.getElementById(inputField).value); //first try to get the value the regular way
console.log(
get_type(
document.getElementById(inputField)
)
); //also try get_type to see if it exists, we're expecting a string
}
//stole this function from a stackoverflow post
function get_type(thing) {
if (thing …Run Code Online (Sandbox Code Playgroud) javascript ×2
algorithm ×1
d3.js ×1
force-layout ×1
html ×1
quicksort ×1
react-table ×1
reactjs ×1
sorting ×1