@grafana/data#toCSV TypeScript Examples
The following examples show how to use
@grafana/data#toCSV.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PanelInspector.tsx From grafana-chinese with Apache License 2.0 | 6 votes |
exportCsv = (dataFrame: DataFrame) => {
const dataFrameCsv = toCSV([dataFrame]);
const blob = new Blob([dataFrameCsv], {
type: 'application/csv;charset=utf-8',
});
saveAs(blob, dataFrame.name + '-' + new Date().getUTCDate() + '.csv');
};
Example #2
Source File: InputQueryEditor.tsx From grafana-chinese with Apache License 2.0 | 6 votes |
onSourceChange = (item: SelectableValue<string>) => {
const { datasource, query, onChange, onRunQuery } = this.props;
let data: DataFrame[] | undefined = undefined;
if (item.value === 'panel') {
if (query.data) {
return;
}
data = [...datasource.data];
if (!data) {
data = [new MutableDataFrame()];
}
this.setState({ text: toCSV(data) });
}
onChange({ ...query, data });
onRunQuery();
};
Example #3
Source File: utils.ts From grafana-chinese with Apache License 2.0 | 6 votes |
export function dataFrameToCSV(dto?: DataFrameDTO[]) {
if (!dto || !dto.length) {
return '';
}
return toCSV(dto.map(v => toDataFrame(v)));
}