Add test for Format and update readme (#3)
This commit is contained in:
parent
67bed9519e
commit
14c7cbb2ae
2 changed files with 45 additions and 15 deletions
|
|
@ -10,20 +10,20 @@ namespace QuickChartTest
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestBasic()
|
public void TestBasic()
|
||||||
{
|
{
|
||||||
Chart qc = new Chart
|
Chart qc = new Chart
|
||||||
{
|
{
|
||||||
Width = 500,
|
Width = 500,
|
||||||
Height = 300,
|
Height = 300,
|
||||||
Config = @"{
|
Config = @"{
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
data: {
|
data: {
|
||||||
labels: ['Q1', 'Q2', 'Q3', 'Q4'],
|
labels: ['Q1', 'Q2', 'Q3', 'Q4'],
|
||||||
datasets: [{
|
datasets: [{
|
||||||
label: 'Users',
|
label: 'Users',
|
||||||
data: [50, 60, 70, 180]
|
data: [50, 60, 70, 180]
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
};
|
};
|
||||||
|
|
||||||
string url = qc.GetUrl();
|
string url = qc.GetUrl();
|
||||||
|
|
@ -36,21 +36,21 @@ namespace QuickChartTest
|
||||||
[Fact]
|
[Fact]
|
||||||
public void TestWithKey()
|
public void TestWithKey()
|
||||||
{
|
{
|
||||||
Chart qc = new Chart
|
Chart qc = new Chart
|
||||||
{
|
{
|
||||||
Key = "abc123",
|
Key = "abc123",
|
||||||
Width = 500,
|
Width = 500,
|
||||||
Height = 300,
|
Height = 300,
|
||||||
Config = @"{
|
Config = @"{
|
||||||
type: 'bar',
|
type: 'bar',
|
||||||
data: {
|
data: {
|
||||||
labels: ['Q1', 'Q2', 'Q3', 'Q4'],
|
labels: ['Q1', 'Q2', 'Q3', 'Q4'],
|
||||||
datasets: [{
|
datasets: [{
|
||||||
label: 'Users',
|
label: 'Users',
|
||||||
data: [50, 60, 70, 180]
|
data: [50, 60, 70, 180]
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
};
|
};
|
||||||
|
|
||||||
string url = qc.GetUrl();
|
string url = qc.GetUrl();
|
||||||
|
|
@ -59,5 +59,32 @@ namespace QuickChartTest
|
||||||
Assert.Contains("h=300", url);
|
Assert.Contains("h=300", url);
|
||||||
Assert.Contains("key=abc123", 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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -77,6 +77,9 @@ The background color of the chart. Any valid HTML color works. Defaults to #ffff
|
||||||
#### 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.
|
||||||
|
|
||||||
|
#### Format: string
|
||||||
|
The output format of the chart. Defaults to "png"
|
||||||
|
|
||||||
#### Key: string
|
#### Key: string
|
||||||
API key (not required)
|
API key (not required)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue