mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 08:14:38 +02:00
Merge branch '1378-cambios-visuales-en-la-grafica-de-donut-en-consola-visual-dev' into 'develop'
Added visual changes to donut graph See merge request artica/pandorafms!1056
This commit is contained in:
commit
fa82e0317a
@ -1392,7 +1392,7 @@ function visual_map_print_item($mode = "read", $layoutData,
|
|||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if ($width == 0) {
|
if ($width == 0) {
|
||||||
$img = d3_donut_graph ($layoutData['id'], 400, 400, $donut_data, $layoutData['border_color']);
|
$img = d3_donut_graph ($layoutData['id'], 300, 300, $donut_data, $layoutData['border_color']);
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
$img = d3_donut_graph ($layoutData['id'], $width, $width, $donut_data, $layoutData['border_color']);
|
$img = d3_donut_graph ($layoutData['id'], $width, $width, $donut_data, $layoutData['border_color']);
|
||||||
@ -2540,15 +2540,21 @@ function get_donut_module_data ($id_module) {
|
|||||||
foreach ($values as $val) {
|
foreach ($values as $val) {
|
||||||
if ($index < $max_elements) {
|
if ($index < $max_elements) {
|
||||||
$data = explode(",", $val);
|
$data = explode(",", $val);
|
||||||
$values_to_return[$index]['tag_name'] = $data[0] . ", " . $data[1];
|
if ($data[1] == 0) {
|
||||||
|
$data[1] = __('No data');
|
||||||
|
}
|
||||||
|
$values_to_return[$index]['tag_name'] = $data[0] . ": " . $data[1];
|
||||||
$values_to_return[$index]['color'] = $colors[$index];
|
$values_to_return[$index]['color'] = $colors[$index];
|
||||||
$values_to_return[$index]['value'] = (int)$data[1];
|
$values_to_return[$index]['value'] = (int)$data[1];
|
||||||
$total += (int)$data[1];
|
$total += (int)$data[1];
|
||||||
$index++;
|
$index++;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if ($data[1] == 0) {
|
||||||
|
$data[1] = __('No data');
|
||||||
|
}
|
||||||
$data = explode(",", $val);
|
$data = explode(",", $val);
|
||||||
$values_to_return[$index]['tag_name'] = __('Others') . ", " . $data[1];
|
$values_to_return[$index]['tag_name'] = __('Others') . ": " . $data[1];
|
||||||
$values_to_return[$index]['color'] = $colors[$index];
|
$values_to_return[$index]['color'] = $colors[$index];
|
||||||
$values_to_return[$index]['value'] += (int)$data[1];
|
$values_to_return[$index]['value'] += (int)$data[1];
|
||||||
$total += (int)$data[1];
|
$total += (int)$data[1];
|
||||||
@ -2558,7 +2564,34 @@ function get_donut_module_data ($id_module) {
|
|||||||
foreach ($values_to_return as $ind => $donut_data) {
|
foreach ($values_to_return as $ind => $donut_data) {
|
||||||
$values_to_return[$ind]['percent'] = ($donut_data['value'] * 100) / $total;
|
$values_to_return[$ind]['percent'] = ($donut_data['value'] * 100) / $total;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$new_values_to_return = array();
|
||||||
|
while (!empty($values_to_return)) {
|
||||||
|
$first = true;
|
||||||
|
$max_elem = 0;
|
||||||
|
$max_elem_array = array();
|
||||||
|
$index_to_del = 0;
|
||||||
|
foreach ($values_to_return as $i => $val) {
|
||||||
|
if ($first) {
|
||||||
|
$max_elem = $val['value'];
|
||||||
|
$max_elem_array = $val;
|
||||||
|
$index_to_del = $i;
|
||||||
|
$first = false;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
if ($val['value'] > $max_elem) {
|
||||||
|
$max_elem = $val['value'];
|
||||||
|
$max_elem_array = $val;
|
||||||
|
$index_to_del = $i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$new_values_to_return[] = $max_elem_array;
|
||||||
|
unset($values_to_return[$index_to_del]);
|
||||||
|
}
|
||||||
|
$values_to_return = $new_values_to_return;
|
||||||
|
|
||||||
return $values_to_return;
|
return $values_to_return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1985,47 +1985,40 @@ function print_donut_graph (recipient, width, height, module_data, resume_color)
|
|||||||
var radius = 120;
|
var radius = 120;
|
||||||
var increment_y = 60;
|
var increment_y = 60;
|
||||||
var increment_y_padding = 25;
|
var increment_y_padding = 25;
|
||||||
var text_size = 15;
|
|
||||||
var decrement_x_padding = 150;
|
var decrement_x_padding = 150;
|
||||||
if (width >= 500) {
|
if (width >= 500) {
|
||||||
radius = 160;
|
radius = 180;
|
||||||
increment_y = 60;
|
increment_y = 60;
|
||||||
text_size = 25;
|
increment_y_padding = 20;
|
||||||
increment_y_padding = 25;
|
decrement_x_padding = 40;
|
||||||
decrement_x_padding = 75;
|
|
||||||
}
|
}
|
||||||
else if (width >= 400) {
|
else if (width >= 400) {
|
||||||
radius = 120;
|
radius = 140;
|
||||||
increment_y = 60;
|
increment_y = 40;
|
||||||
text_size = 22;
|
increment_y_padding = 20;
|
||||||
increment_y_padding = 25;
|
decrement_x_padding = 40;
|
||||||
decrement_x_padding = 75;
|
|
||||||
}
|
}
|
||||||
else if (width >= 300) {
|
else if (width >= 300) {
|
||||||
radius = 80;
|
radius = 100;
|
||||||
increment_y = 40;
|
increment_y = 40;
|
||||||
text_size = 14;
|
increment_y_padding = 15;
|
||||||
increment_y_padding = 20;
|
decrement_x_padding = 40;
|
||||||
decrement_x_padding = 60;
|
|
||||||
}
|
}
|
||||||
else if (width >= 200) {
|
else if (width >= 200) {
|
||||||
radius = 50;
|
radius = 50;
|
||||||
increment_y = 40;
|
increment_y = 40;
|
||||||
text_size = 14;
|
|
||||||
increment_y_padding = 15;
|
increment_y_padding = 15;
|
||||||
decrement_x_padding = 45;
|
decrement_x_padding = 25;
|
||||||
}
|
}
|
||||||
else if (width >= 100) {
|
else if (width >= 100) {
|
||||||
radius = 20;
|
radius = 20;
|
||||||
increment_y = 20;
|
increment_y = 20;
|
||||||
text_size = 10;
|
|
||||||
increment_y_padding = 8;
|
increment_y_padding = 8;
|
||||||
decrement_x_padding = 25;
|
decrement_x_padding = 25;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
radius = 10;
|
radius = 10;
|
||||||
increment_y = 10;
|
increment_y = 10;
|
||||||
text_size = 4;
|
|
||||||
increment_y_padding = 3;
|
increment_y_padding = 3;
|
||||||
decrement_x_padding = 5;
|
decrement_x_padding = 5;
|
||||||
}
|
}
|
||||||
@ -2041,15 +2034,24 @@ function print_donut_graph (recipient, width, height, module_data, resume_color)
|
|||||||
.value(function(d) {
|
.value(function(d) {
|
||||||
return parseFloat(d.percent);
|
return parseFloat(d.percent);
|
||||||
});
|
});
|
||||||
console.log(resume_color);
|
|
||||||
jQuery.each(module_data, function (key, m_d) {
|
jQuery.each(module_data, function (key, m_d) {
|
||||||
|
svg.append("g")
|
||||||
|
.append("rect")
|
||||||
|
.attr("transform", "translate(" + (((width / 2) - (radius + decrement_x_padding))) + "," + (((height / 2) - radius) - increment_y) + ")")
|
||||||
|
.attr('fill', m_d.color)
|
||||||
|
.attr('x', -20)
|
||||||
|
.attr('y', -10)
|
||||||
|
.attr('width', 20)
|
||||||
|
.attr('height', 10);
|
||||||
|
|
||||||
svg.append("g")
|
svg.append("g")
|
||||||
.append("text")
|
.append("text")
|
||||||
.attr('fill', resume_color)
|
.attr('fill', resume_color)
|
||||||
.attr("transform", "translate(" + (((width / 2) - (radius + decrement_x_padding))) + "," + (((height / 2) - radius) - increment_y) + ")")
|
.attr("transform", "translate(" + (((width / 2) - (radius + decrement_x_padding)) + 10) + "," + (((height / 2) - radius) - increment_y) + ")")
|
||||||
.text(m_d.tag_name)
|
.text(m_d.tag_name)
|
||||||
.style("font-family", "Verdana")
|
.style("font-family", "smallfontFont")
|
||||||
.style("font-size", text_size + "px");
|
.style("font-size", "7pt");
|
||||||
|
|
||||||
increment_y -= increment_y_padding;
|
increment_y -= increment_y_padding;
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user