Skip to content

Commit

Permalink
Python2 test_commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrey authored and Andrey committed Apr 21, 2017
1 parent 5f4dcec commit 5b34d4c
Show file tree
Hide file tree
Showing 20 changed files with 1,527 additions and 0 deletions.
11 changes: 11 additions & 0 deletions instagramProj/.idea/instagramProj.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions instagramProj/.idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions instagramProj/.idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

960 changes: 960 additions & 0 deletions instagramProj/.idea/workspace.xml

Large diffs are not rendered by default.

Binary file added instagramProj/db.sqlite3
Binary file not shown.
Empty file added instagramProj/grab/__init__.py
Empty file.
6 changes: 6 additions & 0 deletions instagramProj/grab/admin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.contrib import admin

# Register your models here.
8 changes: 8 additions & 0 deletions instagramProj/grab/apps.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.apps import AppConfig


class GrabConfig(AppConfig):
name = 'grab'
80 changes: 80 additions & 0 deletions instagramProj/grab/code
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
x.domain(d3.extent(data, function(d) { return d.month; }));
y.domain(d3.extent(data, function(d) { return d.count_items; }));

svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + height + ")")
.call(xAxis);

svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")
.attr("y", 6)
.attr("dy", ".71em")
.style("text-anchor", "end")
.text("Play count");

svg.append("path")
.datum(data)
.attr("class", "line")
.attr("d", line);





console.log(url);

// render the table
tabulate(d.data, Object.keys( d ));

// render the chart with nvd3
nv.addGraph(function() {
var chart = nv.models.lineChart()
.margin({
left: 100
})
.useInteractiveGuideline(false)
.transitionDuration(350)
.showLegend(true)
.showYAxis(true)
.showXAxis(true);

chart.xAxis
.axisLabel("Year")
.tickFormat(d3.format(',r'));

chart.yAxis
.axisLabel(d.name + " x 1M")
.tickFormat(d3.format('.02f'));


var chartData = [{
values: [], //values - represents the array of {x,y} data points
key: d.code, //key - the name of the series.
color: '#ff7f0e' //color - optional: choose your own line color.
}];

var roots = d.data.map(function(e) {
return {
x: e[0].slice(0, 4),
y: e[1] / 1000000
};
});

//push it to chartData;
//change index or wrap in loop if more datasets graphed on the same chart, e.g. emissions from fossil, gas, etc.
chartData[0].values = roots;

d3.select('#chart svg') //select the <svg> element you want to render the chart in.
.datum(chartData) //populate the <svg> element with chart data...
.call(chart); //render the chart

//Update the chart when window resizes.
nv.utils.windowResize(function() {
chart.update();
});
return chart;
});
Empty file.
8 changes: 8 additions & 0 deletions instagramProj/grab/models.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import models


class Play:
name = models.CharField(max_length=100)
date = models.DateTimeField()
108 changes: 108 additions & 0 deletions instagramProj/grab/templates/graph/graph.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<!DOCTYPE html>
<meta charset="utf-8">
<style>

body {
font: 10px sans-serif;
}

.axis path,
.axis line {
fill: none;
stroke: #000;
shape-rendering: crispEdges;
}

.x.axis path {
display: none;
}

.line {
fill: none;
stroke: steelblue;
stroke-width: 1.5px;
}

</style>
<body>
<h1>D3_Data</h1>
<p>первый пример</p>
<div class="chartHTML"></div>
<script src="http://d3js.org/d3.v3.js"></script>
<script>
d3.select("h1").style("color","green");

var data_1 = [2,3,45,5,6,7,8,8]
d3.select("body").append("svg")
.selectAll("rect").data(data_1)
.enter()
.append("rect")

d3.json(
"{% url "PyData" %}", function( data) {
console.log(data)

var svg = d3.select("svg")

svg.append("g")
.attr("class", "x axis")
.attr("transform", "translate(0," + d3.max(d.X) + ")")
.call(xAxis);

svg.append("g")
.attr("class", "y axis")
.call(yAxis)
.append("text")
.attr("transform", "rotate(-90)")

}
);


function tabulate(data, columns) {

//remove existing table (if), create new one
d3.select("#datatable").selectAll("table").remove();
var table = d3.select("#datatable").append("table"),
thead = table.append("thead"),
tbody = table.append("tbody");

//append the header row
thead.append("tr")
.selectAll("th")
.data(columns)
.enter()
.append("th")
.text(function(column) {
return column;
});

// create a row for each object in the data
var rows = tbody.selectAll("tr")
.data(data)
.enter()
.append("tr");

// create a cell in each row for each column
var cells = rows.selectAll("td")
.data(function(row) {
return columns.map(function(column) {
return {
column: column,
value: row
};
});
})
.enter()
.append("td")
.text(function(d, i) {
return d.value[i];
});

firstgo=false;
return table;
}

</script>
</body>
</html>
6 changes: 6 additions & 0 deletions instagramProj/grab/tests.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.test import TestCase

# Create your tests here.
10 changes: 10 additions & 0 deletions instagramProj/grab/urls.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
from django.conf.urls import url

from .views import graph , PyData

urlpatterns = [
#url(r'^$', views.index, name='index'),
url(r'^$', graph),
#url(r'^api/play_count_by_month', play_count_by_month, name='play_count_by_month')
url(r'^PyData', PyData, name='PyData')
]
Loading

0 comments on commit 5b34d4c

Please sign in to comment.