String chartJS;
String chartCode;
String chartResize;
String supportUnit;
string chartName;
[Parameter]
public string CType { get; set; }
protected override async Task OnInitializedAsync()
{
int chartType = Convert.ToInt32(CType);
Steema.TeeChart.TChart tChart = new TChart();
Points points1 = new Points(tChart.Chart);
Points points2 = new Points(tChart.Chart);
//setup some datetime data
double[] dates = new double[] { new DateTime(2019, 9, 1).ToOADate(),new DateTime(2019, 9, 15).ToOADate(), new DateTime(2019, 10, 1).ToOADate()
, new DateTime(2019, 10, 15).ToOADate(), new DateTime(2019, 11, 1).ToOADate()
, new DateTime(2019, 11, 15).ToOADate(), new DateTime(2019, 12, 1).ToOADate()
, new DateTime(2019, 12, 15).ToOADate(), new DateTime(2020, 1, 1).ToOADate()
, new DateTime(2020, 1, 15).ToOADate(), new DateTime(2020, 2, 1).ToOADate()
, new DateTime(2020, 2, 15).ToOADate(), new DateTime(2020, 3, 1).ToOADate(), new DateTime(2020, 3, 15).ToOADate()
, new DateTime(2020, 4, 1).ToOADate(), new DateTime(2020, 4, 15).ToOADate(), new DateTime(2020, 5, 1).ToOADate()
, new DateTime(2020, 5, 15).ToOADate(), new DateTime(2020, 6, 1).ToOADate()
, new DateTime(2020, 6, 15).ToOADate(), new DateTime(2020, 7, 1).ToOADate()
, new DateTime(2020, 7, 15).ToOADate(), new DateTime(2020, 8, 1).ToOADate(), new DateTime(2020, 8, 15).ToOADate()
, new DateTime(2020, 9, 1).ToOADate(), new DateTime(2020, 9, 15).ToOADate(), new DateTime(2020, 10, 1).ToOADate()
, new DateTime(2020, 10, 15).ToOADate() };
for (int i = 0; i < dates.Length; i++)
dates[i] = MilliTimeStamp(DateTime.FromOADate(dates[i]));
points1.Title = "Apples";
points1.Add(dates, new double[] { 5, 3, 2, 7, 1, 6, 4, 5, 1, 0, 10, 7, 11, 15, 12, 21, 17, 15, 19, 24, 21, 11, 15, 21, 19, 17, 20, 23 });
points2.Title = "Pears";
points2.Add(dates, new double[] { 7, 1, 5, 1, 0, 10, 6, 3, 2, 7, 11, 4, 5, 3, 4, 5, 1, 5, 11, 15, 16, 14, 14, 13, 12, 15, 17, 19 });
chartName = "shipments";
tChart.Export.Image.JScript.ChartName = chartName;
var customCode = new List<string>();
customCode.Add("setupClientChart(" + chartName + ");");
tChart.Export.Image.JScript.CustomCode = customCode.ToArray();
MemoryStream ms = new MemoryStream();
tChart.Export.Image.JScript.Width = 1400; //start dims
tChart.Export.Image.JScript.Height = 300;
tChart.Export.Image.JScript.DoFullPage = false; //inline, no page <html> header tags
tChart.Export.Image.JScript.Save(ms);
supportUnit = "<script src=\"js/shipments.js\" type=\"text/javascript\"></script>";
ms.Position = 0;
StreamReader reader = new StreamReader(ms);
//setup our chart name, here 'dynoChartName'.
string result = "<script> var " + chartName + "; " + reader.ReadToEnd() + "</script>";
chartJS = await Task.FromResult(result);
}