public ChartDescription GetTotalChartDescription() { var chartdescription = new ChartDescription { type = "bar", data = new ChartData { labels = new[] { "Food", "Accommodation", "Transportation", "Other", "Total" }, datasets = new List <ChartDataSet> { new ChartDataSet { label = "Spent", data = new[] { foodTotal, accommodationTotal, transportationTotal, otherTotal, ActualTotal } }, //new ChartDataSet //{ // label = "Budget", // data = new [] { foodBudget.Value, accommodationBudget.Value, transportationBudget.Value, otherBudget.Value, budgetTotal } //}, }, }, }; return(chartdescription); }
public ChartDescription GetTotalChartDescription() { if (Days.Count() == 0) { return(null); } var foodBudget = Budgets.SingleOrDefault(b => b.Department.Name == "FoodOrder")?.Amount; if (!foodBudget.HasValue) { foodBudget = 0.0m; } var accommodationBudget = Budgets.SingleOrDefault(a => a.Department.Name == "Accommodation")?.Amount; if (!accommodationBudget.HasValue) { accommodationBudget = 0.0m; } var transportationBudget = Budgets.SingleOrDefault(a => a.Department.Name == "Transportation")?.Amount; if (!transportationBudget.HasValue) { transportationBudget = 0.0m; } var otherBudget = Budgets.SingleOrDefault(a => a.Department.Name == "Other")?.Amount; if (!otherBudget.HasValue) { otherBudget = 0.0m; } var chartdescription = new ChartDescription { type = "bar", data = new ChartData { labels = new[] { "Food", "Accommodation", "Transportation", "Other", "Total" }, datasets = new List <ChartDataSet> { new ChartDataSet { label = "Spent", data = new[] { foodTotal, accommodationTotal, transportationTotal, otherTotal, actualTotal } }, new ChartDataSet { label = "Budget", data = new [] { foodBudget.Value, accommodationBudget.Value, transportationBudget.Value, otherBudget.Value, budgetTotal } }, }, }, }; return(chartdescription); }
public SupportHorizontalBarChartExtended() { AxisLeft = new YAxisConfig(); AxisRight = new YAxisConfig(); XAxis = new XAxisConfig(); DescriptionChart = new ChartDescription(); AnimationX = new AnimatorXF(); AnimationY = new AnimatorXF(); }
public ChartDescription GetpolarAreaChartDescription() { var chartdescription = new ChartDescription { type = "polarArea", data = new ChartData { labels = new[] { "Food", "Accommodation", "Transportation", "Other" }, datasets = new List <ChartDataSet> { new ChartDataSet { label = "Spent", data = new[] { foodTotal, accommodationTotal, transportationTotal, otherTotal }, }, }, }, }; return(chartdescription); }
/// <summary> /// Demonstrates how to work with chart data. /// </summary> static void ConsumingCharts(string accessToken) { int?subscriptionId = 0; var scenario = new Scenario("Consuming charts") .InitializeAPI( () => { var cfg = new Configuration(); cfg.ApiKey.Add("Authorization", accessToken); cfg.ApiKeyPrefix.Add("Authorization", "Bearer"); return(new PricesApi(cfg)); }) .InitializeClient( init: () => new WSClient("https://md-api-d.tradovate.com/v1"), opened: (sender, e) => { Log.Write("WebSocket opened."); }, closed: (sender, e) => { Log.Write("WebSocket closed."); }) .Request("Get chart for ESM8", init: () => { var description = new ChartDescription(ChartDescription.UnderlyingTypeEnum.MinuteBar, 15, ChartDescription.ElementSizeUnitEnum.UnderlyingUnits); var timeRange = new ChartTimeRange(AsMuchAsElements: 66); return(new GetChart("ESM8", description, timeRange)); }, sender: (api, request) => api.GetChartAsyncWithHttpInfo(request), responseHandler: (request, response) => { Log.Write($"{request} -> {response.Data}"); subscriptionId = response.Data.RealtimeId; // Store real-time subscription ID to properly cancel the subscription }, dataHandler: message => { switch (message.e) { case "chart": Log.Write("CHART event:"); var json = message.d as JObject; var data = json.ToObject <ChartData>(); data?.Charts?.ForEach(chart => { Log.Write($" ID: {chart.Id}"); Log.Write($" TD: {chart.TradeDate}"); if (chart.Bars != null) { Log.Write(" BARS:"); Console.WriteLine(string.Join("\n", chart.Bars.Select(x => $" {x}"))); } }); break; } }) .ProcessingWhile(TimeSpan.FromSeconds(15)) .Request($"Cancel chart subscription #{subscriptionId}", init: () => new CancelChart(subscriptionId ?? 0), sender: (api, request) => api.CancelChartAsyncWithHttpInfo(request), responseHandler: (request, response) => { Log.Write($"{request} -> {response.Data}"); }); scenario.Run(); }
public ChartDescription GetChartDescription() { if (Days.Count() == 0) { return(null); } var foodBudget = Budgets.SingleOrDefault(b => b.Department.Name == "FoodOrder")?.Amount; if (!foodBudget.HasValue) { foodBudget = 0.0m; } foodBudget /= Days.Count(); var accommodationBudget = Budgets.SingleOrDefault(a => a.Department.Name == "Accommodation")?.Amount; if (!accommodationBudget.HasValue) { accommodationBudget = 0.0m; } accommodationBudget /= Days.Count(); var transportationBudget = Budgets.SingleOrDefault(a => a.Department.Name == "Transportation")?.Amount; if (!transportationBudget.HasValue) { transportationBudget = 0.0m; } transportationBudget /= Days.Count(); var otherBudget = Budgets.SingleOrDefault(a => a.Department.Name == "Other")?.Amount; if (!otherBudget.HasValue) { otherBudget = 0.0m; } otherBudget /= Days.Count(); var chartdescription = new ChartDescription { type = "bar", data = new ChartData { labels = Days.OrderBy(d => d.DayNumber).Select(d => "Day " + d.DayNumber.ToString()), datasets = new List <ChartDataSet> { new ChartDataSet { label = "Food", data = Days.OrderBy(d => d.DayNumber).Select(d => d.foodTotal) }, new ChartDataSet { label = "Accommodation", data = Days.OrderBy(d => d.DayNumber).Select(d => d.accommodationTotal) }, new ChartDataSet { label = "Transportation", data = Days.OrderBy(d => d.DayNumber).Select(d => d.transportationTotal) }, new ChartDataSet { label = "Other", data = Days.OrderBy(d => d.DayNumber).Select(d => d.otherTotal) }, new ChartDataSet { label = "Total", data = Days.OrderBy(d => d.DayNumber).Select(d => d.ActualTotal) }, // new ChartDataSet //{ // label = "Food Budget", // data = Days.OrderBy(d => d.DayNumber).Select(d => foodBudget.Value), // type = "line", // fill = false, // borderColor = "red" //}, // new ChartDataSet //{ // label = "Accommodation Budget", // data = Days.OrderBy(d => d.DayNumber).Select(d => accommodationBudget.Value), // type = "line", // fill = false, // borderColor = "red" //}, // new ChartDataSet //{ // label = "Transportation Budget", // data = Days.OrderBy(d => d.DayNumber).Select(d => transportationBudget.Value), // type = "line", // fill = false, // borderColor = "red" //}, // new ChartDataSet //{ // label = "Other Budget", // data = Days.OrderBy(d => d.DayNumber).Select(d => otherBudget.Value), // type = "line", // fill = false, // borderColor = "red" //}, new ChartDataSet { label = "Total Budget", data = Days.OrderBy(d => d.DayNumber).Select(d => budgetTotal / Days.Count()), type = "line", fill = false, borderColor = "red" }, }, }, }; return(chartdescription); }