Convert Figma logo to code with AI

graffle-js logograffle

Simple GraphQL Client for JavaScript. Minimal. Extensible. Type Safe. Runs everywhere.

6,085
310
6,085
42

Top Related Projects

112,114

Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:

83,989

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown

18,031

Open-source JavaScript charting library behind Plotly and Dash

Graph theory (network) library for visualisation and analysis

5,365

Directed graph layout for JavaScript

:dizzy: Display dynamic, automatically organised, customizable network views.

Quick Overview

Graffle is a JavaScript library for creating interactive and customizable graphs and charts. It provides a flexible API for building various types of visualizations, including line charts, bar charts, scatter plots, and more. Graffle aims to simplify the process of creating data visualizations for web applications.

Pros

  • Highly customizable with a wide range of options for styling and interactivity
  • Supports multiple chart types and can be extended with custom chart implementations
  • Lightweight and performant, suitable for both small and large datasets
  • Responsive design, adapting to different screen sizes and devices

Cons

  • Limited documentation and examples compared to more established charting libraries
  • Smaller community and ecosystem compared to popular alternatives like D3.js or Chart.js
  • May require more setup and configuration for complex visualizations
  • Limited built-in animations and transitions

Code Examples

Creating a simple line chart:

const data = [
  { x: 1, y: 10 },
  { x: 2, y: 15 },
  { x: 3, y: 13 },
  { x: 4, y: 17 }
];

const chart = new Graffle.LineChart('#chart-container', {
  data: data,
  xAxis: { label: 'X Axis' },
  yAxis: { label: 'Y Axis' }
});

chart.render();

Customizing a bar chart with colors and tooltips:

const barChart = new Graffle.BarChart('#bar-chart', {
  data: salesData,
  colors: ['#3366cc', '#dc3912', '#ff9900'],
  tooltip: {
    formatter: (d) => `Sales: $${d.value}`
  }
});

barChart.render();

Creating an interactive scatter plot:

const scatterPlot = new Graffle.ScatterPlot('#scatter-container', {
  data: populationData,
  xAxis: { label: 'Population' },
  yAxis: { label: 'GDP' },
  pointSize: 5,
  onPointClick: (point) => {
    console.log(`Clicked point: ${point.x}, ${point.y}`);
  }
});

scatterPlot.render();

Getting Started

To use Graffle in your project, follow these steps:

  1. Install Graffle via npm:

    npm install graffle
    
  2. Import Graffle in your JavaScript file:

    import { LineChart } from 'graffle';
    
  3. Create a container element in your HTML:

    <div id="chart-container"></div>
    
  4. Initialize and render a chart:

    const chart = new LineChart('#chart-container', {
      data: yourData,
      // Add other configuration options here
    });
    chart.render();
    

For more advanced usage and configuration options, refer to the Graffle documentation.

Competitor Comparisons

112,114

Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:

Pros of D3

  • Extensive and powerful library with a wide range of visualization capabilities
  • Large community and ecosystem with numerous examples and resources
  • Fine-grained control over every aspect of data visualization

Cons of D3

  • Steeper learning curve due to its low-level nature and complexity
  • Requires more code to create basic visualizations compared to higher-level libraries
  • Performance can be an issue with large datasets or complex visualizations

Code Comparison

D3:

const svg = d3.select("body").append("svg")
    .attr("width", 400)
    .attr("height", 300);

svg.selectAll("circle")
    .data(data)
    .enter().append("circle")
    .attr("cx", d => d.x)
    .attr("cy", d => d.y)
    .attr("r", 5);

Graffle:

const chart = new Graffle.Chart({
    element: "#chart",
    width: 400,
    height: 300
});

chart.scatter(data, {
    x: "x",
    y: "y"
});

D3 offers more flexibility but requires more code, while Graffle provides a higher-level API for quicker implementation of common chart types. D3 is better suited for custom, complex visualizations, whereas Graffle is more appropriate for rapid development of standard charts with less customization.

83,989

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown

Pros of Mermaid

  • More mature and widely adopted project with a larger community
  • Supports a broader range of diagram types (e.g., flowcharts, sequence diagrams, Gantt charts)
  • Better documentation and examples available

Cons of Mermaid

  • Steeper learning curve due to its more complex syntax
  • Limited customization options for diagram styling
  • Larger file size and potentially slower rendering for complex diagrams

Code Comparison

Mermaid:

graph TD
    A[Start] --> B{Is it?}
    B -->|Yes| C[OK]
    B -->|No| D[End]

Graffle:

digraph {
    A [label="Start"]
    B [label="Is it?", shape=diamond]
    C [label="OK"]
    D [label="End"]
    A -> B
    B -> C [label="Yes"]
    B -> D [label="No"]
}

Both libraries aim to create diagrams using text-based descriptions, but Mermaid uses a custom syntax while Graffle follows the DOT language. Mermaid's syntax is more concise and easier to read for simple diagrams, while Graffle's DOT-based approach offers more flexibility for complex graph structures.

18,031

Open-source JavaScript charting library behind Plotly and Dash

Pros of Plotly.js

  • More comprehensive and feature-rich library with a wide range of chart types
  • Extensive documentation and community support
  • Interactive and customizable charts with built-in animations

Cons of Plotly.js

  • Larger file size and potentially slower load times
  • Steeper learning curve due to its extensive API
  • May be overkill for simple visualization needs

Code Comparison

Plotly.js:

Plotly.newPlot('myDiv', [{
  x: [1, 2, 3, 4],
  y: [10, 15, 13, 17],
  type: 'scatter'
}]);

Graffle:

const chart = new Graffle.Chart();
chart.line([1, 2, 3, 4], [10, 15, 13, 17]);
chart.render('#myDiv');

Summary

Plotly.js offers a more comprehensive solution for data visualization with a wide range of chart types and interactive features. It has extensive documentation and community support, making it suitable for complex projects. However, its large file size and steep learning curve may be drawbacks for simpler use cases.

Graffle, on the other hand, appears to be a lighter-weight library with a simpler API, potentially making it easier to use for basic charting needs. It may be more suitable for projects that require quick implementation and smaller file sizes.

The choice between the two libraries depends on the specific requirements of your project, such as the complexity of visualizations needed, performance considerations, and development time constraints.

Graph theory (network) library for visualisation and analysis

Pros of Cytoscape.js

  • More mature and widely adopted project with a larger community
  • Extensive documentation and examples available
  • Supports a wide range of graph visualization features and algorithms

Cons of Cytoscape.js

  • Steeper learning curve due to its comprehensive feature set
  • Larger file size, which may impact load times for simpler projects
  • May be overkill for basic graph visualization needs

Code Comparison

Graffle:

const graph = new Graffle();
graph.addNode('A');
graph.addNode('B');
graph.addEdge('A', 'B');
graph.render('#container');

Cytoscape.js:

const cy = cytoscape({
  container: document.getElementById('cy'),
  elements: [
    { data: { id: 'A' } },
    { data: { id: 'B' } },
    { data: { source: 'A', target: 'B' } }
  ]
});

Both libraries allow for creating and rendering graphs, but Cytoscape.js offers more configuration options and a more complex API. Graffle aims for simplicity and ease of use, making it potentially more suitable for smaller projects or developers new to graph visualization. Cytoscape.js, on the other hand, provides a robust set of features for advanced graph manipulation and analysis, making it a better choice for complex graph-based applications.

5,365

Directed graph layout for JavaScript

Pros of dagre

  • More mature and widely adopted project with a larger community
  • Extensive documentation and examples available
  • Supports a wider range of graph layout algorithms

Cons of dagre

  • Last updated in 2018, potentially outdated
  • Heavier and more complex, which may impact performance for simpler use cases
  • Steeper learning curve due to its comprehensive feature set

Code Comparison

Graffle:

import { Graph } from 'graffle';

const graph = new Graph();
graph.addNode('A');
graph.addNode('B');
graph.addEdge('A', 'B');

dagre:

var g = new dagre.graphlib.Graph();
g.setNode("A", { label: "A" });
g.setNode("B", { label: "B" });
g.setEdge("A", "B");

Both libraries offer similar basic functionality for creating and manipulating graphs. Graffle's API appears slightly more concise, while dagre provides more options for node and edge attributes. The core concepts remain similar, making it relatively easy to switch between the two if needed.

:dizzy: Display dynamic, automatically organised, customizable network views.

Pros of vis-network

  • More mature and widely adopted project with a larger community
  • Extensive documentation and examples available
  • Supports a wider range of graph visualization features and customization options

Cons of vis-network

  • Larger file size and potentially heavier performance impact
  • Steeper learning curve due to more complex API and configuration options
  • Less focused on specific use cases, which may lead to unnecessary complexity for simpler projects

Code Comparison

vis-network:

var nodes = new vis.DataSet([
  { id: 1, label: 'Node 1' },
  { id: 2, label: 'Node 2' },
]);
var edges = new vis.DataSet([
  { from: 1, to: 2 },
]);
var container = document.getElementById('mynetwork');
var data = { nodes: nodes, edges: edges };
var options = {};
var network = new vis.Network(container, data, options);

graffle:

const graph = new Graffle();
graph.addNode('1', { label: 'Node 1' });
graph.addNode('2', { label: 'Node 2' });
graph.addEdge('1', '2');
graph.render('#mynetwork');

Both libraries allow for creating and rendering network graphs, but vis-network requires more setup code and offers more configuration options, while graffle provides a simpler API for basic graph creation and rendering.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

[!NOTE] Looking for graphql-request? It's been renamed to Graffle and the old version is available on the graphql-request branch.

Graffle Logo

Graffle

Minimal. Extensible. Type Safe. GraphQL client for JavaScript.

✨ Document Builder with full type inference • 🧰 Powerful extension system
🚛 Multi-transport (HTTP + in-memory) • 🎭 Native GraphQL syntax support
📦 Rich ecosystem of extensions • 🧙 Custom scalar codecs

Documentation • Getting Started • Examples

Version Downloads License CI TypeScript

Getting Started

Visit graffle.js.org/guides/getting-started for installation instructions, quick start guide, and examples.

Note: Graffle is currently in pre-release. Follow the documentation for the correct installation command.

Learn More

Visit graffle.js.org for full documentation, guides, and examples.

License

MIT

Sponsors

Graffle is supported by these generous sponsors.
If you find Graffle valuable and would like to support its development,
please consider becoming a sponsor.

Browser testing via