The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
grafana/public/app/plugins/panel/graph3/module.tsx

208 lines
6.0 KiB

FieldColor: Adds new standard color option for color (#28039) * FieldColor: Added field color option * Progress * FieldColor: Added custom schemes * move to fieldColor * move to fieldColor * add back the standard color picker * FieldColor: Added registry for field color modes * wip refactor * Seperate scale from color mode * Progress * schemes working * Stuff is working * Added fallback * Updated threshold tests * Added unit tests * added more tests * Made it work with new graph panel * Use scale calculator from graph panel * Updates * Updated test * Renaming things * Update packages/grafana-data/src/field/displayProcessor.ts Co-authored-by: Ryan McKinley <ryantxu@gmail.com> * updated according to feedback, added docs * Updated docs * Updated * Update docs/sources/panels/field-options/standard-field-options.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update docs/sources/panels/field-options/standard-field-options.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Updated docs according to feedback * fixed test * Updated * Updated wording * Change to fieldState.seriesIndex * Updated tests * Updates * New names * More work needed to support bar gauge and showing the color modes in the picker * Now correct gradients work in bar gauge * before rename * Unifying the concept * Updates * review feedback * Updated * Skip minification * Updated * UI improvements Co-authored-by: Ryan McKinley <ryantxu@gmail.com> Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
5 years ago
import { FieldConfigProperty, PanelPlugin } from '@grafana/data';
import { GraphCustomFieldConfig } from '@grafana/ui';
import { GraphPanel } from './GraphPanel';
import { Options } from './types';
export const plugin = new PanelPlugin<Options, GraphCustomFieldConfig>(GraphPanel)
.useFieldConfig({
standardOptions: [
// FieldConfigProperty.Min,
// FieldConfigProperty.Max,
FieldColor: Adds new standard color option for color (#28039) * FieldColor: Added field color option * Progress * FieldColor: Added custom schemes * move to fieldColor * move to fieldColor * add back the standard color picker * FieldColor: Added registry for field color modes * wip refactor * Seperate scale from color mode * Progress * schemes working * Stuff is working * Added fallback * Updated threshold tests * Added unit tests * added more tests * Made it work with new graph panel * Use scale calculator from graph panel * Updates * Updated test * Renaming things * Update packages/grafana-data/src/field/displayProcessor.ts Co-authored-by: Ryan McKinley <ryantxu@gmail.com> * updated according to feedback, added docs * Updated docs * Updated * Update docs/sources/panels/field-options/standard-field-options.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Update docs/sources/panels/field-options/standard-field-options.md Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com> * Updated docs according to feedback * fixed test * Updated * Updated wording * Change to fieldState.seriesIndex * Updated tests * Updates * New names * More work needed to support bar gauge and showing the color modes in the picker * Now correct gradients work in bar gauge * before rename * Unifying the concept * Updates * review feedback * Updated * Skip minification * Updated * UI improvements Co-authored-by: Ryan McKinley <ryantxu@gmail.com> Co-authored-by: Diana Payton <52059945+oddlittlebird@users.noreply.github.com>
5 years ago
FieldConfigProperty.Color,
FieldConfigProperty.Unit,
FieldConfigProperty.DisplayName,
FieldConfigProperty.Decimals,
// NOT: FieldConfigProperty.Thresholds,
FieldConfigProperty.Mappings,
],
useCustomConfig: builder => {
builder
.addBooleanSwitch({
path: 'line.show',
name: 'Show lines',
description: '',
defaultValue: true,
})
.addSelect({
path: 'line.width',
name: 'Line width',
defaultValue: 1,
settings: {
options: [
{ value: 1, label: '1 • thin' },
{ value: 2, label: '2' },
{ value: 3, label: '3' },
{ value: 4, label: '4' },
{ value: 5, label: '5' },
{ value: 6, label: '6' },
{ value: 7, label: '7' },
{ value: 8, label: '8' },
{ value: 9, label: '9' },
{ value: 10, label: '10 • thick' },
],
},
showIf: c => {
return c.line.show;
},
})
.addBooleanSwitch({
path: 'points.show',
name: 'Show points',
description: '',
defaultValue: false,
})
.addSelect({
path: 'points.radius',
name: 'Point radius',
defaultValue: 4,
settings: {
options: [
{ value: 1, label: '1 • thin' },
{ value: 2, label: '2' },
{ value: 3, label: '3' },
{ value: 4, label: '4' },
{ value: 5, label: '5' },
{ value: 6, label: '6' },
{ value: 7, label: '7' },
{ value: 8, label: '8' },
{ value: 9, label: '9' },
{ value: 10, label: '10 • thick' },
],
},
showIf: c => c.points.show,
})
.addBooleanSwitch({
path: 'bars.show',
name: 'Show bars',
description: '',
defaultValue: false,
})
.addSelect({
path: 'fill.alpha',
name: 'Fill area opacity',
defaultValue: 0.1,
settings: {
options: [
{ value: 0, label: 'No Fill' },
{ value: 0.1, label: '10% • transparent' },
{ value: 0.2, label: '20%' },
{ value: 0.3, label: '30%' },
{ value: 0.4, label: '40% ' },
{ value: 0.5, label: '50%' },
{ value: 0.6, label: '60%' },
{ value: 0.7, label: '70%' },
{ value: 0.8, label: '80%' },
{ value: 0.9, label: '90%' },
{ value: 1, label: '100% • opaque' },
],
},
})
.addTextInput({
path: 'axis.label',
name: 'Axis Label',
category: ['Axis'],
defaultValue: '',
settings: {
placeholder: 'Optional text',
},
// no matter what the field type is
shouldApply: () => true,
})
.addRadio({
path: 'axis.side',
name: 'Y axis side',
category: ['Axis'],
defaultValue: 3,
settings: {
options: [
{ value: 3, label: 'Left' },
{ value: 1, label: 'Right' },
],
},
})
.addNumberInput({
path: 'axis.width',
name: 'Y axis width',
category: ['Axis'],
defaultValue: 60,
settings: {
placeholder: '60',
},
})
.addBooleanSwitch({
path: 'axis.grid',
name: 'Show axis grid',
category: ['Axis'],
description: '',
defaultValue: true,
})
.addRadio({
path: 'nullValues',
name: 'Display null values as',
description: '',
defaultValue: 'null',
settings: {
options: [
{ value: 'null', label: 'null' },
{ value: 'connected', label: 'Connected' },
{ value: 'asZero', label: 'Zero' },
],
},
});
},
})
.setPanelOptions(builder => {
builder
.addRadio({
path: 'tooltipOptions.mode',
name: 'Tooltip mode',
description: '',
defaultValue: 'single',
settings: {
options: [
{ value: 'single', label: 'Single series' },
{ value: 'multi', label: 'All series' },
{ value: 'none', label: 'No tooltip' },
],
},
})
// .addBooleanSwitch({
// path: 'graph.realTimeUpdates',
// name: 'Real time updates',
// description: 'continue to update the graph so the time axis matches the clock.',
// defaultValue: false,
// })
.addBooleanSwitch({
category: ['Legend'],
path: 'legend.isVisible',
name: 'Show legend',
description: '',
defaultValue: true,
})
.addBooleanSwitch({
category: ['Legend'],
path: 'legend.asTable',
name: 'Display legend as table',
description: '',
defaultValue: false,
showIf: c => c.legend.isVisible,
})
.addRadio({
category: ['Legend'],
path: 'legend.placement',
name: 'Legend placement',
description: '',
defaultValue: 'bottom',
settings: {
options: [
{ value: 'left', label: 'Left' },
{ value: 'top', label: 'Top' },
{ value: 'bottom', label: 'Bottom' },
{ value: 'right', label: 'Right' },
],
},
showIf: c => c.legend.isVisible,
});
});