[Rt-commit] rt branch, 4.4/configurable-chart-y-axis, created. rt-4.4.3-79-g33ebe2831
Craig Kaiser
craig at bestpractical.com
Fri Nov 30 10:55:07 EST 2018
The branch, 4.4/configurable-chart-y-axis has been created
at 33ebe2831cf373b2774b9485741435e4ff29ad3f (commit)
- Log -----------------------------------------------------------------
commit 33ebe2831cf373b2774b9485741435e4ff29ad3f
Author: Craig Kaiser <craig at bestpractical.com>
Date: Thu Nov 29 11:03:35 2018 -0500
Make the Y axis for charts Min and Max value configurable from web UI
diff --git a/share/html/Search/Chart b/share/html/Search/Chart
index f4d618ffb..3eaa34bbf 100644
--- a/share/html/Search/Chart
+++ b/share/html/Search/Chart
@@ -53,6 +53,8 @@ $ChartStyle => 'bar+table+sql'
@ChartFunction => 'COUNT'
$Width => undef
$Height => undef
+$ChartMax => undef
+$ChartMin => undef
</%args>
<%init>
use GD;
@@ -119,8 +121,8 @@ if ( $Cache and my $data = delete $session{'charts_cache'}{ $Cache } ) {
}
my @data = ([],[]);
-my $max_value = 0;
-my $min_value;
+my $max_value = $ChartMax || 0;
+my $min_value = $ChartMin;
my $max_key_length = 0;
while ( my $entry = $report->Next ) {
push @{ $data[0] }, [ map $entry->LabelValue( $_ ), @{ $columns{'Groups'} } ];
@@ -144,7 +146,7 @@ while ( my $entry = $report->Next ) {
foreach my $v ( @values ) {
$max_value = $v if $max_value < $v;
- $min_value = $v if !defined $min_value || $min_value > $v;
+ $min_value = $v if !$ChartMin && (!length $min_value || $min_value > $v);
}
}
diff --git a/share/html/Search/Chart.html b/share/html/Search/Chart.html
index 50266049b..6e550a304 100644
--- a/share/html/Search/Chart.html
+++ b/share/html/Search/Chart.html
@@ -217,6 +217,19 @@ jQuery(".chart-picture [name=ChartStyleIncludeTable]").change( updateChartStyle
jQuery(".chart-picture [name=ChartStyleIncludeSQL]").change( updateChartStyle );
</script>
+<&| /Widgets/TitleBox, title => loc('Chart Axis Options') &>
+<div class="chart-table">
+ <div class="chart-input-row">
+ <span class="label"><&|/l&>Chart Y Min Value</&>:</span>
+ <input class="chart-input" type="number" name="ChartMin" value="<% $ARGS{ChartMin} %>" />
+ </div>
+ <div class="chart-input-row">
+ <span class="label"><&|/l&>Chart Y Max Value</&>:</span>
+ <input class="chart-input" type="number" name="ChartMax" value="<% $ARGS{ChartMax} %>" />
+ </div>
+</div>
+</&>
+
<& /Elements/Submit, Label => loc('Update Chart'), Name => 'Update' &>
</form>
diff --git a/share/static/css/base/charts.css b/share/static/css/base/charts.css
index 31baf7cee..ca0336413 100644
--- a/share/static/css/base/charts.css
+++ b/share/static/css/base/charts.css
@@ -26,3 +26,17 @@
.chart-wrapper .collection-as-table tr th.oddline {
background: #ddd;
}
+
+.chart-table {
+ display: table;
+}
+.chart-input-row {
+ display: table-row;
+}
+
+.chart-input {
+ float: right;
+ display: table-cell;
+ margin: 0 0 5px 5px;
+ size: 50px;
+}
-----------------------------------------------------------------------
More information about the rt-commit
mailing list