Giter VIP home page Giter VIP logo

chartgen's Introduction

ChartGen

super simple svg chart generating library in Rust.

Example.rs:

extern crate chartgen;
use chartgen::{generate_svg, truncate_chart, Point};

fn main() {
    let points: Vec<Point<f64>> = Vec::from([
        Point { x: 0.0, y: 0.0 },
        Point { x: 0.0, y: 9020.0 },
        Point { x: 1.0, y: 4845.0 },
        Point { x: 2.0, y: 6189.0 },
        Point { x: 3.0, y: 9190.0 },
        Point { x: 4.0, y: 9471.0 },
        Point { x: 5.0, y: 9313.0 },
        Point { x: 6.0, y: 504.0 },
        Point { x: 7.0, y: 4555.0 },
        Point { x: 8.0, y: 3455.0 },
    ]);
    let size = Point { x: 150.0, y: 100.0 };
    println!(
        "{}",
        generate_svg(&truncate_chart(&points, size), size, String::from("red"), String::from("2"))
    );
}

Results in:

<svg xmlns="http://www.w3.org/2000/svg" width="150" height="100" viewbox="0 0 150 100"><polyline fill="none" stroke="red" points="0.00,100.00 0.00,4.76 18.75,48.84 37.50,34.65 56.25,2.97 75.00,0.00 93.75,1.67 112.50,94.68 131.25,51.91 150.00,63.52 "/></svg>

Or

chartgen's People

Stargazers

 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.