Skip to content

Add bar chart plotting and creating traces from data #81

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

Open
wants to merge 20 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,24 @@ Works with grafana 4, 5, and 6
![Screenshot of scatter plot](https://raw.githubusercontent.com/NatelEnergy/grafana-plotly-panel/master/src/img/screenshot-multiple-trace.png)
![Screenshot of 3d scatter plot](https://raw.githubusercontent.com/NatelEnergy/grafana-plotly-panel/master/src/img/screenshot-scatter-3d.png)
![Screenshot of the options screen](https://raw.githubusercontent.com/NatelEnergy/grafana-plotly-panel/master/src/img/screenshot-options-new.png)
![Screenshot of horizontal bar chart](https://raw.githubusercontent.com/NatelEnergy/grafana-plotly-panel/master/src/img/screenshot-hbar-single-trace.png)
![Screenshot of horizontal bar chart](https://raw.githubusercontent.com/NatelEnergy/grafana-plotly-panel/master/src/img/screenshot-hbar-multi-trace.png)
![Screenshot of stacked vertical bar chart](https://raw.githubusercontent.com/NatelEnergy/grafana-plotly-panel/master/src/img/screenshot-vbar-stacked-auto-trace.png)

### Auto-trace

Sometimes the number and identity of the traces on a plot varies depending
on a property of the data being plotted. Auto-trace mode allows traces
to be constructed from the query result. The query must return exactly
3 columns. The column contents must be:

1. The trace name. This must be a string.
1. An X value for the named trace.
1. The corresponding Y value.

### Building

To complie, run:
To compile, run:

```
npm install -g yarn
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"name": "natel-plotly-panel",
"name": "sinodun-natel-plotly-panel",
"version": "0.0.7-dev",
"description": "Plot.ly Panel Plugin for Grafana",
"scripts": {
Expand Down
2 changes: 1 addition & 1 deletion src/SeriesWrapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ export class SeriesWrapperTable extends SeriesWrapper {

const col = table.columns[index];
if (!col) {
throw new Error('Unkonwn Column: ' + index);
throw new Error('Unknown Column: ' + index);
}

this.name = col.text;
Expand Down
Binary file added src/img/screenshot-hbar-multi-trace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/screenshot-hbar-single-trace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/img/screenshot-vbar-stacked-auto-trace.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 4 additions & 4 deletions src/libLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ export function loadPlotly(cfg: any): Promise<any> {
return Promise.resolve(loaded);
}

const needsFull = cfg.settings.type !== 'scatter';
let url = 'public/plugins/natel-plotly-panel/lib/plotly-cartesian.min.js';
const needsFull = cfg.settings.type === 'scatter3d';
let url = 'public/plugins/sinodun-natel-plotly-panel/lib/plotly-cartesian.min.js';
if (cfg.loadFromCDN) {
url = needsFull
? 'https://cdn.plot.ly/plotly-latest.min.js'
: 'https://cdn.plot.ly/plotly-cartesian-latest.min.js';
} else if (needsFull) {
url = 'public/plugins/natel-plotly-panel/lib/plotly.min.js';
url = 'public/plugins/sinodun-natel-plotly-panel/lib/plotly.min.js';
}
return new Promise((resolve, reject) => {
$script(url, resolve);
Expand All @@ -40,7 +40,7 @@ export function loadIfNecessary(cfg: any): Promise<any> {
return loadPlotly(cfg);
}

const needsFull = cfg.settings.type !== 'scatter';
const needsFull = cfg.settings.type === 'scatter3d';
if (needsFull && !isFull) {
console.log('Switching to the full plotly library');
loaded = null;
Expand Down
Loading