mirror of https://github.com/grafana/grafana
MarketTrend: rename to candlestick panel (#41582)
parent
53905f2d4a
commit
1aac13e5d0
@ -0,0 +1,9 @@ |
|||||||
|
# Candlestick |
||||||
|
|
||||||
|
The candlestick panel shows a chart that is typically used to describe price movements of a security, derivative, or currency. |
||||||
|
|
||||||
|
This chart is **included** with Grafana. |
||||||
|
|
||||||
|
Read more about it here: |
||||||
|
|
||||||
|
[https://grafana.com/docs/grafana/latest/visualizations/candlestick/](https://grafana.com/docs/grafana/latest/visualizations/candlestick/) |
||||||
@ -1,11 +1,11 @@ |
|||||||
import { createTheme, toDataFrame } from '@grafana/data'; |
import { createTheme, toDataFrame } from '@grafana/data'; |
||||||
import { prepareCandlestickFields } from './fields'; |
import { prepareCandlestickFields } from './fields'; |
||||||
import { MarketOptions } from './models.gen'; |
import { CandlestickOptions } from './models.gen'; |
||||||
|
|
||||||
const theme = createTheme(); |
const theme = createTheme(); |
||||||
|
|
||||||
describe('Candlestick data', () => { |
describe('Candlestick data', () => { |
||||||
const options: MarketOptions = {} as MarketOptions; |
const options: CandlestickOptions = {} as CandlestickOptions; |
||||||
|
|
||||||
it('require a time field', () => { |
it('require a time field', () => { |
||||||
const info = prepareCandlestickFields( |
const info = prepareCandlestickFields( |
||||||
|
Before Width: | Height: | Size: 1.8 KiB After Width: | Height: | Size: 1.8 KiB |
@ -1,7 +1,7 @@ |
|||||||
{ |
{ |
||||||
"type": "panel", |
"type": "panel", |
||||||
"name": "Market trend", |
"name": "Candlestick", |
||||||
"id": "market-trend", |
"id": "candlestick", |
||||||
"state": "alpha", |
"state": "alpha", |
||||||
|
|
||||||
"info": { |
"info": { |
||||||
@ -0,0 +1,53 @@ |
|||||||
|
import { VisualizationSuggestionsBuilder } from '@grafana/data'; |
||||||
|
import { config } from '@grafana/runtime'; |
||||||
|
import { SuggestionName } from 'app/types/suggestions'; |
||||||
|
import { prepareCandlestickFields } from './fields'; |
||||||
|
import { CandlestickOptions, defaultPanelOptions } from './models.gen'; |
||||||
|
|
||||||
|
export class CandlestickSuggestionsSupplier { |
||||||
|
getSuggestionsForData(builder: VisualizationSuggestionsBuilder) { |
||||||
|
const { dataSummary } = builder; |
||||||
|
|
||||||
|
if ( |
||||||
|
!builder.data?.series || |
||||||
|
!dataSummary.hasData || |
||||||
|
dataSummary.timeFieldCount < 1 || |
||||||
|
dataSummary.numberFieldCount < 2 || |
||||||
|
dataSummary.numberFieldCount > 10 |
||||||
|
) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
const info = prepareCandlestickFields(builder.data.series, defaultPanelOptions, config.theme2); |
||||||
|
if (!info.open || info.warn || info.noTimeField) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
// Regular timeseries
|
||||||
|
if (info.open === info.high && info.open === info.low) { |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
const list = builder.getListAppender<CandlestickOptions, {}>({ |
||||||
|
name: '', |
||||||
|
pluginId: 'candlestick', |
||||||
|
options: {}, |
||||||
|
fieldConfig: { |
||||||
|
defaults: { |
||||||
|
custom: {}, |
||||||
|
}, |
||||||
|
overrides: [], |
||||||
|
}, |
||||||
|
previewModifier: (s) => {}, |
||||||
|
}); |
||||||
|
|
||||||
|
list.append({ |
||||||
|
name: SuggestionName.Candlestick, |
||||||
|
options: defaultPanelOptions, |
||||||
|
fieldConfig: { |
||||||
|
defaults: {}, |
||||||
|
overrides: [], |
||||||
|
}, |
||||||
|
}); |
||||||
|
} |
||||||
|
} |
||||||
Loading…
Reference in new issue