public void ChartCategoryUpdate() { TestUtils.Upload(c_fileName, c_folderName + "/" + c_fileName); ChartCategory category = new ChartCategory { Value = "NewCategory", DataPoints = new List <OneValueChartDataPoint> { new OneValueChartDataPoint { Value = 40 }, new OneValueChartDataPoint { Value = 50 }, new OneValueChartDataPoint { Value = 14 } } }; Chart chart = TestUtils.SlidesApi.UpdateChartCategory( c_fileName, c_slideIndex, c_shapeIndex, c_categoryIndex, category, c_password, c_folderName); Assert.IsNotNull(chart); Assert.AreEqual(c_seriesCount, chart.Series.Count); Assert.AreEqual(c_categoryCount, chart.Categories.Count); Assert.AreEqual(c_categoryCount, ((OneValueSeries)chart.Series[0]).DataPoints.Count); Assert.AreEqual(category.DataPoints[0].Value, ((OneValueSeries)chart.Series[0]).DataPoints[c_categoryIndex - 1].Value); }
public IActionResult Multilevellabel() { List <MultiLevelLabelsData> chartData = new List <MultiLevelLabelsData> { new MultiLevelLabelsData { x = "Grapes", y = 28 }, new MultiLevelLabelsData { x = "Apples", y = 87 }, new MultiLevelLabelsData { x = "Pears", y = 42 }, new MultiLevelLabelsData { x = "Grapes", y = 13 }, new MultiLevelLabelsData { x = "Apples", y = 13 }, new MultiLevelLabelsData { x = "Pears", y = 10 }, new MultiLevelLabelsData { x = "Tomato", y = 31 }, new MultiLevelLabelsData { x = "Potato", y = 96 }, new MultiLevelLabelsData { x = "Cucumber", y = 41 }, new MultiLevelLabelsData { x = "Onion", y = 59 } }; ViewBag.dataSource = chartData; List <ChartMultiLevelLabel> multilevels = new List <ChartMultiLevelLabel>(); ChartMultiLevelLabel one = new ChartMultiLevelLabel(); ChartCategory category = new ChartCategory(); category.Start = "-0.5"; category.End = "0.5"; category.Text = "Seedless"; ChartCategory category1 = new ChartCategory(); category1.Start = "0.5"; category1.End = "2.5"; category1.Text = "Seedled"; ChartCategory category2 = new ChartCategory(); category2.Start = "2.5"; category2.End = "3.5"; category2.Text = "Seedless"; ChartCategory category3 = new ChartCategory(); category3.Start = "3.5"; category3.End = "5.5"; category3.Text = "Seedled"; ChartCategory category4 = new ChartCategory(); category4.Start = "5.5"; category4.End = "6.5"; category4.Text = "Seedless"; ChartCategory category5 = new ChartCategory(); category5.Start = "6.5"; category5.End = "7.5"; category5.Text = "Seedled"; ChartCategory category6 = new ChartCategory(); category6.Start = "7.5"; category6.End = "8.5"; category6.Text = "Seedless"; ChartCategory category7 = new ChartCategory(); category7.Start = "8.5"; category7.End = "9.5"; category7.Text = "Seedled"; List <ChartCategory> categoryOne = new List <ChartCategory>(); categoryOne.Add(category); categoryOne.Add(category1); categoryOne.Add(category2); categoryOne.Add(category3); categoryOne.Add(category4); categoryOne.Add(category5); categoryOne.Add(category6); categoryOne.Add(category7); one.Categories = categoryOne; ChartMultiLevelLabel two = new ChartMultiLevelLabel(); ChartCategory category11 = new ChartCategory(); category11.Start = "-0.5"; category11.End = "2.5"; category11.Text = "In Season"; ChartCategory category12 = new ChartCategory(); category12.Start = "2.5"; category12.End = "5.5"; category12.Text = "Out of Season"; ChartCategory category22 = new ChartCategory(); category22.Start = "5.5"; category22.End = "7.5"; category22.Text = "In Season"; ChartCategory category33 = new ChartCategory(); category33.Start = "7.5"; category33.End = "9.5"; category33.Text = "Out of Season"; List <ChartCategory> categoryTwo = new List <ChartCategory>(); categoryTwo.Add(category11); categoryTwo.Add(category12); categoryTwo.Add(category22); categoryTwo.Add(category33); two.Categories = categoryTwo; ChartMultiLevelLabel three = new ChartMultiLevelLabel(); ChartCategory category111 = new ChartCategory(); category111.Start = "-0.5"; category111.End = "5.5"; category111.Text = "Fruits"; ChartCategory category222 = new ChartCategory(); category222.Start = "5.5"; category222.End = "9.5"; category222.Text = "Vegetables"; List <ChartCategory> categoryThree = new List <ChartCategory>(); categoryThree.Add(category111); categoryThree.Add(category222); three.Categories = categoryThree; multilevels.Add(one); multilevels.Add(two); multilevels.Add(three); ViewBag.multiLevelLabels = multilevels; return(View()); }
private TrendGraphSeries AddSeries(DateTime start, DateTime end, Color color) { ChartCategory cat = new ChartCategory(); cat.WpfColor = color; nfi.NumberDecimalDigits = 2; nfi.CurrencyNegativePattern = 0; TimeSpan span = (end - start); int days = span.Days; if (days > 360) { cat.Name = start.Year.ToString(); } else { cat.Name = start.ToShortDateString(); } TrendGraphSeries s = new TrendGraphSeries(cat.Name, cat.Name); chartData.AddSeries(s); s.Flipped = generator.IsFlipped; IList <ChartValue> timeData = s.Values; s.BeginUpdate(); DateTime last = start; TrendValue lastv = null; foreach (TrendValue v in this.data) { // calculate balances using data from the start of the account \ list so the end balance is correct if (v.Date <= end && v.Date >= start) { // If the items are on the same day, don't add to the graph yet. // Accumulate them and the accumulated value for the day will be displayed if (last != v.Date) { AddDatum(v, last, v.Date, timeData); } last = v.Date; lastv = v; } } // Put the last item on the graph if (lastv != null) { AddDatum(lastv, last, end.AddDays(1), timeData); } s.EndUpdate(); //s.Accumulate = false; //s.Color = color; s.Category = cat; s.Start = start; s.End = end; return(s); }
private TrendGraphSeries AddSeries(DateTime start, DateTime end, Color color) { ChartCategory cat = new ChartCategory(); cat.WpfColor = color; nfi.NumberDecimalDigits = 2; nfi.CurrencyNegativePattern = 0; TimeSpan span = (end - start); int days = span.Days; if (days > 360) { cat.Name = start.Year.ToString(); } else { cat.Name = start.ToShortDateString(); } TrendGraphSeries s = new TrendGraphSeries(cat.Name, cat.Name); chartData.AddSeries(s); if ((this.account != null && this.account.Type == AccountType.Credit) || (this.category != null && this.category.Type == CategoryType.Expense)) { s.Flipped = true; } IList <ChartValue> timeData = s.Values; s.BeginUpdate(); bool first = true; double balance = this.account != null ? (double)this.account.OpeningBalance : 0; DateTime last = start; Transaction lastt = null; bool started = this.account != null; foreach (object row in data) { Transaction t = row as Transaction; if (t == null) { continue; } if (t.Account == this.account || // showing transactions for an account (account == null)) // showing transactions by category // && ((!t.IsBudgeted && t.Account.IsBudgeted)) { decimal v = t.GetCategorizedAmount(this.category); if (t.Date >= start && t.Date <= end) { started = true; if (first) { string label = GetLabel(balance, t); timeData.Add(new ChartValue(label, (double)balance, t)); first = false; } balance = AddDatum(balance, last, t.Date, t, timeData, (double)v); last = t.Date; lastt = t; } if (started) { balance += (double)v; } } } if (last != end && lastt != null) { balance = AddDatum(balance, last, end, lastt, timeData, 0); } s.EndUpdate(); //s.Accumulate = false; //s.Color = color; s.Category = cat; s.Start = start; s.End = end; return(s); }
public ActionResult Charts(ChartCategory? category) { const int maxAlbums = 4; HomepageAlbumModel model = null; AlbumRepository repo = new AlbumRepository(); @ViewBag.Category = MainCategory.Charts; category = category ?? ChartCategory.Popular; if (!Enum.IsDefined(typeof(ChartCategory), category)) category = ChartCategory.Popular; @ViewBag.Chart = category; switch (category) { case ChartCategory.Popular: { model = new HomepageAlbumModel() { Name = "Most popular", Albums = Helpers.Convert(repo.GetMostPopular(maxAlbums)) }; break; } case ChartCategory.Biggest: { model = new HomepageAlbumModel() { Name = "Biggest", Albums = Helpers.Convert(repo.GetBiggest(maxAlbums)) }; break; } case ChartCategory.MostComments: { model = new HomepageAlbumModel() { Name = "Most commented", Albums = Helpers.Convert(repo.GetMostCommented(maxAlbums)) }; break; } case ChartCategory.TopRated: { model = new HomepageAlbumModel() { Name = "Highest rated", Albums = Helpers.Convert(repo.GetTopRated(maxAlbums)) }; break; } } return View(model); }
private TrendGraphSeries AddSeries(DateTime start, DateTime end, Color color) { ChartCategory cat = new ChartCategory(); cat.WpfColor = color; nfi.NumberDecimalDigits = 2; nfi.CurrencyNegativePattern = 0; TimeSpan span = (end - start); int days = span.Days; if (days > 360) { cat.Name = start.Year.ToString(); } else { cat.Name = start.ToShortDateString(); } TrendGraphSeries s = new TrendGraphSeries(cat.Name); chartData.AddSeries(s); s.Flipped = generator.IsFlipped; IList <ChartDataValue> timeData = s.Values; TrendValue emptyTrendValue = new TrendValue(); emptyTrendValue.Value = 0; emptyTrendValue.UserData = null; DateTime last = start; TrendValue lastv = emptyTrendValue; foreach (TrendValue v in this.data) { // NOTE: This list is assumed to be sorted if (v.Date > end) { break; } if (v.Date >= start) { // If the items are on the same day, don't add to the graph yet. // Accumulate them and the accumulated value for the day will be displayed if (last != v.Date) { AddDatum(lastv, last, v.Date, timeData); } last = v.Date; } lastv = v; } // Put the last item on the graph AddDatum(lastv, last, end.AddDays(1), timeData); //s.Accumulate = false; //s.Color = color; s.Category = cat; s.Start = start; s.End = end; return(s); }