Add support for chart.js version parameter (#4)
This commit is contained in:
parent
fbb6deee1a
commit
3735d4d181
3 changed files with 40 additions and 2 deletions
|
|
@ -22,6 +22,7 @@ namespace QuickChart
|
||||||
public string Format { get; set; }
|
public string Format { get; set; }
|
||||||
public string BackgroundColor { get; set; }
|
public string BackgroundColor { get; set; }
|
||||||
public string Key { get; set; }
|
public string Key { get; set; }
|
||||||
|
public string Version { get; set; }
|
||||||
public string Config { get; set; }
|
public string Config { get; set; }
|
||||||
|
|
||||||
public string Scheme { get; set; }
|
public string Scheme { get; set; }
|
||||||
|
|
@ -62,6 +63,10 @@ namespace QuickChart
|
||||||
{
|
{
|
||||||
builder.Append("&key=").Append(Uri.EscapeDataString(Key));
|
builder.Append("&key=").Append(Uri.EscapeDataString(Key));
|
||||||
}
|
}
|
||||||
|
if (!string.IsNullOrEmpty(Version))
|
||||||
|
{
|
||||||
|
builder.Append("&v=").Append(Uri.EscapeDataString(Version));
|
||||||
|
}
|
||||||
|
|
||||||
return $"{Scheme}://{Host}:{Port}/chart?{builder}";
|
return $"{Scheme}://{Host}:{Port}/chart?{builder}";
|
||||||
}
|
}
|
||||||
|
|
@ -85,6 +90,7 @@ namespace QuickChart
|
||||||
format = Format,
|
format = Format,
|
||||||
chart = Config,
|
chart = Config,
|
||||||
key = Key,
|
key = Key,
|
||||||
|
version = Version,
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
string url = $"{Scheme}://{Host}:{Port}/chart/create";
|
string url = $"{Scheme}://{Host}:{Port}/chart/create";
|
||||||
|
|
@ -123,6 +129,7 @@ namespace QuickChart
|
||||||
format = Format,
|
format = Format,
|
||||||
chart = Config,
|
chart = Config,
|
||||||
key = Key,
|
key = Key,
|
||||||
|
version = Version,
|
||||||
}, options);
|
}, options);
|
||||||
|
|
||||||
string url = $"{Scheme}://{Host}:{Port}/chart";
|
string url = $"{Scheme}://{Host}:{Port}/chart";
|
||||||
|
|
|
||||||
|
|
@ -86,5 +86,32 @@ namespace QuickChartTest
|
||||||
Assert.Contains("h=300", url);
|
Assert.Contains("h=300", url);
|
||||||
Assert.Contains("f=svg", url);
|
Assert.Contains("f=svg", url);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void TestWithVersion()
|
||||||
|
{
|
||||||
|
Chart qc = new Chart
|
||||||
|
{
|
||||||
|
Width = 500,
|
||||||
|
Height = 300,
|
||||||
|
Format = "2.9.4",
|
||||||
|
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("v=2.9.4", url);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,13 +26,14 @@ Chart qc = new Chart();
|
||||||
|
|
||||||
qc.Width = 500;
|
qc.Width = 500;
|
||||||
qc.Height = 300;
|
qc.Height = 300;
|
||||||
|
qc.Version = "2.9.4";
|
||||||
qc.Config = @"{
|
qc.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]
|
||||||
}]
|
}]
|
||||||
}
|
}
|
||||||
}";
|
}";
|
||||||
|
|
@ -80,6 +81,9 @@ The device pixel ratio of the chart. This will multiply the number of pixels by
|
||||||
#### Format: string
|
#### Format: string
|
||||||
The output format of the chart. Defaults to "png"
|
The output format of the chart. Defaults to "png"
|
||||||
|
|
||||||
|
#### Version: string
|
||||||
|
Chart.js version (not required)
|
||||||
|
|
||||||
#### Key: string
|
#### Key: string
|
||||||
API key (not required)
|
API key (not required)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue