Using d3js with Nikola

瀏覽次數:20 次
跳到第一則未讀訊息

Nicolas Guarin

未讀,
2017年6月23日 晚上8:44:522017/6/23
收件者:nikola-discuss
Hello,

I am trying to add this script to a blog post

    http://bl.ocks.org/nicoguaro/b34fe29feb232413375b

I place the .tsv file in files and then, use the relative path to it. But the file is not copied to the output, and does not work. If I manually
place the file in the expected path it works.

Also, it appears in the wrong place... I think that this could be fixed replacing

   
    d3.select("body").append("svg")

by


d3.select("div").append("svg")

Chris Warrick

未讀,
2017年6月24日 清晨5:35:522017/6/24
收件者:Nikola—Discuss
> --
> You received this message because you are subscribed to the Google Groups
> "nikola-discuss" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to nikola-discus...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

* Where do you place the .tsv file?
* What is FILE_FOLDERS set to?
* What paths do you use?
* How do you use it in your code?
* The JS snippet assumes the document contains nothing else; you need
to adjust it to get into the post contents. How to that depends on
d3’s inner workings.

--
Chris Warrick <https://chriswarrick.com/>
PGP: 5EAAEA16

Nicolás Guarín-Zapata

未讀,
2017年6月27日 晚上8:04:182017/6/27
收件者:nikola-...@googlegroups.com
> * Where do you place the .tsv file?

I place it in files.


> * What is FILE_FOLDERS set to?

This is the line that set it up

FILES_FOLDERS = {'files': ''}


> * What paths do you use?

I was using the relative path

../files/materials.tsv

Another option is to use an URL from a file stored remotely, e.g.


https://gist.githubusercontent.com/nicoguaro/b34fe29feb232413375b/raw/d6c9ab62639de30f1ebdeca5225b3d23b1ba0df7/materials_E_density.tsv


> * How do you use it in your code?

I read the material data from this file to generate a visualization
like this one

http://bl.ocks.org/nicoguaro/raw/b34fe29feb232413375b/

> * The JS snippet assumes the document contains nothing else; you need
> to adjust it to get into the post contents. How to that depends on
> d3’s inner workings.

Yes, I noticed that ... I just realized that I can insert the content
inside the post using the tag article. Then, I can
add content with something like

var svg = d3.select("article").append("svg");

Chris Warrick

未讀,
2017年6月28日 清晨5:00:372017/6/28
收件者:Nikola—Discuss
On 28 June 2017 at 02:03, Nicolás Guarín-Zapata <nicog...@gmail.com> wrote:
>> * Where do you place the .tsv file?
>
> I place it in files.
>
>
>> * What is FILE_FOLDERS set to?
>
> This is the line that set it up
>
> FILES_FOLDERS = {'files': ''}
>
>
>> * What paths do you use?
>
> I was using the relative path
>
> ../files/materials.tsv

You can’t refer to it like that. Since you set files to the site root,
you must use /materials.tsv as your path. (Note that since you’re
doing it in JS code, you need to adjust the path if your site is not
in the server root.)
回覆所有人
回覆作者
轉寄
0 則新訊息