Skip to content

Commit

Permalink
(docs) README displays examples and API docs
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincobain2000 committed Dec 22, 2023
1 parent ac09aad commit bd61d05
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 38 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
on:
pull_request:
push:
paths:
- '**/*.go'
- '**/*.mod'
Expand Down
29 changes: 29 additions & 0 deletions .github/workflows/coveritup.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
push:
paths:
- '**/*.go'
- '**/*.mod'
- '**/*.sum'
- '**/*.yaml'
name: CI
jobs:
test:
strategy:
matrix:
go-version: [dev-latest]
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: kevincobain2000/action-gobrew@v2
with:
version: ${{ matrix.go-version }}
- name: Install Tools
run: |
go install github.com/securego/gosec/v2/cmd/gosec@latest
go install github.com/axw/gocov/gocov@latest
go install github.com/AlekSi/gocov-xml@latest
- name: Lint
run: |
gosec ./...
go vet -all .
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
on:
pull_request:
push:
paths:
- '**/*.go'
- '**/*.mod'
Expand All @@ -15,7 +15,7 @@ jobs:
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: kevincobain2000/action-gobrew@v2.2
- uses: kevincobain2000/action-gobrew@v2
with:
version: ${{ matrix.go-version }}
- name: Test
Expand Down
120 changes: 86 additions & 34 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,10 @@
</a>
</p>
<p align="center">
Chart to Image API interface for go-charts.
<br>
Data Driven READMEs.
<br>

<br>

Chart as Image - API using go-charts.
</p>

**Quick Setup:** Easy setup. Add charts to your README.
**Quick Setup:** Easy setup. Add charts as images in markdown, emails etc.

**Hassle Free:** Create charts as images with single URL.

Expand All @@ -22,58 +16,116 @@
# Build Status


## Development
# API

`https://instachart.coveritup.app`

## `GET /line`

| Query Param | Required | Description | Example |
| :---------- | :------- | :---------- | :------------------------------------------------------------------------ |
| `data` || JSON | `?data={ "x": [["2022-12-23","2022-12-24","2023-12-25"]],"y": [[1,2,3]]}` |
| `title` | | string | |
| `x_label` | | string | |
| `y_label` | | string | |
| `height` | | int | |
| `width` | | int | |

```sh
air
```

## API Docs
| `data` | Required | Description | Example |
| :------ | :------- | :---------- | :------------------------------------ |
| `x` || []Array | `"x": [["2022-12-23","2022-12-24"], ` |
| `y` || []Array | `"y": [[1,2,3],[3,5,7]]` |
| `names` | | Array | `"names": ["Series A", "Series B"]` |

### Line Chart
### Single Line Series

#### Single date series
<details>
<summary><i>Image URL</i></summary>

```sh
http://localhost:3000/line?data={
https://instachart.coveritup.app/line?title=Line+single+Series&x_label=dates&y_label=amount&data={
"x": [["2022-12-23","2022-12-24","2023-12-25"]],
"y": [[1,2,3]]
}
```
</details>

#### Multiple date series
---

![Line single series](https://instachart.coveritup.app/line?title=Line+single+Series&x_label=dates&y_label=amount&data={%20%22x%22:%20[[%222022-12-23%22,%222022-12-24%22,%222023-12-25%22]],%20%22y%22:%20[[1,2,3]],%20%22names%22:%20[%22Series%20A%22]%20})

### Multiple Line Series

<details>
<summary><i>Image URL</i></summary>

```sh
http://localhost:3000/line?data={
https://instachart.coveritup.app/line??title=Multi+Line+Series&x_label=dates&y_label=amount&data={
"x": [["2022-12-23","2022-12-24","2023-12-25"], ["2022-12-23","2022-12-28","2023-12-30"]],
"y": [[1,2,3], [2,5,3]]
"y": [[1,2,3], [1,5,10]],
"names": ["Series A", "Series B"]
}
```
</details>

---

![Multi line series](https://instachart.coveritup.app/line?title=Multi+Line+Series&x_label=dates&y_label=amount&data={%20%22x%22:%20[[%222022-12-23%22,%222022-12-24%22,%222023-12-25%22],%20[%222022-12-23%22,%222022-12-28%22,%222023-12-30%22]],%20%22y%22:%20[[1,2,3],%20[1,5,10]],%20%22names%22:%20[%22Series%20A%22,%20%22Series%20B%22]%20})


### Continuous Series

#### Continuous Series
<details>
<summary><i>Image URL</i></summary>

```sh
http://localhost:3000/line?data={
"x": [["10","20","30"]],
"y": [[1,2,3]]
https://instachart.coveritup.app/line??title=Continuous+Series&x_label=No+of+people&y_label=amount&data={
"x": [["10","20","30"], ["10","20","30"], ["10","20","30"]],
"y": [[1,2,3], [10,20,30], [6,3,9]],
"names": ["Series A", "Series B", "Series C"]
}
```

#### Multiple Continuous Series
</details>

---

![Multi line series](https://instachart.coveritup.app/line?title=Continuous+Series&x_label=No+of+people&y_label=amount&data={%20"x":%20[["10","20","30"],%20["10","20","30"],%20["10","20","30"]],%20"y":%20[[1,2,3],%20[10,20,30],%20[6,3,9]]%20})



## `GET /bar`

| Query Param | Required | Description | Example |
| :---------- | :------- | :---------- | :--------------------------------------------------- |
| `data` || JSON | `?data={ "x": [["Mon","Tue","Wed"]],"y": [[1,2,3]]}` |
| `title` | | string | |
| `y_label` | | string | |
| `height` | | int | |
| `width` | | int | |


| `data` | Required | Description | Example |
| :------ | :------- | :---------- | :------------------------------------ |
| `x` || []Array | `"x": [["Mon","Tue", "Wed"], ` |
| `y` || []Array | `"y": [[1,2,3]]` |


### Series

<details>
<summary><i>Image URL</i></summary>

```sh
http://localhost:3000/line?data={
"x": [["10","20","30"], ["10","20","30"]],
"y": [[1,2,3], [10,20,30]]
https://instachart.coveritup.app/bar?title=Bar+Chart&y_label=Sleeping+hours&data={
"x": ["Monday", "Friday", "Sunday"],
"y": [8, 2 ,14]
}
```

### Bar Chart
</details>

#### Series
---

```sh
http://localhost:3000/bar?title=sleeping+hours
&y_label=hours
&data={ "x": ["Monday","Sunday"], "y": [8, 14] }
```
![Bar chart](https://instachart.coveritup.app/bar?title=Bar+Chart&y_label=Sleeping+hours&data={%20%22x%22:%20[%22Monday%22,%20%22Friday%22,%20%22Sunday%22],%20%22y%22:%20[8,%202%20,14]%20})
1 change: 1 addition & 0 deletions pkg/echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
func NewEcho() *echo.Echo {
e := echo.New()
e.HTTPErrorHandler = HTTPErrorHandler
e.Pre(middleware.RemoveTrailingSlash())
SetupLogger(e)
SetupRoutes(e)
return e
Expand Down
2 changes: 1 addition & 1 deletion pkg/line_chart_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ func TestGetLineRequestChart_ValidRequest(t *testing.T) {
e := echo.New()

e.GET("/line", func(c echo.Context) error {
img, err := NewLineChartHandler().GetLineRequestChart(c)
img, err := NewLineChartHandler().Get(c)
if err != nil {
return err
}
Expand Down

0 comments on commit bd61d05

Please sign in to comment.