小编DFe*_*her的帖子

D3.js不更新数据

我正在与AngularJS一起更新D3堆叠条形图.在此,所有数据最初都是可见的,并且更新过滤掉不需要的数据.在过去,它使用这个模型没有问题:

data = [{
    name: John Doe, 
    splits: [{distance: 1, time: 1234},]
},...]
Run Code Online (Sandbox Code Playgroud)

现在我尝试使用此模型为每个堆栈添加一个栏:

data = [{
    name: John Doe
    time: 12345, 
    splits: [{distance: 1, time: 1234},]
},...]
Run Code Online (Sandbox Code Playgroud)

我的问题是更新数据.我的计算值会被正确重新计算,例如缩放域.time更新行仍然只能识别更新前的数据值(为简洁起见,代码片段被严重截断):

// Set ranges of values in axes
x.domain(data.map(function(d) { return d.name}));
y.domain([ min , max]);

// Y Axis is updated to the correct time range
chart.append('g').attr('class', 'y axis').call(yAxis).selectAll('text').style('font-family','Open Sans').style('font-size', '.9rem'); 

// data join / Select Athlete
var athlete = chart.selectAll(".athlete").data(data),
athdata = athlete.enter(),

console.log(data) // data is correct here …
Run Code Online (Sandbox Code Playgroud)

html javascript bar-chart d3.js

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

Scrapy请求回调未触发

我正在使用scrapy 0.24从网站上抓取数据.但是,我无法通过回调方法发出任何请求parse_summary.

class ExampleSpider(scrapy.Spider):
    name = "tfrrs"
    allowed_domains = ["example.org"]
    start_urls = (
        'http://www.example.org/results_search.html?page=0&sport=track&title=1&go=1',
    )

    def __init__(self, *args, **kwargs):
        super(TfrrsSpider, self).__init__(*args, **kwargs)
        self.start_urls = ['http://www.example.org/results_search.html?page=0&sport=track'&title=1&go=1',]
            pass

    # works without issue
    def parse(self, response):
        races = response.xpath("//table[@width='100%']").xpath(".//a[starts-with(@href, 'http://www.tfrrs.org/results/')]/@href").extract()
        callback = self.parse_trackfieldsummary
        for race in races:
            yield scrapy.Request(race, callback=self.parse_summary)
        pass

    # works without issue
    def parse_summary(self, response):
        baseurl = 'http://www.example.org/results/'
        results = response.xpath("//div[@class='data']").xpath('.//a[@style="margin-left: 20px;"]/@href').extract()
        for result in results:
            print(baseurl+result)  # shows that url is correct everytime
            yield scrapy.Request(baseurl+result, callback=self.parse_compiled)

    # …
Run Code Online (Sandbox Code Playgroud)

python callback scrapy web-scraping python-2.7

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

连接到AEM 6.0 JCR:前提条件失败

我在AEM 6.0中连接到JCR存储库时遇到了一些问题.当我到达创建一个session关于repostory 的点时,我得到了一个javax.jcr.lock.LockException: Precondition Failed.

我一直在使用本教程开始.

这是我非常简单的代码示例:

import java.io.FileNotFoundException;
import java.io.FileReader;

import javax.jcr.Repository;
import javax.jcr.Session;
import javax.jcr.SimpleCredentials;

import org.apache.jackrabbit.commons.JcrUtils;

import com.opencsv.CSVReader;


public class Main { 

    public static void main(String[] args) throws FileNotFoundException {
        Repository repository;
        FileReader fileReader;
        CSVReader csvReader;

        try {
            System.out.println("connecting to repository");
            repository = JcrUtils.getRepository("http://localhost:4502/crx/server");

            Session session = repository.login( new SimpleCredentials("admin", "admin".toCharArray())); // throws javax.jcr.lock.LockException: Precondition Failed

        }
        catch(Exception e) {
            System.out.println(e);
        }
    }

}
Run Code Online (Sandbox Code Playgroud)

任何指导将不胜感激.

java jcr http-status-code-412 aem

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