-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
127 additions
and
100 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +0,0 @@ | ||
<script tal:attributes="src string:${view/site_url}//++plone++senaite.ast.static/bundles/senaite.ast.js"></script><link href="#" rel="stylesheet" tal:attributes="href string:${view/site_url}//++plone++senaite.ast.static/bundles/senaite.ast.5e0568240a9f397d2c58.css"/> | ||
This file was deleted.
Oops, something went wrong.
99 changes: 99 additions & 0 deletions
99
src/senaite/timeseries/browser/templates/timeseries_results.pt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
<tal:contents_table | ||
define="portal context/@@plone_portal_state/portal;" | ||
i18n:domain="senaite.timeseries"> | ||
|
||
<!-- Load d3.js --> | ||
<script src="https://d3js.org/d3.v4.js"></script> | ||
<script> | ||
// set the dimensions and margins of the graph | ||
var margin = {top: 10, right: 30, bottom: 30, left: 60}, | ||
width = 460 - margin.left - margin.right, | ||
height = 400 - margin.top - margin.bottom; | ||
|
||
// append the svg object to the body of the page | ||
var svg = d3.select("#my_dataviz") | ||
.append("svg") | ||
.attr("width", width + margin.left + margin.right) | ||
.attr("height", height + margin.top + margin.bottom) | ||
.append("g") | ||
.attr("transform", | ||
"translate(" + margin.left + "," + margin.top + ")"); | ||
|
||
//Read the data | ||
d3.csv("https://raw.githubusercontent.com/holtzy/data_to_viz/master/Example_dataset/3_TwoNumOrdered_comma.csv", | ||
|
||
// When reading the csv, I must format variables: | ||
function(d){ | ||
return { date : d3.timeParse("%Y-%m-%d")(d.date), value : d.value } | ||
}, | ||
|
||
// Now I can use this dataset: | ||
function(data) { | ||
|
||
// Add X axis --> it is a date format | ||
var x = d3.scaleTime() | ||
.domain(d3.extent(data, function(d) { return d.date; })) | ||
.range([ 0, width ]); | ||
svg.append("g") | ||
.attr("transform", "translate(0," + height + ")") | ||
.call(d3.axisBottom(x)); | ||
|
||
// Add Y axis | ||
var y = d3.scaleLinear() | ||
.domain([0, d3.max(data, function(d) { return +d.value; })]) | ||
.range([ height, 0 ]); | ||
svg.append("g") | ||
.call(d3.axisLeft(y)); | ||
|
||
// Add the line | ||
svg.append("path") | ||
.datum(data) | ||
.attr("fill", "none") | ||
.attr("stroke", "steelblue") | ||
.attr("stroke-width", 1.5) | ||
.attr("d", d3.line() | ||
.x(function(d) { return x(d.date) }) | ||
.y(function(d) { return y(d.value) }) | ||
) | ||
|
||
debugger; | ||
} | ||
) | ||
|
||
|
||
</script> | ||
|
||
<!-- Results entry listing --> | ||
<form name="listing_form" | ||
class="form form-inline" | ||
method="post" | ||
i18n:domain="senaite.timeseries" | ||
tal:omit-tag="view/omit_form" | ||
tal:attributes="id python:view.form_id; | ||
action python:view.getPOSTAction()"> | ||
|
||
<input tal:condition="not: view/omit_form" | ||
tal:replace="structure context/@@authenticator/authenticator"/> | ||
|
||
<input tal:condition="not: view/omit_form" | ||
type="hidden" name="submitted" value="1"/> | ||
|
||
<!-- ReactJS managed component --> | ||
<div class="ajax-contents-table w-100" | ||
tal:attributes="data-form_id python:view.form_id; | ||
data-listing_identifier python:view.listing_identifier; | ||
data-enable_ajax_transitions python:view.ajax_transitions_enabled(); | ||
data-pagesize python:view.pagesize; | ||
data-api_url python:view.get_api_url(); | ||
data-columns python:view.ajax_columns(); | ||
data-show_column_toggles python:view.ajax_show_column_toggles(); | ||
data-review_states python:view.ajax_review_states();"> | ||
</div> | ||
</form> | ||
|
||
<!-- Create a div where the graph will take place --> | ||
<p>WTF</p> | ||
<div id="my_dataviz"></div> | ||
<p>WTF</p> | ||
|
||
</tal:contents_table> |