Commit d0c4dbf3 authored by bhm15's avatar bhm15
Browse files

Add admission app & Chart Class on static

parent cb724a22
Pipeline #16153 failed with stage
in 5 minutes and 50 seconds
......@@ -45,6 +45,7 @@ INSTALLED_APPS = [
'public',
'degree',
'educator',
'admission',
'uploads'
]
......
class AdegaChart{
constructor(config){
this.data = null;
this.data_x = config.data_x;
this.data_y = config.data_y;
this.div_target = config.div_target;
this.error_y = config. error_y || null;
this.type = config.type || "scatter";
this.title = config.title || "";
this.legend = config.legend || null;
if(typeof(this.data_y[0]) == "number"){
this.data_y = [this.data_y];
this.type = [this.type];
this.legend = [this.legend];
if(this.error_y != null)
this.error_y = [this.error_y];
}
this.reloadGraph();
}
reloadGraph(){
var data = [];
for(var i in this.data_y){
data.push(
{
x: this.data_x,
y: this.data_y[i],
type: this.type[i],
fill: "tozeroy"
}
);
if(this.legend && this.legend[i] != null){
data[i].name = this.legend[i];
}
if(this.error_y && this.error_y[i] != null){
data[i].error_y = {
type: 'data',
array: this.error_y[i],
visible: true,
}
}
}
var layout = {
title: this.title
};
Plotly.newPlot(this.div_target, data, layout);
}
}
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -66,4 +66,9 @@
</div>
</footer>
</body>
<script src="{% static 'adega/js/plotly-latest.min.js' %}"></script>
<script src="{% static 'adega/js/adega-chart.js' %}"></script>
{% block js-foot %}
{% endblock js-foot %}
</html>
\ No newline at end of file
......@@ -8,6 +8,8 @@ urlpatterns = [
url(r'^uploads/', include('uploads.urls', namespace='uploads')),
url(r'^admission/', include('admission.urls', namespace='admission')),
url(r'^public/', include('public.urls', namespace='public')),
url(r'^logout/$', views.logout, name='logout'),
......
from django.contrib import admin
# Register your models here.
from django.apps import AppConfig
class AdmissionConfig(AppConfig):
name = 'admission'
from django.db import models
# Create your models here.
{% extends 'base.html' %}
{% load static %}
{% block content %}
<div id="myChart"></div>
<div id="myChart2"></div>
{% endblock content %}
{% block js-foot %}
<script>
var chart1 = new AdegaChart({
data_x: [0,1,2],
data_y: [6,10,2],
div_target: "myChart",
error_y: [1,2,3],
//type: "bar",
title: "Exemplo 1"
});
var chart1 = new AdegaChart({
data_x: [0,1,2],
data_y: [[6,10,2], [7,9,2.5]],
div_target: "myChart2",
error_y: [[1,2,3], [1.5,0.1,0.5]],
type:["bar", "scatter"],
title: "Exemplo 2",
legend: ["linha 1", "linha 2"]
});
</script>
{% endblock js-foot %}
\ No newline at end of file
from django.test import TestCase
# Create your tests here.
from django.conf.urls import url
from django.conf import settings
from django.conf.urls.static import static
from admission import views
urlpatterns = [
url(r'^$', views.upload, name='upload'),
]
if settings.DEBUG:
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.shortcuts import render, redirect
from django.core.files.storage import FileSystemStorage
from django.contrib import messages
def upload(request):
return render(request, 'admission/admission.html')
......@@ -2,7 +2,7 @@ from django.conf.urls import url
from django.conf import settings
from django.conf.urls.static import static
from uploads import views
from admission import views
urlpatterns = [
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment