2013-10-28 24 views
2

我做了一個項目的形式,我想在symfony2中做甘特圖。我如何在symfony2.3中創建甘特圖?請給我建議。如何在symfony2中使用圖表?

這裏是一個甘特圖示例:

enter image description here

,這裏是我的項目表的代碼:

{% extends '::base.html.twig' %} 
{% block body -%} 
<title>{% block title %}Projects>Create Projects{% endblock %}</title> 
{% block stylesheets %} 
<link href="{{ asset('styles/bootstrap1.css') }}" rel="stylesheet" /> 
<link href="{{ asset('styles/uniform.default.css') }}" rel="stylesheet" /> 
<link href="{{ asset('styles/select2.css') }}" rel="stylesheet" /> 
<link href="{{ asset('styles/form-wizard.css') }}" rel="stylesheet" /> 
<style type="text/css"> 
.btn { 
display: inline-block; 
padding: 4px 12px; 
margin-bottom: 0; 
font-size: 14px; 
font-weight: normal; 
line-height: 1.428571429; 
text-align: center; 
white-space: nowrap; 
vertical-align: middle; 
cursor: pointer; 
margin:0 300px; 
margin-top: 20px; 
border: 1px solid transparent; 
border-radius: 4px; 
-webkit-user-select: none; 
-moz-user-select: none; 
    -ms-user-select: none; 
    -o-user-select: none; 
     user-select: none;   
} 
#space{ 
    margin:0 70px; 
    } 
.wizard-steps li { 
display: block; 
float: left; 
max-width: 25%; 
min-width: 20%; 
text-align: center; 
} 
</style> 
{% endblock %} 
<div id="fuelux-wizard" class="wizard row"> 
    <ul class="wizard-steps"> 
     <li data-target="#step1" class="active"> 
      <span class="step">1</span> 
      <span class="title">Create <br> Projects</span> 
     </li> 
     <li data-target="#step2"> 
      <span class="step">2</span> 
      <span class="title">Milestones</span> 
     </li> 
     <li data-target="#step3"> 
      <span class="step">3</span> 
      <span class="title">Tasklist</span> 
     </li> 
     <li data-target="#step4"> 
      <span class="step">4</span> 
      <span class="title">Tasks</span> 
     </li> 
     <li data-target="#step5"> 
      <span class="step">5</span> 
      <span class="title">Teams</span> 
     </li> 
    </ul>        
    </div> 
<div id="space"> 
<h3>Projects creation</h3> 
<form action="{{ path('projects_create') }}" method="post" {{ form_enctype(form) }}> 
    {{ form_widget(form) }} 
    <p> 
<button type="submit" class="btn btn-success"> Next <i class="icon-chevron-right"></i> </button> 
    </p> 
</form> 
<div id="result"></div> 
    <ul class="record_actions"> 
    <li> 
     <a href="{{ path('projects') }}"> 
      Back to the list 
     </a> 
    </li> 
</ul> 
</div> 
{% endblock %} 
{% block javascripts %} 
<script src="{{ asset('js/jquery-1.10.2.js') }}" type="text/javascript"></script> 
<script type="text/javascript"> 
    $(document).ready(function() { 
    $("form").submit(function(e) {    
     e.preventDefault(); 
     var url = $(this).attr('action'); 
     var data = $(this).serialize(); 
     $.ajax({ 
      type: "POST", 
      url: url, 
      data: data, 
     }).done(function(result) { 
      if(result.success) { 
       $('#result').css({'color':'black','background-color':'#8F8','display':'Block','width':'200px'}); 
       $('#result').html('Projects Record Inserted'); 
       setTimeout(function(){ 
        $('#result').hide(); 
        },3000); 
      window.location.href = "{{ path('milestones_new') }}"; 
      } 
     }); 
     this.reset(); 
    }); 
});  
</script> 

{% endblock %} 
+0

你已經有一個實體來存儲任務嗎?你會手動輸入你的taks的開始和結束日期嗎?或者你想Symfony2(用你的代碼)從輸入創建甘特圖? –

+1

不,我不輸入任務的開始日期和結束日期,但我想從輸入創建甘特圖 –

+0

首先,您必須創建將存儲任務的實體。 [自引用表](http://docs.doctrine-project.org/en/latest/reference/association-mapping.html#one-to-one-self-referencing)應該很好地存儲任務。然後,您必須執行計算才能生成甘特圖。最後,你將不得不顯示它。這是雄心勃勃的,祝你好運。 :) –

回答