Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panel / Terms / Add log axis. #56

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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