protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            PnlTripData.Visible = true;
            int tripId = Convert.ToInt32(ListBox1.SelectedItem.Text);


            /* Gemiddelde snelheid */
            int averageSpeed = GetAverageSpeed(dataSet, userId, tripId);

            Label5.Text = (averageSpeed * 3.6) + " km/uur";
            int averageSpeedAll = GetAverageSpeed(dataSet, userId);

            Label10.Text = (averageSpeedAll * 3.6) + " km/uur";

            /* linechart */
            LineChart one = newLine(dataSet, "Trip nummer " + tripId, ColorTranslator.FromHtml("#f67027"), 2, userId, tripId);

            ConfigureColors();
            one.ShowLineMarkers = false;
            ChartControl1.Charts.Add(one);
            ChartControl1.RedrawChart();

            /* GoogleMaps */
            String[] Latitude  = GetLatitudes(dataSet, userId, tripId);
            String[] Longitude = GetLongitudes(dataSet, userId, tripId);
            js.Text = BuildScript(Latitude, Longitude);

            welkomstTekst.Text = "Trip is geselecteerd. Klik op een andere trip om deze weer te geven.";


            //int selectedIndex = Convert.ToInt32(ListBox1.SelectedItem.Text);
            //int tripId = selectedIndex;

            //ChartControl1.Charts.Clear();

            ///* Gemiddelde snelheid */
            //int averageSpeed = GetAverageSpeed(dataSet, userId, tripId);
            //Label5.Text = averageSpeed + " km/uur";
            //int averageSpeedAll = GetAverageSpeed(dataSet, userId, 0);
            //Label10.Text = averageSpeedAll + " km/uur";

            ///* linechart */
            //LineChart one = newLine(dataSet, "Trip nummer 1", ColorTranslator.FromHtml("#f67027"), 2, userId, tripId);
            //ConfigureColors();
            //one.ShowLineMarkers = false;
            //ChartControl1.Charts.Add(one);
            //ChartControl1.RedrawChart();

            ///* GoogleMaps */
            //String[] Latitude = GetLatitudes(dataSet, userId, tripId);
            //String[] Longitude = GetLongitudes(dataSet, userId, tripId);
            //js.Text = BuildScript(Latitude, Longitude);
        }
Ejemplo n.º 2
0
    void CreateChart()
    {
        DataTable dtChart = InitializeDtChart();

        dtChart.Rows.Add("Kullanýlan Kredi", this.ChartCreditUsed);
        dtChart.Rows.Add("Alýnan Kredi", this.ChartBoughtCredit);

        PieChart chart = new PieChart();

        chart.DataSource           = dtChart.DefaultView;
        chart.DataXValueField      = "Description";
        chart.DataYValueField      = "Value";
        chart.DataLabels.Visible   = true;
        chart.DataLabels.ForeColor = System.Drawing.Color.Blue;
        chart.Shadow.Visible       = true;
        chart.DataBind();
        chart.Explosion = dtChart.Rows.Count;
        ChartControl1.Charts.Add(chart);
        ChartControl1.RedrawChart();
    }
Ejemplo n.º 3
0
    private void PlotChart()
    {
        // Preparing Data Source For Chart Control
        DataTable  dt  = new DataTable("Chart");
        DataColumn dc  = new DataColumn("Website", typeof(string));
        DataColumn dc1 = new DataColumn("Validation", typeof(int));

        dt.Columns.Add(dc);
        dt.Columns.Add(dc1);
        DataRow dr = dt.NewRow();

        dr[0] = "www.united.com";
        dr[1] = 184;
        dt.Rows.Add(dr);
        DataRow dr1 = dt.NewRow();

        dr1[0] = "www.orbits.com";
        dr1[1] = 9;
        dt.Rows.Add(dr1);
        //Chart type you can change chart type here ex. pie chart,circle chart

        LineChart chart = new LineChart();//Class instance for LineChart

        chart.Fill.Color = Color.FromArgb(50, Color.SteelBlue);
        chart.Line.Color = Color.SteelBlue;
        chart.Line.Width = 2;

        //chart.Legend = "X Axis: Year.\nY Axis: Average";
        chart.Legend = "X Axis: Websites \nY Axis: Validations";
        //looping through datatable and adding to chart control
        foreach (DataRow dr2 in dt.Rows)
        {
            string str = dr2["Website"].ToString();
            chart.Data.Add(new ChartPoint(dr2["Website"].ToString(), (float)System.Convert.ToSingle(dr2["Validation"])));
        }
        ConfigureColors();
        ChartControl1.Charts.Add(chart);
        ChartControl1.RedrawChart();
    }
Ejemplo n.º 4
0
    private void LoadExcel2()
    {
        DataTable  dt = new DataTable("Chart");
        DataColumn dc = new DataColumn("Website", typeof(string));

        //DataColumn dc1 = new DataColumn("Validation", typeof(string));
        dt.Columns.Add(dc);
        //dt.Columns.Add(dc1);
        //DataRow dr = dt.NewRow();

        Excel.Application xlApp       = null;
        Excel.Workbook    xlWorkBook  = null;
        Excel.Worksheet   xlWorkSheet = null;
        Excel.Range       range       = null;
        //Excel.Sheets sheets;

        //string str1, str2;
        //int rCnt = 0;
        //int cCnt = 0;
        //System.Array[] myvalues;
        //string[] strArray;
        object obj;

        try
        {
            xlApp      = new Excel.Application();
            xlWorkBook = xlApp.Workbooks.Open(path1, 0, true, 5, "", "", true, Microsoft.Office.Interop.Excel.XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0);
            //xlWorkSheet = (Excel.Worksheet)xlWorkBook.ActiveSheet;
            //sheets = xlWorkBook.Worksheets;
            //xlWorkSheet = (Excel.Worksheet)sheets.get_Item(1);
            //xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(2);
            xlWorkSheet = (Excel.Worksheet)xlWorkBook.ActiveSheet;
            //str1 = xlWorkBook.Name;
            //str2 = xlWorkSheet.Name;

            int firstRow = 15;
            int lastRow  = 1331;
            for (int i = firstRow; i <= lastRow; i++)
            {
                range = xlWorkSheet.get_Range("A" + i.ToString(), "Z" + i.ToString());
                obj   = range.Cells.Value;
                System.Array myvalues = (System.Array)obj;

                //myvalues = (System.Array)range.Cells.Value;
                //strArray = ConvertToStringArray(myvalues);
                //string str = strArray[1];
                DataRow dr1 = dt.NewRow();
                string  str = myvalues.GetValue(1, 2).ToString();
                dr1[0] = str;
                dt.Rows.Add(dr1);
            }


            var result = dt.AsEnumerable()
                         .GroupBy(r => r.Field <string>("Website"), StringComparer.InvariantCultureIgnoreCase)
                         .Select(r => new
            {
                Str   = r.Key,
                Count = r.Count()
            });

            //LineChart chart = new LineChart();//Class instance for LineChart
            //SmoothLineChart chart = new SmoothLineChart();//Class instance for LineChart
            //AreaChart chart = new AreaChart();//Class instance for LineChart
            ColumnChart chart = new ColumnChart();
            //ScatterChart chart = new ScatterChart();
            //StackedColumnChart chart = new StackedColumnChart();

            chart.Fill.Color         = Color.FromArgb(50, Color.SteelBlue);
            chart.Fill.Type          = InteriorType.Hatch;
            chart.Fill.HatchStyle    = System.Drawing.Drawing2D.HatchStyle.DottedDiamond;
            chart.Fill.ForeColor     = Color.DarkBlue;
            chart.Line.Width         = 1;
            chart.Line.Color         = Color.SteelBlue;
            chart.ShowLineMarkers    = true;
            chart.DataLabels.Visible = true;
            //chart.DataLabels.ShowValue = true;
            //chart.DataLabels.ShowXTitle = true;
            //chart.DataXValueField = "Websites"; ;
            //chart.DataYValueField = "Validations";
            //chart.Legend = "X Axis: Websites \nY Axis: Validations";
            //chart.ShowLegend = true;

            //looping through datatable and adding to chart control

            foreach (var item in result)
            {
                string str = item.Str;
                int    i   = item.Count;
                chart.Data.Add(new ChartPoint(str, (float)System.Convert.ToSingle(i)));
                //Console.WriteLine($"{item.Str} : {item.Count}");
            }

            //chart.DataLabels.ForeColor = Color.White;
            //chart.DataLabels.NumberFormat = "$0.00";
            //chart.DataLabels.Position = DataLabelPosition.Center;
            //chart.DataLabels.Background.Color = Color.SteelBlue;
            //chart.DataLabels.Border.Color = Color.Red;
            //chart.DataLabels.Separator = " ";
            //chart.DataLabels.ShowLegend = true;
            //chart.DataLabels.MaxPointsWidth = 1;
            //chart.ShowLineMarkers = true;
            //chart.LineMarker = new XLineMarker(6, Color.Red, Color.Green);


            //foreach (DataRow dr2 in dt.Rows)
            //{
            //    string str = dr2["Website"].ToString();
            //    chart.Data.Add(new ChartPoint(dr2["Website"].ToString(), (float)System.Convert.ToSingle(dr2["Validation"])));
            //}
            //ChartEngine engine = new ChartEngine();
            //ChartCollection charts = new ChartCollection(engine);
            //engine.Charts = charts;
            //engine.TopChartPadding = 20;
            //charts.Add(chart);


            ConfigureColors();
            ChartControl1.Charts.Clear();
            ChartControl1.Charts.Add(chart);
            ChartControl1.RedrawChart();


            xlWorkBook.Close(false, Missing.Value, Missing.Value);
            xlApp.Quit();
        }
        catch (Exception e)
        {
            string str = e.Message;
        }
        finally
        {
            // Close the Excel process
            releaseObject(range);
            releaseObject(xlWorkSheet);
            releaseObject(xlWorkBook);
            releaseObject(xlApp);
        }
    }
Ejemplo n.º 5
0
    protected void Button2_Click(object sender, EventArgs e)
    {
        Label1.Text = "RATING GIVEN TO '" + DropDownList1.SelectedItem.ToString() + "' FOR '" + DropDownList2.SelectedItem.ToString() + "' = " + DropDownList2.SelectedValue.ToString();
        Label2.Text = DropDownList1.SelectedItem.ToString();
        Label3.Text = DropDownList1.SelectedValue.ToString();
        string st  = DropDownList2.SelectedItem.ToString();
        string ft  = DropDownList2.SelectedValue.ToString();
        float  ft1 = float.Parse(ft);

        ////LineChart c = new LineChart();
        //Chart c = new ColumnChart();
        //c.Data.Add(new ChartPoint("", 0));
        //c.Data.Add(new ChartPoint(st, ft1));
        //c.Data.Add(new ChartPoint("", 0));
        //c.Fill.Color = Color.CornflowerBlue;
        //c.Line.Color = Color.Red;
        //c.DataLabels.Visible = true;

        ////ChartControl1.YCustomStart = 0;
        //ChartControl1.YCustomEnd = 6;
        ////ChartControl1.YValuesInterval = (float)0.5;

        //ChartControl1.Charts.Add(c);
        //ChartControl1.RedrawChart();
        //ChartControl1.Visible = true;


        MapColumnChart cl = new MapColumnChart();

        cl.Legend             = "User A";
        cl.Fill.Color         = Color.Blue;
        cl.DataLabels.Visible = true;
        // cl.DataLabels.Visible = true;
        // cl.Legend = DropDownList1.SelectedItem.ToString();

        ChartPointCollection data2 = cl.Data;

        data2.Add(new ChartPoint("", 0));
        data2.Add(new ChartPoint(st, ft1));
        //data2.Add(new ChartPoint("Mar", 60));
        //data2.Add(new ChartPoint("Apr", 40));
        //data2.Add(new ChartPoint("May", 30));
        //data2.Add(new ChartPoint("Jun", 10));
        //data2.Add(new ChartPoint("Jul", 30));
        //data2.Add(new ChartPoint("Aug", 20));
        //data2.Add(new ChartPoint("Sep", 60));
        //data2.Add(new ChartPoint("Oct", 40));
        //data2.Add(new ChartPoint("Nov", 20));
        //data2.Add(new ChartPoint("Dec", 30));

        cl.Rects = new System.Collections.ArrayList();

        ChartControl1.Charts.Add(cl);

        MapColumnChart c2 = new MapColumnChart();

        c2.Legend     = "User B";
        c2.Fill.Color = Color.DarkBlue;

        data2 = c2.Data;
        data2.Add(new ChartPoint("", 0));
        data2.Add(new ChartPoint(st, 0));
        data2.Add(new ChartPoint("", 0));
        data2.Add(new ChartPoint("", 0));
        data2.Add(new ChartPoint("", 0));
        data2.Add(new ChartPoint("", 0));
        data2.Add(new ChartPoint("", 0));
        data2.Add(new ChartPoint("", 0));
        //data2.Add(new ChartPoint("", 0));
        //data2.Add(new ChartPoint("", 0));
        //data2.Add(new ChartPoint("", 0));
        //data2.Add(new ChartPoint("", 0));

        c2.Rects = cl.Rects;
        ChartControl1.Charts.Add(c2);

        ChartControl1.RedrawChart();
        ChartControl1.YCustomEnd = 6;
        ChartControl1.Visible    = true;
    }