Beispiel #1
0
        private static void CreateSampleHtmlHistogram()
        {
            var sampleData = new HtmlHistogram.BarData[100];

            for (int i = 0; i < sampleData.Length; i++)
            {
                sampleData[i] = new HtmlHistogram.BarData
                {
                    Value           = (int)(100 + 40 * Math.Sin(i / 10.0)),
                    BarColor        = i < 40 ? "blue" : "green",
                    Width           = 5,
                    BackgroundColor = (i > 60 && i < 90) ? "orange" : ""
                };
            }

            var sampleHtml = new HtmlHistogram()
            {
                TableBackgroundColor = "lightgrey;",
                TableBorderColor     = "lightgrey",
                TableBorderSize      = 5
            }.Build(sampleData, sampleData.Max(x => x.Value).ToString());

            sampleHtml = "<html><body><hr/>" + sampleHtml + "<hr/></body></html>";

            File.WriteAllText("sample.html", sampleHtml);
        }
Beispiel #2
0
        private static string BuildHtmlHistogram(List <DailyCost> dailyCostsHisto, DateTime cutDate)
        {
            double scaleFactor = 100.0 / dailyCostsHisto.Max(x => x.Value);

            var histoData = dailyCostsHisto.Select(item =>
                                                   new HtmlHistogram.BarData()
            {
                Value    = (int)(item.Value * scaleFactor),
                Width    = 5,
                BarColor = item.DT < cutDate ? "blue" : "green"
            });

            string html = new HtmlHistogram()
            {
                TableBackgroundColor = "lightgrey;",
                TableBorderColor     = "lightgrey",
                TableBorderSize      = 5
            }
            .Build(histoData, dailyCostsHisto.Max(x => x.Value).ToString("0.00"));

            return(html);
        }