小编tim*_*Tao的帖子

如何将所选节点置于d3 js前面?

我正在使用d3v3脚本来可视化数据.我需要在mouseleave中突出显示并将节点置于鼠标中心,反之亦然.现在,我可以通过增加节点的高度和宽度来高亮点亮节点.

无法将节点带到前面.我尝试过使用像opacity,z-index这样的CSS.

脚本

<script>

    // some colour variables
    var tcBlack = "purple";

    // rest of vars
    var w = 1500,
        h = 800,
        maxNodeSize = 50,
        x_browser = 25,
        y_browser = 25,
        root;

    var vis;
    var force = d3.layout.force(); 

    vis = d3.select("#visfel_map").append("svg").attr("width", w).attr("height", h);


    d3.json(url, function(error,json) {
    if (error) 
        return console.warn(error);
    root = json;
    root.fixed = true;
    root.x = w / 2;
    root.y = h / 4;


            // Build the path
    var defs = vis.insert("svg:defs")
        .data(["end"]);


    defs.enter().append("svg:path")
        .attr("d", …
Run Code Online (Sandbox Code Playgroud)

javascript css html5 data-driven d3.js

6
推荐指数
2
解决办法
1427
查看次数

解决从JSON解码的PHP数组

我正在加载一个JSON数组并将其解码为PHP数组

$jsonfile = file_get_contents('https://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=MSFT&interval=15min&outputsize=full&apikey=demo'); 
$jsonarray = json_decode($jsonfile); 
var_dump($jsonarray);
Run Code Online (Sandbox Code Playgroud)

到目前为止,我得到一个看起来像这样的数组:

object(stdClass)#1 (2) { 
    ["Meta Data"]=> object(stdClass)#2 (5) { 
        ["1. Information"]=> string(49) "Daily Prices (open, high, low, close) and Volumes" 
        ["2. Symbol"]=> string(5) "AAWVX" 
        ["3. Last Refreshed"]=> string(10) "2017-06-30" 
        ["4. Output Size"]=> string(9) "Full size" 
        ["5. Time Zone"]=> string(10) "US/Eastern" 
    } 
    ["Time Series (Daily)"]=> object(stdClass)#3 (105) { 
        ["2017-06-30"]=> object(stdClass)#4 (5) { 
            ["1. open"]=> string(7) "10.5100" 
            ["2. high"]=> string(7) "10.5100" 
            ["3. low"]=> string(7) "10.5100" 
            ["4. close"]=> string(7) "10.5100" 
            ["5. volume"]=> string(1) "0" 
        } …
Run Code Online (Sandbox Code Playgroud)

php arrays json

4
推荐指数
1
解决办法
339
查看次数

在woocommerce中更改特定产品的购物车项目数量

我可以在某些特定产品中更改WooCommerce数量吗?

我试过了:

global $woocommerce;
    $items = $woocommerce->cart->get_cart();
    foreach($items as $item => $values) { 
        $_product = $values['data']->post; 
        echo "<b>".$_product->post_title.'</b>  <br> Quantity: '.$values['quantity'].'<br>'; 
        $price = get_post_meta($values['product_id'] , '_price', true);
        echo "  Price: ".$price."<br>";
    } 
Run Code Online (Sandbox Code Playgroud)

如何在购物车中获取特定产品ID?

php wordpress cart woocommerce product-quantity

3
推荐指数
1
解决办法
7574
查看次数

Terraform:列表到字符串

我正在尝试使用 terraform module 创建一个安全组terraform-aws-modules/security-group/aws。这需要从数据源id获取的VPC。aws_vpcsVPC ID 需要一个字符串值,但aws_vpcs数据源返回一个包含单个值的列表。

请找到

data "aws_vpcs" "this" {
  tags = {
    "Name" = "example"
  }
}

module "route53_sg" {
  source = "terraform-aws-modules/security-group/aws"

  name        = "R53_health_checkers"
  description = "Security group for Route53 health checkers"
  vpc_id      = element([data.aws_vpcs.this.ids], 0)
  ingress_cidr_blocks = [
...
...
...
  ]
  ingress_rules = ["https-443-tcp"]
}




Run Code Online (Sandbox Code Playgroud)
$ terraform apply
data.aws_lb.ext_alb: Refreshing state...
data.aws_vpcs.this: Refreshing state...

Error: Invalid value for module argument

  on main.tf line 75, in module …
Run Code Online (Sandbox Code Playgroud)

terraform

3
推荐指数
1
解决办法
1万
查看次数

C#'Enumerable.Repeat()'如何重载?

我已经为遗传算法编写了这个代码,通过获得基因的随机int(质量,高度(指标)和腿力)计算跳跃高度,然后用其他表现最好的随机标本再现自身.存储在一个名为的2d数组中geneBoard.现在我的问题; 你认为写1000次相同的值是不切实际的,所以我试着用这个:

float[,] geneBoard = Enumerable.Repeat(
    mass = GetMass(500, 1000), 
    height = GetHeight(150, 190), 
    force = GetForce(500, 3500), 
    fitnessScore = Convert.ToSingle(PhysicalTest(mass, height, force)), 1000)
.ToArray();
Run Code Online (Sandbox Code Playgroud)

而不是这个:

float[,] geneBoard = new float[4, 4]
        {
            { mass = GetMass(500, 1000), height = GetHeight(150, 190), force = GetForce(500, 3500), fitnessScore = Convert.ToSingle(PhysicalTest(mass, height, force)) },
            { mass = GetMass(500, 1000), height = GetHeight(150, 190), force = GetForce(500, 3500), fitnessScore = Convert.ToSingle(PhysicalTest(mass, height, force)) },
            { mass = GetMass(500, 1000), height = …
Run Code Online (Sandbox Code Playgroud)

c# linq multidimensional-array genetic-algorithm

1
推荐指数
1
解决办法
151
查看次数