Skip to content

Commit

Permalink
Panel / Terms / Add log axis.
Browse files Browse the repository at this point in the history
  • Loading branch information
François Prunayre committed Oct 21, 2014
1 parent 5fe408f commit 26a50ea
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
3 changes: 3 additions & 0 deletions src/app/panels/terms/editor.html
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
<div class="span1" ng-show="panel.chart == 'pie'">
<label class="small">Labels</label><input type="checkbox" ng-model="panel.labels" ng-checked="panel.labels">
</div>
<div class="span1" ng-show="panel.chart == 'bar'">
<label class="small">Log axis</label><input type="checkbox" ng-model="panel.logAxis" ng-checked="panel.logAxis">
</div>
</div>
<div class="row-fluid">
<div class="span2">
Expand Down
35 changes: 32 additions & 3 deletions src/app/panels/terms/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ function (angular, app, _, $, kbn) {
donut : false,
tilt : false,
labels : true,
logAxis : false,
arrangement : 'horizontal',
chart : 'bar',
counter_pos : 'above',
Expand Down Expand Up @@ -318,15 +319,43 @@ function (angular, app, _, $, kbn) {
try {
// Add plot to scope so we can build out own legend
if(scope.panel.chart === 'bar') {

var yAxisConfig = {
show: true,
min: scope.yaxis_min,
color: "#c8c8c8"
};
if (scope.panel.logAxis) {
_.defaults(yAxisConfig, {
ticks: function (axis) {
var res = [], i = 1,
ticksNumber = 8,
max = axis.max === 0 ? 0 : Math.log(axis.max),
min = axis.min === 0 ? 0 : Math.log(axis.min),
interval = (max - min) / ticksNumber;
do {
var v = interval * i;
res.push(Math.exp(v));
++i;
} while (v < max);
return res;
},
transform: function (v) {
return v === 0 ? 0 : Math.log(v); },
inverseTransform: function (v) {
return v === 0 ? 0 : Math.exp(v); }
});
}

plot = $.plot(elem, chartData, {
legend: { show: false },
series: {
lines: { show: false, },
lines: { show: false },
bars: { show: true, fill: 1, barWidth: 0.8, horizontal: false },
shadowSize: 1
},
// yaxis: { show: true, min: 0, color: "#c8c8c8" },
yaxis: { show: true, min: scope.yaxis_min, color: "#c8c8c8" },
yaxis: yAxisConfig,
xaxis: { show: false },
grid: {
borderWidth: 0,
Expand Down Expand Up @@ -354,7 +383,7 @@ function (angular, app, _, $, kbn) {

plot = $.plot(elem, chartData, {
legend: {
show: false,
show: false
// position: position,
// backgroundColor: "transparent"
},
Expand Down

2 comments on commit 26a50ea

@aadel
Copy link
Contributor

@aadel aadel commented on 26a50ea Oct 21, 2014

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the contribution!

@fxprunayre
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're welcome ! I'm quite new to banana, but I will look into some improvements like logAxis, color palette for maps, i18n for the interface, ... (if you're interested in).

Please sign in to comment.