How to use the d3-fetch.text function in d3-fetch

To help you get started, we’ve selected a few d3-fetch examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github openstreetmap / iD / modules / svg / data.js View on Github external
drawData.url = function(url, defaultExtension) {
        _template = null;
        _fileList = null;
        _geojson = null;
        _src = null;

        // strip off any querystring/hash from the url before checking extension
        var testUrl = url.split(/[?#]/)[0];
        var extension = getExtension(testUrl) || defaultExtension;
        if (extension) {
            _template = null;
            d3_text(url)
                .then(function(data) {
                    drawData.setFile(extension, data);
                })
                .catch(function() {
                    /* ignore */
                });

        } else {
            drawData.template(url);
        }

        return this;
    };
github openstreetmap / iD / modules / renderer / tasking.js View on Github external
taskGeoJSON.properties[prop] = json[prop];
                        }
                    }
                }

                return taskGeoJSON;
            }
            return '';
        }

        // load task if it hasn't ben loaded
        if (!that.getTask(taskId)) {
            var path = 'project/' + projectId + '/task/' + taskId + '?as_file=false';

            var url = apibase + path;
            d3_text(url)
                .then(function(result) {
                    if (result) {

                        // parse task
                        var json = combineTaskDetails(projectId, JSON.parse(result));
                        var parsedTask = parsers.task(json);

                        // add to tasks
                        _taskingCache.tasks.push(parsedTask);

                        // set as current task
                        _taskingCache.currentTask = parsedTask;

                        dispatch.call('loadedTask');
                    }
                })
github DefinitelyTyped / DefinitelyTyped / types / d3-fetch / d3-fetch-tests.ts View on Github external
let p3: Promise = d3Fetch.image(url);
const imageProperties = {
    width: '300px',
    height: '500px'
};
p3 = d3Fetch.image(url, imageProperties);

let p4: Promise = d3Fetch.json(url);
p4 = d3Fetch.json(url, init);
let p5: Promise = d3Fetch.json(url);
p5 = d3Fetch.json(url, init);

let myString: Promise;
myString = d3Fetch.text(url);
myString = d3Fetch.text(url, init);

const parseRow = (rawRow: DSVRowString, index: number, columns: string[]): (MyType | undefined | null) => {
    const myType: MyType | null = rawRow['foo'] ? { foo: rawRow['foo'] + '+ bar' } : null;
    return myType;
};
let promise1: Promise>;
let promise2: Promise>;
promise1 = d3Fetch.csv(url);
promise1 = d3Fetch.csv(url, init);
promise2 = d3Fetch.csv(url, parseRow);
promise2 = d3Fetch.csv(url, init, parseRow);
promise1 = d3Fetch.dsv(';', url);
promise1 = d3Fetch.dsv(';', url, init);
promise2 = d3Fetch.dsv(';', url, parseRow);
promise2 = d3Fetch.dsv(';', url, init, parseRow);
promise1 = d3Fetch.tsv(url);
github hpcc-systems / Visualization / website / src / markdownPlugins / sampleCarousel.ts View on Github external
renderSample() {
        let retVal;
        if (this._sampleWidgets[this._idx]) {
            this._sampleCarousel
                .active(this._idx)
                ;
            retVal = Promise.resolve();
        } else {
            retVal = text(this._samples[this._idx]).then(js => {
                this._sampleWidgets[this._idx] = new Sample().data([["", js]]);
                this._sampleCarousel
                    .widgets(this._sampleWidgets)
                    .active(this._idx)
                    ;
            });
        }
        return retVal.then(() => {
            this
                .title(this._samples[this._idx].substring((samplePath + "./samples/").length))
                .lazyRender()
                ;
        });
    }
github graphsense / graphsense-dashboard / src / app.js View on Github external
loadCategories () {
    this.mapResult(text('./categoryColors.yaml').then(YAML.parse), 'receiveCategoryColors')
    this.mapResult(this.rest.categories(), 'receiveCategories')
  }
  storeRelations (relations, anchor, keyspace, isOutgoing) {
github hpcc-systems / Visualization / packages / marshaller / src / ddl2 / dsTable.ts View on Github external
.on("click", () => {
            d3Text("https://raw.githubusercontent.com/hpcc-systems/Visualization/master/utils/data/data/airports.csv").then(csv => {
                this.add(new Databomb().format("csv").payload(csv));
            });
            d3Text("https://raw.githubusercontent.com/hpcc-systems/Visualization/master/utils/data/data/carriers.csv").then(csv => {
                this.add(new Databomb().format("csv").payload(csv));
            });
            d3Text("https://raw.githubusercontent.com/hpcc-systems/Visualization/master/utils/data/data/stats.csv").then(csv => {
                this.add(new Databomb().format("csv").payload(csv));
            });
            this.add(new WUResult(this._ec)
                .wu(new WU(this._ec).url("http://localhost:8010").wuid("W20190802-112509"))
                .resultName("Result 1")
            );
            this.add(new LogicalFile(this._ec)
                .url("http://localhost:8010")
                .logicalFile("progguide::exampledata::peopleaccts")
            );
            this.add(new LogicalFile(this._ec)
                .url("http://localhost:8010")
                .logicalFile("progguide::exampledata::people")
            );
            const vmRoxie = new RoxieService(this._ec)
                .url("http://localhost:8002")
github hpcc-systems / Visualization / packages / marshaller / src / ddl2 / dsTable.ts View on Github external
.on("click", () => {
            d3Text("https://raw.githubusercontent.com/hpcc-systems/Visualization/master/utils/data/data/airports.csv").then(csv => {
                this.add(new Databomb().format("csv").payload(csv));
            });
            d3Text("https://raw.githubusercontent.com/hpcc-systems/Visualization/master/utils/data/data/carriers.csv").then(csv => {
                this.add(new Databomb().format("csv").payload(csv));
            });
            d3Text("https://raw.githubusercontent.com/hpcc-systems/Visualization/master/utils/data/data/stats.csv").then(csv => {
                this.add(new Databomb().format("csv").payload(csv));
            });
            this.add(new WUResult(this._ec)
                .wu(new WU(this._ec).url("http://localhost:8010").wuid("W20190802-112509"))
                .resultName("Result 1")
            );
            this.add(new LogicalFile(this._ec)
                .url("http://localhost:8010")
                .logicalFile("progguide::exampledata::peopleaccts")
            );
            this.add(new LogicalFile(this._ec)
                .url("http://localhost:8010")
                .logicalFile("progguide::exampledata::people")