Draw charts from Azure Data Explorer queries
Перейти к файлу
Violet Voronetzky 587fc2ffbb Deleted temp code 2019-12-01 17:08:34 +02:00
.vscode Initial release 2019-11-10 18:08:31 +02:00
definitelyTyped Initial release 2019-11-10 18:08:31 +02:00
src Added UT for getValidDate 2019-12-01 17:05:18 +02:00
test Deleted temp code 2019-12-01 17:08:34 +02:00
.gitignore Initial release 2019-11-10 18:08:31 +02:00
.travis.yml Add Travis + badge 2019-11-11 09:06:59 +02:00
CODE_OF_CONDUCT.md Update to MS Code Of Conduct + MIT lisence 2019-11-11 14:45:49 +02:00
LICENSE Updating LICENSE to template content 2019-11-10 07:38:22 -08:00
README.md PR modifications 2019-12-01 15:19:18 +02:00
SECURITY.md Initial SECURITY.md commit 2019-11-10 07:38:25 -08:00
index.ts Added highcharts visualizer and data transformations 2019-12-01 10:19:14 +02:00
launch.json Initial release 2019-11-10 18:08:31 +02:00
package-lock.json Added highcharts visualizer and data transformations 2019-12-01 10:19:14 +02:00
package.json Added highcharts visualizer and data transformations 2019-12-01 10:19:14 +02:00
tasks.json Initial release 2019-11-10 18:08:31 +02:00
tsconfig.json Initial release 2019-11-10 18:08:31 +02:00

README.md

This package is a work in process. Please DO NOT USE it yet

query-data-to-chart-private

Build Status    npm version

Draw charts from Azure Data Explorer queries

Installation

npm install adx-query-charts

Dependencies

Make sure to install the following packages before using the adx-query-charts library:

  1. moment: npm i moment
  2. lodash: npm i lodash
  3. highcharts: npm i highcharts

Usage

import * as Charts from 'adx-query-charts';

const highchartsVisualizer = new Charts.HighchartsVisualizer();
const chartHelper = chartHelper = new Charts.KustoChartHelper('chart-elem-id', highchartsVisualizer);
const chartOptions: Charts.IChartOptions = {
    chartType: Charts.ChartType.Column,
    columnsSelection: {
        xAxis: { name: 'timestamp', type: Charts.DraftColumnType.DateTime },
        yAxes: [{ name: 'requestCount', type: Charts.DraftColumnType.Int }]
    }
};

// Draw the chart - the chart will be drawn inside an element with 'chart-elem-id' id
chartHelper.draw(queryResultData, chartOptions);

API

IChartOptions

Option name: Type: Details: Default value:
chartType ChartType Mandatory.
The type of the chart to draw
columnsSelection IColumnsSelection The columns selection for the Axes and the split-by of the chart If not provided, default columns will be selected.
See: getDefaultSelection method
maxUniqueXValues number The maximum number of the unique X-axis values.
The chart will show the biggest values, and the rest will be aggregated to a separate data point.
100
exceedMaxDataPointLabel string The label of the data point that contains the aggregated value of all the X-axis values that exceed the 'maxUniqueXValues'. 'OTHER'
aggregationType AggregationType Multiple rows with the same values for the X-axis and the split-by will be aggregated using a function of this type.
For example, assume we get the following query result data:
['2016-08-02T10:00:00Z', 'Chrome 51.0', 15],
['2016-08-02T10:00:00Z', 'Internet Explorer 9.0', 4]
When drawing a chart with columnsSelection = { xAxis: timestamp, yAxes: count_ }, and aggregationType = AggregationType.Sum we need to aggregate the values of the same timestamp value and return one row with ["2016-08-02T10:00:00Z", 19]
AggregationType.Sum
utcOffset number The desired offset from UTC in hours for date values. Used to handle timezone.
The offset will be added to the original date from the query results data.
For example:
For 'Africa/Harare'timezone provide utcOffset = 2 and the displayed date will be be:
'11/25/2019, 2:00 AM' instead of '11/25/2019, 12:00 AM'
See time zone [info](https://msdn.microsoft.com/en-us/library/ms912391(v=winembedded.11)
0

ChartType

export enum ChartType {
    Line = 'Line',
    Scatter = 'Scatter',
    Area = 'Area',
    StackedArea = 'StackedArea',
    PercentageArea = 'PercentageArea',
    Column = 'Column',
    StackedColumn = 'StackedColumn',
    PercentageColumn = 'PercentageColumn',
    Pie = 'Pie',
    Donut = 'Donut',
}

IColumnsSelection


export interface IColumn {
    name: string;
    type: DraftColumnType;
}

export interface IColumnsSelection {
    xAxis: IColumn;
    yAxes: IColumn[];
    splitBy?: IColumn[];
}

AggregationType


export enum AggregationType {
    Sum = 'Sum',
    Average = 'Average',
    Min = 'Min',
    Max = 'Max'
}

Test

Unit tests are written using Jest.

Run tests: npm run test

Contributing

This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.

When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.

This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.