Update README.md

This commit is contained in:
Ian Webster 2020-11-26 18:32:26 -05:00 committed by GitHub
parent 29606a55c9
commit 0a19efe865
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,12 +1,23 @@
# quickchart-csharp # quickchart-csharp
[![Build Status](https://travis-ci.com/typpo/quickchart-csharp.svg?branch=master)](https://travis-ci.com/typpo/quickchart-csharp)
[![Nuget](http://img.shields.io/nuget/v/QuickChart.svg?style=flat)](https://www.nuget.org/packages/QuickChart)
A C# client for the [quickchart.io](https://quickchart.io/) chart API. A C# client for the [quickchart.io](https://quickchart.io/) chart API.
# Installation ## Installation
Use `QuickChart/QuickChart.cs` in this project, or install `QuickChart` through NuGet. Use `QuickChart/QuickChart.cs` in this project, or install the `QuickChart` package:
# Usage ```
PM> Install-Package QuickChart -Version 1.0.0
```
or
```
dotnet add package QuickChart --version 1.0.0
```
## Usage
This library provides a `QuickChart` namespace containing a `Chart` class. Import and instantiate it. Then set properties on it and specify a [Chart.js](https://chartjs.org) config: This library provides a `QuickChart` namespace containing a `Chart` class. Import and instantiate it. Then set properties on it and specify a [Chart.js](https://chartjs.org) config:
@ -45,46 +56,49 @@ The URLs will render an image of a chart:
<img src="https://quickchart.io/chart?c=%7B%22type%22%3A+%22bar%22%2C+%22data%22%3A+%7B%22labels%22%3A+%5B%22Hello+world%22%2C+%22Test%22%5D%2C+%22datasets%22%3A+%5B%7B%22label%22%3A+%22Foo%22%2C+%22data%22%3A+%5B1%2C+2%5D%7D%5D%7D%7D&w=600&h=300&bkg=%23ffffff&devicePixelRatio=2.0&f=png" width="500" /> <img src="https://quickchart.io/chart?c=%7B%22type%22%3A+%22bar%22%2C+%22data%22%3A+%7B%22labels%22%3A+%5B%22Hello+world%22%2C+%22Test%22%5D%2C+%22datasets%22%3A+%5B%7B%22label%22%3A+%22Foo%22%2C+%22data%22%3A+%5B1%2C+2%5D%7D%5D%7D%7D&w=600&h=300&bkg=%23ffffff&devicePixelRatio=2.0&f=png" width="500" />
## Customizing your chart ### Customizing your chart
You can set the following properties: You can set the following properties:
### Config: string #### Config: string
The actual Chart.js chart configuration. The actual Chart.js chart configuration.
### Width: int #### Width: int
Width of the chart image in pixels. Defaults to 500 Width of the chart image in pixels. Defaults to 500
### Height: int #### Height: int
Height of the chart image in pixels. Defaults to 300 Height of the chart image in pixels. Defaults to 300
### BackgroundColor: str #### BackgroundColor: string
The background color of the chart. Any valid HTML color works. Defaults to #ffffff (white). Also takes rgb, rgba, and hsl values. The background color of the chart. Any valid HTML color works. Defaults to #ffffff (white). Also takes rgb, rgba, and hsl values.
### DevicePixelRatio: double #### DevicePixelRatio: double
The device pixel ratio of the chart. This will multiply the number of pixels by the value. This is usually used for retina displays. Defaults to 1.0. The device pixel ratio of the chart. This will multiply the number of pixels by the value. This is usually used for retina displays. Defaults to 1.0.
## Getting URLs #### Key: string
API key (not required)
### Creating chart URLs
There are a few ways to get a URL for your chart object. There are a few ways to get a URL for your chart object.
### GetUrl(): string #### GetUrl(): string
Returns a URL that will display the chart image when loaded. Returns a URL that will display the chart image when loaded.
### GetShortUrl(): string #### GetShortUrl(): string
Uses the quickchart.io web service to create a fixed-length chart URL that displays the chart image. Returns a URL such as `https://quickchart.io/chart/render/f-a1d3e804-dfea-442c-88b0-9801b9808401`. Uses the quickchart.io web service to create a fixed-length chart URL that displays the chart image. Returns a URL such as `https://quickchart.io/chart/render/f-a1d3e804-dfea-442c-88b0-9801b9808401`.
Note that short URLs expire after a few days for users of the free service. You can [subscribe](https://quickchart.io/pricing/) to keep them around longer. Note that short URLs expire after a few days for users of the free service. You can [subscribe](https://quickchart.io/pricing/) to keep them around longer.
## Other methods #### Other methods
### ToFile(string path) #### ToFile(string path)
Write your chart to file. Write your chart to file.
### ToByteArray(): byte[] #### ToByteArray(): byte[]
Returns an array of bytes representing your image. Returns an array of bytes representing your image.