Filter custom graph size in visual console editor, autoset size - #99
This commit is contained in:
parent
dc085fa339
commit
62541482ab
|
@ -0,0 +1,7 @@
|
|||
<?php
|
||||
$stacked = db_get_sql('select stacked from tgraph where id_graph = '.$_GET['data']);
|
||||
$num_items = db_get_sql('select count(*) from tgraph_source where id_graph = '.$_GET['data']);
|
||||
echo "$stacked,$num_items";
|
||||
|
||||
|
||||
?>
|
|
@ -298,6 +298,26 @@ function update_button_palette_callback() {
|
|||
break;
|
||||
case 'module_graph':
|
||||
|
||||
|
||||
if($('#dir_items').html() == 'horizontal'){
|
||||
if(parseInt($('#text-left').val()) + (parseInt($('input[name=height_module_graph]').val() * $('#count_items').html())) > parseInt($('#background').css('width'))
|
||||
|| parseInt($('#text-left').val()) + (parseInt($('input[name=width_module_graph]').val() * $('#count_items').html())) > parseInt($('#background').css('width'))){
|
||||
|
||||
alert($('#count_items').html()+' joined graph items are wider than background');
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if($('#dir_items').html() == 'vertical'){
|
||||
if(parseInt($('#text-top').val()) + (parseInt($('input[name=height_module_graph]').val() * $('#count_items').html())) > parseInt($('#background').css('height'))){
|
||||
alert($('#count_items').html()+' joined graph items are higher than background');
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if($('input[name=width_module_graph]').val() == ''){
|
||||
alert('Undefined width');
|
||||
return false;
|
||||
|
@ -1151,6 +1171,8 @@ function loadFieldsFromDB(item) {
|
|||
|
||||
});
|
||||
|
||||
$('#count_items').html(1);
|
||||
|
||||
if (data.type == 6 || data.type == 7 || data.type == 8 || data.type == 1) {
|
||||
|
||||
$("#period_row." + item).css('display', '');
|
||||
|
@ -1169,6 +1191,20 @@ function loadFieldsFromDB(item) {
|
|||
|
||||
}
|
||||
else {
|
||||
|
||||
jQuery.get ("ajax.php",
|
||||
{"page": "general/cg_items","data": data.id_custom_graph},
|
||||
function (data, status) {
|
||||
if(data.split(",")[0] == 4){
|
||||
$('#count_items').html(data.split(",")[1]);
|
||||
$('#dir_items').html('vertical');
|
||||
}
|
||||
else if (data.split(",")[0] == 5) {
|
||||
$('#count_items').html(data.split(",")[1]);
|
||||
$('#dir_items').html('horizontal');
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
$("input[name='radio_choice'][value='custom_graph']")
|
||||
.prop('checked', true);
|
||||
|
|
|
@ -446,7 +446,10 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
|
|||
html_print_input_text('width_module_graph', 300, '', 3, 5, true) .
|
||||
' X ' .
|
||||
html_print_input_text('height_module_graph', 180, '', 3, 5, true) .
|
||||
'</td>';
|
||||
' X ' .
|
||||
'<span id="count_items">1</span> '.
|
||||
'<span id="dir_items"></span> item/s
|
||||
</td>';
|
||||
|
||||
|
||||
//Insert and modify before the buttons to create or update.
|
||||
|
@ -587,6 +590,49 @@ function visual_map_editor_print_item_palette($visualConsole_id, $background) {
|
|||
$(".border_color").attachColorPicker();
|
||||
$(".fill_color").attachColorPicker();
|
||||
$(".line_color").attachColorPicker();
|
||||
|
||||
$("input[name=radio_choice]").change(function(){
|
||||
$('#count_items').html(1);
|
||||
});
|
||||
|
||||
$("#custom_graph").click(function(){
|
||||
$('#count_items').html(1);
|
||||
jQuery.get ("ajax.php",
|
||||
{"page": "general/cg_items","data": $(this).val()},
|
||||
function (data, status) {
|
||||
if(data.split(",")[0] == 8){
|
||||
size = 400+(data.split(",")[1] * 50);
|
||||
if(data.split(",")[1]>3){
|
||||
size = 400+(3 * 50);
|
||||
}
|
||||
$('#text-width_module_graph').val(size);
|
||||
$('#text-height_module_graph').val(180);
|
||||
|
||||
}
|
||||
else if (data.split(",")[0] == 4) {
|
||||
size = data.split(",")[1];
|
||||
if(data.split(",")[1] > 1){
|
||||
$('#count_items').html(data.split(",")[1]);
|
||||
$('#dir_items').html('vertical');
|
||||
}
|
||||
$('#text-width_module_graph').val(300);
|
||||
$('#text-height_module_graph').val(50);
|
||||
}
|
||||
else if (data.split(",")[0] == 5) {
|
||||
size = data.split(",")[1];
|
||||
if(data.split(",")[1] > 1){
|
||||
$('#count_items').html(data.split(",")[1]);
|
||||
$('#dir_items').html('horizontal');
|
||||
}
|
||||
$('#text-width_module_graph').val(100);
|
||||
$('#text-height_module_graph').val(100);
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
|
||||
});
|
||||
</script>
|
||||
<?php
|
||||
|
|
|
@ -598,7 +598,7 @@ function flot_custom_pie_chart ($flash_charts, $graph_values,
|
|||
|
||||
$graph_id = uniqid('graph_');
|
||||
|
||||
$return = "<div id='$graph_id' class='graph' style='width: ".$width."px; height: ".$height."px;'></div>";
|
||||
$return = "<div id='$graph_id' class='graph noresizevc' style='width: ".$width."px; height: ".$height."px;'></div>";
|
||||
|
||||
if ($water_mark != '') {
|
||||
$return .= "<div id='watermark_$graph_id' style='display:none; position:absolute;'><img id='watermark_image_$graph_id' src='".$water_mark["url"]."'></div>";
|
||||
|
|
|
@ -302,9 +302,8 @@ $ignored_params['refr'] = '';
|
|||
}
|
||||
});
|
||||
|
||||
$(".graph").each(function(){
|
||||
height = parseInt($(this).css("height")) - 30;
|
||||
|
||||
$(".graph:not([class~='noresizevc'])").each(function(){
|
||||
height = parseInt($(this).css("height")) - 30;
|
||||
$(this).css('height', height);
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in New Issue