0
votes

In Play framework for scala I'm using data.csv in the js file line_graph.js and line_graph.js is loaded but data.csv is not getting loaded. How shall i load data in js file.

<script src="@routes.Assets.at("js/line_graph.js")" type="text/javascript"></script>

 <a  href="@routes.Assets.at("js/data.csv")"></a>
<script src="https://cdnjs.cloudflare.com/ajax/libs/d3/4.2.2/d3.js"></script>

My assets structure.

public /js /line_graph.js ,data.csv

my routes

GET     /assets/*file               controllers.Assets.at(path="/public", file)

application.conf

play.filters.headers.contentSecurityPolicy = "default-src *; script-src 'self' cdnjs.cloudflare.com code.jquery.com"

line_graph.js code

d3.csv("data.csv", function(error, data) {
    if (error)
        throw error;
    data.forEach(function(d) {
        d.number = d.number;
        d.iteration1 = +d.iteration1, d.iteration2 = +d.iteration2;
    });
1
Do you have any error in your browser developper window ?vdebergue

1 Answers

1
votes

In your file line_graph.js you don't use the correct url for the csv file. Try with:

d3.csv("/assets/js/data.csv", function(error, data) {
  ...