From c7d475576cb8b80fc50214e36959bdb886b8c6f0 Mon Sep 17 00:00:00 2001 From: Ian Webster Date: Tue, 21 Sep 2021 08:20:41 -0700 Subject: [PATCH] Add test for Format and update readme --- QuickChartTest/QuickChartTest.cs | 57 +++++++++++++++++++++++--------- README.md | 3 ++ 2 files changed, 45 insertions(+), 15 deletions(-) diff --git a/QuickChartTest/QuickChartTest.cs b/QuickChartTest/QuickChartTest.cs index 9ed2b1b..4141d40 100644 --- a/QuickChartTest/QuickChartTest.cs +++ b/QuickChartTest/QuickChartTest.cs @@ -10,20 +10,20 @@ namespace QuickChartTest [Fact] public void TestBasic() { - Chart qc = new Chart - { - Width = 500, - Height = 300, + Chart qc = new Chart + { + Width = 500, + Height = 300, Config = @"{ type: 'bar', data: { labels: ['Q1', 'Q2', 'Q3', 'Q4'], datasets: [{ - label: 'Users', - data: [50, 60, 70, 180] + label: 'Users', + data: [50, 60, 70, 180] }] } - }" + }" }; string url = qc.GetUrl(); @@ -36,21 +36,21 @@ namespace QuickChartTest [Fact] public void TestWithKey() { - Chart qc = new Chart - { - Key = "abc123", - Width = 500, - Height = 300, + Chart qc = new Chart + { + Key = "abc123", + Width = 500, + Height = 300, Config = @"{ type: 'bar', data: { labels: ['Q1', 'Q2', 'Q3', 'Q4'], datasets: [{ - label: 'Users', - data: [50, 60, 70, 180] + label: 'Users', + data: [50, 60, 70, 180] }] } - }" + }" }; string url = qc.GetUrl(); @@ -59,5 +59,32 @@ namespace QuickChartTest Assert.Contains("h=300", url); Assert.Contains("key=abc123", url); } + + [Fact] + public void TestWithFormat() + { + Chart qc = new Chart + { + Width = 500, + Height = 300, + Format = "svg", + Config = @"{ + type: 'bar', + data: { + labels: ['Q1', 'Q2', 'Q3', 'Q4'], + datasets: [{ + label: 'Users', + data: [50, 60, 70, 180] + }] + } + }" + }; + + string url = qc.GetUrl(); + Assert.Contains("https://quickchart.io:443/chart", url); + Assert.Contains("w=500", url); + Assert.Contains("h=300", url); + Assert.Contains("f=svg", url); + } } } diff --git a/README.md b/README.md index 7524eec..a54f56b 100644 --- a/README.md +++ b/README.md @@ -77,6 +77,9 @@ The background color of the chart. Any valid HTML color works. Defaults to #ffff #### 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. +#### Format: string +The output format of the chart. Defaults to "png" + #### Key: string API key (not required)