Skip to content
This repository has been archived by the owner on Feb 13, 2019. It is now read-only.

Commit

Permalink
Doc + Graph Title display support
Browse files Browse the repository at this point in the history
  • Loading branch information
hugo082 committed Jun 6, 2017
1 parent 7a5c9aa commit ea057ab
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 12 deletions.
28 changes: 18 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

DBStatistic (DBS) is a graph generator that help you to implement a database statistics on your website.

`v1.0` `01 JUN 17`
`v1.1` `06 JUN 17`

## Installation

Expand Down Expand Up @@ -80,7 +80,7 @@ After this, go to your service class and implement your custom method

use DB\StatisticBundle\Core\Graph;

public function myCustomGraphMethod(Graph $graph, array $parameters) {
public function myCustomGraphMethod(Graph $graph) {
// set your data
}

Expand All @@ -90,7 +90,7 @@ To set data to your graph, you must use the `Graph` parameter and insert the dat
will contains the data. All data have been sorted by string label.
For example

public function myCustomGraphMethod(Graph $graph, array $parameters) {
public function myCustomGraphMethod(Graph $graph) {
$repo = $this->em->getRepository('MyBundle:MyEntity');
$entities = $repo->findAll();

Expand All @@ -111,7 +111,7 @@ List of line data insertion :
Your graph can contains multiple line. To do this, can create multiple line on your data (Warning : all line must have
different id).

public function myCustomGraphMethod(Graph $graph, array $parameters) {
public function myCustomGraphMethod(Graph $graph) {
$repo = $this->em->getRepository('MyBundle:MyEntity');
$entities = $repo->findAll();

Expand All @@ -127,17 +127,25 @@ different id).

### Graph actions

You can set different actions on your graph by adding them in your `config.yml` file. This action send to your custom
method in `paramters`. Some defaults methods takes this `parameters` into account to custom the result (like scale).
You can set different actions on your graph by adding them in your `config.yml` file. Thess actions are computed end injected
into your graph object. Some defaults methods takes these actions into account to custom the result (like scale).
For the `select` action type you must configure a `default` choice.

graphID:
actions:
- {id: actionId, title: actionTitle}
- {id: actionId, type: button, title: actionTitle} # type : 'button' | 'select'
- {id: datescale, type: select, choices: [
{id: week, title: Week},
{id: day, title: Day},
{id: month, title: Month, default: true},
{id: year, title: Year}
]
}

### Graph scale

You can create a scale for your graph. To do this, you must set the scale to your data and compute them with graph `parameters`.
All scale item have an `action_id`, and this item are choose when `parameters` contains his action.
You can create a scale for your graph. To do this, you must set the scale to your data and compute them with graph action.
All scale item have an `action_id`, and this item are choose when it is the value of action.

After setting all your data, you must compute them to take scale in consideration.

Expand All @@ -147,7 +155,7 @@ After setting all your data, you must compute them to take scale in consideratio

$data = $graph->getData();
$data->setScale(Scale::fromType(Scale::SCALE_TYPE_DATE));
$data->getScale()->computeParameters($parameters);
$data->getScale()->computeAction($graph->getAction("datescale"));

$caLine = $data->createLine("ca", "Chiffre d'affaire");
$beLine = $data->createLine("be", "Benefice");
Expand Down
5 changes: 5 additions & 0 deletions Resources/public/js/statcore.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ function GraphController(id) {
}).appendTo(this.container());
this.show();

$('<div>')
.text(graph.informations.title).attr({
class: "title-container"
}).prependTo(this.container());

this.actionController.graph = this.graph;
this.actionController.actions = graph.actions;
this.actionController.insert();
Expand Down
2 changes: 1 addition & 1 deletion Resources/public/js/statcore.min.js

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

2 changes: 1 addition & 1 deletion Resources/views/Default/index.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
background-color: #fafafa;
vertical-align: middle;
}
div[data-type=graph] div.actions-container {
div[data-type=graph] div.actions-container, div[data-type=graph] div.title-container {
text-align: center;
}
div[data-type=graph] canvas {
Expand Down

0 comments on commit ea057ab

Please sign in to comment.