# Report

The QuillReport type, a saved report as useDashboard, useReport and Chart use it.

`useDashboard` gives each section's reports as `QuillReport`s, `useReport`
gives its report as `chart`, and `Chart` draws one.

```ts
import type { QuillReport } from "@quillsql/react";

interface QuillReport {
  /** The report's unique id. */
  id: string;

  /** The name of the report. */
  name: string;

  /** The name of the dashboard this report belongs to. */
  dashboardName: string;

  /** The rows of data returned from this report's query. */
  rows: { [key: string]: string }[];

  /** The columns data returned from this report's query. */
  columns: Column[];

  /** The type of this chart. */
  chartType: string;

  /** Whether to show a legend for this chart. */
  showLegend?: boolean;

  /** The chart's own order, after the query: a value of useReport's `chartSortOptions`, `''` for none. */
  chartSort?: string;

  /** The table and field this report uses for date filtering, if any. */
  dateField?: { table: string; field: string };

  /** The pivot used in this query, if any. */
  pivot: Pivot | null;

  /** The label of the xAxis. */
  xAxisLabel: string;

  /** The field to use for this report's xAxis. */
  xAxisField: string;

  /** The format for this report's xAxis. */
  xAxisFormat: AxisFormat;

  /** The template flag for a report */
  template?: boolean;

  /** A list of metadata about the yAxes of this report. */
  yAxisFields: {
    /** The field for this yAxis. */
    field: string;

    /** The label to use for this yAxis. */
    label: string;

    /** The format of the data in this yAxis. */
    format: AxisFormat;
  }[];

  /**
   * The relative ordering of this report in relation to its siblings. Ordering
   * starts at 1 and counts up (eg. 1, 2, 3, etc.).
   *
   * Also note that reports in the same section are first grouped by `chartType`
   * and then each group is sorted by `order`. Currently, the first group is the
   * `metric` reports and the last group is the `table` reports with the rest of
   * the reports in between.
   */
  order: number;

  /**
   * The rows of data returned from this report's query over the comparison date
   * range as opposed to the primary date range.
   */
  compareRows: { [key: string]: string }[];

  /** An array filters that have been applied to this query. */
  filtersApplied?: InternalFilter[];

  /** A page prop used for smart table pagination */
  pagination?: Pagination;

  /** A sort prop used for smart table pagination */
  sort?: { field: string; direction: string };

  /** A total row count used for SQL pagination */
  rowCount: number;

  /** A query for the report used by the report builder on initial load of report */
  queryString: string;

  /** Saved virtual queries used as this report's datasources. */
  virtualQueries?: string[];

  /** A map of dashboard filters to the appropriate table and field for the report */
  filterMap?: { [key: string]: { table: string; field: string } };

  /** A list of reference lines to render on compatible charts */
  referenceLines?: { label: string; query: [number, number] | string }[];

  /** Resolved reference line y values */
  referenceLineYValues?: { label: string; query: [number, number] }[];

  /** A flag to determine whether to automatically display custom fields */
  includeCustomFields?: boolean;

  /** Columns with custom fields */
  columnsWithCustomFields?: Column[];

  /** The pivot row info. */
  pivotRows?: { [key: string]: string }[];

  /** Row field name returned by the pivot query after backend disambiguation. */
  pivotResultRowField?: string;

  /** Logical row field used to request pivotResultRowField. */
  pivotResultSourceRowField?: string;

  /** A list of metadata about the pivot yAxes of this report. */
  pivotColumns?: ColumnInternal[];

  /** Total pivot row count */
  pivotRowCount?: number;
}
```
