Evidence

repository·main·Indexed 11 days ago

https://github.com/evidence-dev/evidence

An open-source, code-based Business Intelligence tool that enables developers to create data-driven websites using SQL and Markdown. It provides a programmatic alternative to drag-and-drop BI tools and includes a VS Code extension, a CLI for project scaffolding, and various data adapters for BigQuery, CSV, Databricks, DuckDB, JavaScript, MSSQL, MySQL, Postgres, Redshift, Snowflake, SQLite, and Trino.

Tokens
240K
Snippets
924
Records
1.2K
Agent score
91%

What's inside Evidence

  1. Overview of Evidence components and libraries

    main

    Evidence is a library designed for creating reports using a combination of Markdown and SQL. It integrates several powerful underlying libraries to provide its core functionality:

    • Charts: Powered by ECharts.
    • Maps: Powered by Leaflet.
    • UI Components: Powered by Shadcn.

    Components are categorized into functional groups such as Data (for displaying metrics and tables) and Charts (for visual data representation).

  2. What is Evidence?

    main
    Evidence is an open source, code-driven framework for building data products using SQL. It serves as an alternative to drag-and-drop BI tools, allowing you to create reports, decision-support tools, and embedded dashboards. Instead of a GUI, you build your data products using markdown files containing SQL queries and components.
  3. Use the Redshift Adapter

    main

    The Redshift adapter allows Evidence to connect to Amazon Redshift data sources. It functions as a wrapper around the Postgres adapter, meaning connection configurations compatible with Postgres will generally work for Redshift.

    For detailed connection information and configuration requirements, refer to the official Evidence documentation on Redshift data sources: https://docs.evidence.dev/core-concepts/data-sources/#redshift

  4. Overview of Chart Annotations

    main

    Evidence provides four types of annotations to add context to charts, such as highlighting specific points, areas, or drawing lines. These can be defined using inline values or by providing a dataset.

    Available annotation types:

    • ReferenceLine: Draws a line (e.g., sales target, launch dates, or linear regression).
    • ReferenceArea: Highlights a specific area (e.g., holiday shopping periods or metric control ranges).
    • ReferencePoint: Highlights specific points (e.g., anomalies or points of interest).
    • Callout: Draws attention to data with text (e.g., explaining a trend).
    <LineChart data={orders_by_month} x=month y=sales yFmt=usd0>
        <ReferenceLine y=7500 label="Reference Line" hideValue labelPosition="aboveStart" color=positive/>
        <ReferenceArea xMin='2020-03-14' xMax='2020-08-15' label="Reference Area" color=warning/>
        <ReferencePoint x="2019-07-01" y=6590 label="Reference Point" labelPosition=bottom color=negative/>
        <Callout x="2021-05-01" y=11012 labelPosition=bottom labelWidth=fit>
            Callout
            Data trending up here
        </Callout>
    </LineChart>
  5. Use SQL format tags for reusable column formatting

    main

    You can define formats directly in your SQL by appending a format tag to the column name with an underscore. This ensures the column is formatted consistently across all components and tables.

    Syntax: column_name_tag (e.g., growth_pct for a column named growth).

    Rules:

    • Format tags are case-insensitive.
    • When creating tables, Evidence uses the tag to format the column title (e.g., customer_id becomes Customer ID, while growth_pct becomes Growth).
    • Formatting configuration is managed in the Value Formatting Section of Evidence Settings.
    -- Example of applying a percentage tag in SQL
    SELECT
        growth_pct
    FROM sales_data
  6. Use conditional logic with If/Else statements

    main

    You can programmatically control the visibility of content in your reports using {#if}, {:else if}, {:else}, and {/if} blocks. This is useful for managing information density or showing specific call-to-action messages only when certain data thresholds are met.

    Syntax structure:

    • {#if condition}: Starts the conditional block.
    • {:else if condition}: (Optional) Provides an alternative condition.
    • {:else}: (Optional) Provides a fallback if no previous conditions are met.
    • {/if}: Closes the conditional block.
    {#if condition}
    
    Display some content.
    
    {:else if another condition}
    
    Another thing instead.
    
    {:else }
    
    Something completely different.
    
    {/if}
  7. Configure Legend options for CalendarHeatmap

    main

    The <CalendarHeatmap /> component supports three legend modes via the legend and filter props:

    1. Default Legend: The standard legend display (set filter=false).
    2. No Legend: Completely hides the legend by setting legend={false}.
    3. Filter Legend: Enables interactive filtering by setting filter={true}.
    // No Legend
    <CalendarHeatmap
        data={oneyear}
        date=date
        value=orders
        legend={false}
        filter={false}
    />
    
    // Filter Legend
    <CalendarHeatmap
        data={oneyear}
        date=date
        value=orders
        filter={true}
    />
  8. Identify your role in the Evidence ecosystem

    main

    Evidence defines three distinct user roles based on how you interact with the tool:

    • Developers: Users who write JavaScript to create plugins, custom components, or customize application shells.
    • Authors: Users who create and maintain Evidence Projects (writing Markdown and SQL) without directly interacting with the SDK.
    • Viewers: End-users who consume the completed, built Evidence App.