Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string strAccessConn = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=D:\Faks\Diploma\vs2015\DemoMPE\DemoMPE\App_Data\Asfaltna_baza.mdb";
            string strAccessSelect = "SELECT * FROM gorivo";

            DataSet myDataSet = new DataSet();
            OleDbConnection myAccessConn = null;
            try
            {
                myAccessConn = new OleDbConnection(strAccessConn);
            }
            catch (Exception ex)
            {
                LabelTotalText.Text = $"Error: Failed to create a database connection. \n{ex.Message}";
                return;
            }

            try
            {
                OleDbCommand myAccessCommand = new OleDbCommand(strAccessSelect, myAccessConn);
                OleDbDataAdapter myDataAdapter = new OleDbDataAdapter(myAccessCommand);

                myAccessConn.Open();
                myDataAdapter.Fill(myDataSet, "gorivo");
            }
            catch (Exception ex)
            {
                LabelTotalText.Text = $"Error: Failed to retrieve the required data from the DataBase.\n{ex.Message}";
                return;
            }
            finally
            {
                myAccessConn.Close();
            }

            DataRowCollection dra = myDataSet.Tables["gorivo"].Rows;

            object[,] dataFill = new object[dra.Count, 2];
            for (int j = 0; j < dra.Count; j++)
            {
                dataFill[j, 0] = dra[j][1];
                dataFill[j, 1] = Convert.ToDecimal(dra[j][6]);
            }

            Series serie = new Series { Data = new Data(dataFill) };
            Highstock chart = new Highstock("chart");
            chart.SetSeries(serie);
            chart.SetYAxis(new YAxis { Labels = new YAxisLabels { Formatter = "function() { return Highcharts.numberFormat(this.value, 2) ;}" } });
            chart.SetTooltip(new Tooltip { PointFormat = "Value: {point.y:.2f}" });

            ltrChartGas.Text = chart.ToHtmlString();
        }
Esempio n. 2
0
        public static void AppendHighstock(this StringBuilder sb, Highstock chart)
        {
            foreach (KeyValuePair<string, string> jsVariable in chart.JsVariables)
                sb.AppendLine("var {0} = {1};".FormatWith(jsVariable.Key, jsVariable.Value), 1);

            sb.AppendLine(chart.Name + " = new Highcharts.StockChart({", 1);
            sb.Append(chart.GetOptions(), 2);
            sb.AppendLine("});", 1);

            foreach (KeyValuePair<string, string> jsFunction in chart.JsFunctions)
            {
                sb.AppendLine();
                sb.AppendLine(jsFunction.Key, 1);
                sb.AppendLine(jsFunction.Value, 2);
                sb.AppendLine("}", 1);
            }
        }
Esempio n. 3
0
        public static void AppendHighstock(this StringBuilder sb, Highstock chart)
        {
            foreach (KeyValuePair <string, string> jsVariable in chart.JsVariables)
            {
                sb.AppendLine("var {0} = {1};".FormatWith(jsVariable.Key, jsVariable.Value), 1);
            }

            sb.AppendLine(chart.Name + " = new Highcharts.StockChart({", 1);
            sb.Append(chart.GetOptions(), 2);
            sb.AppendLine("});", 1);

            foreach (KeyValuePair <string, string> jsFunction in chart.JsFunctions)
            {
                sb.AppendLine();
                sb.AppendLine(jsFunction.Key, 1);
                sb.AppendLine(jsFunction.Value, 2);
                sb.AppendLine("}", 1);
            }
        }
Esempio n. 4
0
        protected void Page_Load(object sender, EventArgs e)
        {
            GasContext _db = new GasContext();
            IQueryable<DateTime> gasPricesDate = _db.GasPrices
                .Select(x => x.gasDate);
            var gd = gasPricesDate.ToArray();
            var gds = new string[gd.Length];
            for (int i = 0; i < gd.Length; i++)
            {
                gds[i] = Conversion.getTime(gd[i]).ToString();
            }

            IQueryable<decimal> gasPricesPrice = _db.GasPrices
                .Select(x => x.gasPrice);
            var gp = gasPricesPrice.ToArray();
            var gps = new decimal[gp.Length];
            for (int i = 0; i < gp.Length; i++)
            {
                gps[i] = gp[i];
            }

            object[,] dataFill = new object[gasPricesDate.Count(), 2];
            for (int i = 0; i < gasPricesDate.Count(); i++)
            {
                dataFill[i, 0] = gds[i];
                dataFill[i, 1] = gps[i];
            }

            Series serie = new Series { Data = new Data(dataFill) };
            Highstock chart = new Highstock("chart");
            chart.SetSeries(serie);
            chart.SetYAxis(new YAxis { Labels = new YAxisLabels { Formatter = "function() { return Highcharts.numberFormat(this.value, 2) ;}" } });
            chart.SetTooltip(new Tooltip { PointFormat = "Value: {point.y:.2f}" });

            ltrChartGasPrice.Text = chart.ToHtmlString();
        }