RAWGraphs Documentation

repository·master·Indexed 27 days ago

https://github.com/rawgraphs/rawgraphs-app

An open-source web application for creating custom vector-based visualizations from tabular data using d3.js. It serves as a bridge between spreadsheet applications and vector graphics editors, processing data locally in the browser to generate SVG outputs. The tool supports various data separators, multiple locales for time formatting, and provides utilities for parsing JSON, CSV, and SPARQL data.

Tokens
3.1K
Snippets
8
Records
15
Agent score
94%

What's inside RAWGraphs

  1. Overview of RAWGraphs capabilities

    master

    RAWGraphs is an open web tool for creating custom vector-based visualizations using the d3.js library.

    Key Features:

    • Data Input: Works with tabular data (spreadsheets, CSV) or copied-and-pasted text.
    • Output: Generates SVG-based visualizations that can be edited in vector graphics editors (e.g., Inkscape, Adobe Illustrator) or embedded in web pages.
    • Privacy: Data is processed locally in the web browser; no server-side storage or operations are performed.
    • Extensibility: Supports custom layouts defined by users.
  2. Install and run RAWGraphs locally

    master

    To run an instance of RAWGraphs on your local machine, follow these steps:

    1. Ensure Requirements are met:

    2. Clone the repository:

      git clone https://github.com/rawgraphs/rawgraphs-app.git
      cd rawgraphs-app
    3. Install dependencies:

      yarn install
    4. Set OpenSSL environment variable: If you encounter OpenSSL issues, ensure you are using the legacy provider:

      export NODE_OPTIONS=--openssl-legacy-provider
    5. Run in development mode:

      yarn start
    git clone https://github.com/rawgraphs/rawgraphs-app.git
    cd rawgraphs-app
    yarn install
    export NODE_OPTIONS=--openssl-legacy-provider
    yarn start
  3. Deserialize a project state with deserializeProject()

    master

    Use deserializeProject to reconstruct a RAWGraphs project state from a serialized JSON object.

    Requirements:

    • The input object must have a version property equal to `
  4. Cite RAWGraphs in research

    master

    If using RAWGraphs in research, please cite the following paper:

    Mauri, M., Elli, T., Caviglia, G., Uboldi, G., & Azzi, M. (2017). RAWGraphs: A Visualisation Platform to Create Open Outputs. In Proceedings of the 12th Biannual Conference on Italian SIGCHI Chapter (p. 28:1–28:5). New York, NY, USA: ACM. https://doi.org/10.1145/3125571.3125585

    Bibtex:

    @inproceedings{Mauri:2017:RVP:3125571.3125585,
     author = {Mauri, Michele and Elli, Tommaso and Caviglia, Giorgio and Uboldi, Giorgio and Azzi, Matteo},
     title = {RAWGraphs: A Visualisation Platform to Create Open Outputs},
     booktitle = {Proceedings of the 12th Biannual Conference on Italian SIGCHI Chapter},
     series = {CHItaly '17},
     year = {2017},
     isbn = {978-1-4503-5237-6},
     location = {Cagliari, Italy},
     pages = {28:1--28:5},
     articleno = {28},
     numpages = {5},
     url = {http://doi.acm.org/10.1145/3125571.3125585},
     doi = {10.1145/3125571.3125585},
     acmid = {3125585},
     publisher = {ACM},
     address = {New York, NY, USA},
     keywords = {Visualization tools, data visualization, open output, visual interface},
    }
  5. Parse datasets off-main-thread with parseDatasetInWorker

    master
    Use parseDatasetInWorker to perform data parsing tasks in a Web Worker to avoid blocking the main UI thread. This function lazily initializes a parsing worker and uses Comlink to proxy the parseDataset method. It accepts the raw data, the expected data types, and specific parsing options.
  6. Serialize a project state with serializeProject()

    master

    Use serializeProject to convert the current application state into a JSON-compatible object for exporting. This function captures user input, parsed data, data types, and chart-specific configurations (mapping and visual options).

    // Note: This is a conceptual usage based on the function signature
    const projectJson = serializeProject(
      userInput,
      userData,
      userDataType,
      parseError,
      unstackedData,
      unstackedColumns,
      data,
      separator,
      thousandsSeparator,
      decimalsSeparator,
      locale,
      stackDimension,
      dataSource,
      currentChart,
      mapping,
      visualOptions
    );
  7. Parse and validate data with parseAndCheckData

    master

    The parseAndCheckData function is a wrapper around parseData that includes validation logic to ensure the resulting dataset is usable. It is specifically designed to handle errors and empty datasets gracefully.

    Returns an array containing:

    1. dataType: The identified format ('json', 'csv', or null).
    2. data: The parsed data.
    3. error: An error message string if parsing failed or the data is empty, otherwise null.
    4. extra: An object containing metadata (e.g., the detected separator for CSV).
  8. Parse tabular data with parseData

    master

    The parseData function attempts to identify and parse a data string into one of the supported formats: sparql, json, or csv. It iterates through available parsers and returns the first successful result.

    Returns an array containing:

    1. dataType: The identified format ('sparql', 'json', or 'csv'), or null if parsing fails.
    2. parsed: The parsed data structure.
    3. extra: An object containing metadata (e.g., the detected separator for CSV).
  9. Normalize JSON arrays with normalizeJsonArray

    master

    The normalizeJsonArray function transforms a JSON array into a flattened object structure suitable for tabular visualization. It handles several edge cases:

    • Arrays within elements: Converts arrays into space-separated strings of scalar values.
    • Nested objects: Flattens one level of nesting using dot notation (e.g., { a: { b: 1 } } becomes { 'a.b': 1 }).
    • Arrays of arrays: Converts them into objects with keys like Column 1, Column 2, etc.
    • Scalar values: Wraps them in an object with a value key.

    It only preserves scalar types (string, number, boolean) or null values.

  10. Map data to visual elements with mapDataInWorker

    master
    Use mapDataInWorker to perform data mapping (transforming data into visual coordinates/attributes) in a Web Worker. This function lazily initializes a mapping worker and uses Comlink to proxy the mapData method. It requires the chartName and a configuration object containing data, mapping, visualOptions, and dataTypes. An optional customChart parameter can be provided.
  11. Reference aggregation, scale, and color scheme labels

    master

    The following labels are used for UI display of aggregations, scales, and color schemes:

    Aggregations (AGGREGATIONS_LABELS):

    • count: Count
    • mean: Average
    • median: Median
    • max: Max
    • min: Min
    • countDistinct: Count unique
    • sum: Sum
    • csv: CSV
    • csvDistinct: CSV (unique)

    Scales (SCALES_LABELS):

    • sequential: Sequential
    • diverging: Diverging
    • ordinal: Ordinal

    Color Schemes (COLOR_SCHEMES_LABELS):

    • interpolateBlues: Blue sequential
    • interpolateGreens: Green sequential
    • interpolateReds: Red sequential
    • interpolateRdBu: RdBu diverging
    • interpolateBrBG: BrBG diverging
    • interpolatePiYG: PiYG diverging
    • schemeCategory10: Categorical 10
    • interpolateTurbo: Turbo discrete
    • interpolateSpectral: Spectral discrete
    export const AGGREGATIONS_LABELS = {
      "count": "Count",
      "mean": "Average",
      "median": "Median",
      "max": "Max",
      "min": "Min",
      "countDistinct": "Count unique",
      "sum": "Sum",
      "csv": "CSV",
      "csvDistinct": "CSV (unique)",
    }
    
    export const SCALES_LABELS = {
      "sequential": "Sequential",
      "diverging": "Diverging",
      "ordinal": "Ordinal"
    }
    
    export const COLOR_SCHEMES_LABELS = {
      "interpolateBlues": "Blue sequential",
      "interpolateGreens": "Green sequential",
      "interpolateReds": "Red sequential",
      "interpolateRdBu": "RdBu diverging",
      "interpolateBrBG": "BrBG diverging",
      "interpolatePiYG": "PiYG diverging",
      "schemeCategory10": "Categorical 10",
      "interpolateTurbo": "Turbo discrete",
      "interpolateSpectral": "Spectral discrete"
    }