예제 #1
0
 private void AppendSeries(ChartGenerator chart, IEnumerable dataSource, string title)
 {
     if (((ICollection)dataSource).Count > 0)
     {
         chart.CreateSeries(title, dataSource, "InDate", "Count");
     }
 }
예제 #2
0
파일: TradingSystem.cs 프로젝트: bg0jr/Maui
        public TradingSystem( string name )
        {
            Name = name;

            myIndicator = new CombinedIndicator();
            AdditionalReportGenerators = new List<IReportGenerator>();
            myChartGenerator = new ChartGenerator();
        }
예제 #3
0
        public TradingSystem(string name)
        {
            Name = name;

            myIndicator = new CombinedIndicator();
            AdditionalReportGenerators = new List <IReportGenerator>();
            myChartGenerator           = new ChartGenerator();
        }
        //private void PopulateChart(string chartType)
        //{
        //    var chartData = GetChartData();
        //    ChartGenerator chartGenerator = new ChartGenerator(chartType, chartData);
        //    ReportHtml =  chartGenerator.GenerateChart();
        //}

        private async void PopulateChart(string chartType, string url)
        {
            var chartData = await GetChartDataFromUrl(url);

            ChartGenerator chartGenerator = new ChartGenerator(chartType, chartData);

            ReportHtml = chartGenerator.GenerateChart();
        }
예제 #5
0
        private void LoadChart(ChartGenerator chart)
        {
            var axis = this.GenerateAxis(chart.DataSources);

            chart.LoadChart(this.ChartContainer, axis);

            //chart.LoadChart(this.ChartContainer, this.GenerateAxis(chart.DataSources));
        }
예제 #6
0
 protected DQN(Shape inputShape, int numberOfActions, float learningRate, float discountFactor, int batchSize, BaseExperienceReplay memory)
     : base(inputShape, numberOfActions, learningRate, discountFactor)
 {
     BatchSize  = batchSize;
     Memory     = memory;
     ErrorChart = new ChartGenerator($"dqn_error", "Q prediction error", "Episode");
     ErrorChart.AddSeries(0, "Abs error", System.Drawing.Color.LightGray);
     ErrorChart.AddSeries(1, $"Avg({ErrorAvg.N}) abs error", System.Drawing.Color.Firebrick);
     ImportanceSamplingWeights = new Tensor(new Shape(1, numberOfActions, 1, batchSize));
 }
예제 #7
0
        private void OnLoadCompleted(ChartGenerator chart, IEnumerable list, IEnumerable uniqueList)
        {
            this.AppendSeries(chart, list, QueryReportResource.Chart_Title_LoginCount);
            this.AppendSeries(chart, uniqueList, QueryReportResource.Chart_Title_UniqueLoginCount);

            this.ChartContainer.Children.Clear();
            this.CloseLoading();
            this.BtnSearch.IsEnabled = true;

            this.LoadChart(chart);
        }
예제 #8
0
    public void ChangeColors()
    {
        ChartGenerator chartgen = this.GetComponent <ChartGenerator>();

        Color[] tempcolors = new Color[chartgen.numcolors()];

        chartgen.colors.CopyTo(tempcolors, 0);
        newcolors.CopyTo(chartgen.colors, 0);
        tempcolors.CopyTo(newcolors, 0);

        chartgen.getchart();
    }
        public ActionResult BondBreakdownChart(AssetBreakdown assetBreakdown)
        {
            List<string> keys = new List<string>();
            List<decimal> values = new List<decimal>();

            keys.Add("Total Domestic");
            keys.Add("Total International");

            values.Add(assetBreakdown.TotalDomesticBonds ?? 0);
            values.Add(assetBreakdown.TotalInternationalBonds ?? 0);

            ChartGenerator cg = new ChartGenerator();
            MemoryStream ms = cg.GenerateChart(keys.ToArray(), values.ToArray(), SeriesChartType.Pie, 400, 200, false, true, false);
            return File(ms.ToArray(), "image/png", "mychart.png");
        }
예제 #10
0
        private void Button1_Click_1(object sender, EventArgs e)
        {
            LoadingSpinner ls = new LoadingSpinner(this, AppMessages.messages["data_save"]);

            try
            {
                ls.show();
                ExcelReader excelReader = new ExcelReader();
                excelReader.saveExcelFromDataGridView(
                    new DataGridView[2] {
                    dataGridView1, dataGridView2
                },
                    new int[2] {
                    1, 2
                },
                    new string[2] {
                    "Sales Forecast", "Cost Of Sales"
                }
                    );

                TableGenerator tbl = new TableGenerator();
                tbl.GenerateMultipleTable(new DataGridView[2] {
                    dataGridView1, dataGridView2
                }, "sales_forecast_table.rtf", new string[2] {
                    "Sales Forecast", "Cost Of Sales"
                });
                ChartGenerator cgr = new ChartGenerator();
                cgr.generateBarChart(dataGridView1, "generate.png", "Forecast Sales");
                cgr.ImageToRtf("sales_forecast_table.rtf", "generate.png");
                cgr.generateBarChart(dataGridView2, "generate1.png", "Cost of Sales");
                cgr.ImageToRtf("sales_forecast_table.rtf", "generate1.png");
                Label       l    = mw.Controls.Find("label4", true)[0] as Label;
                ProgressBar pbar = mw.Controls.Find("progressBar1", true)[0] as ProgressBar;
                dgp.updateProgress("sales_forecast_table.rtf", dataGridView1.Rows.Count > 0 && dataGridView2.Rows.Count > 0 ? 1 : 0);
                l.Text     = dgp.completedSteps().ToString() + " /";
                pbar.Value = dgp.completedSteps();
                l.Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show("Exception: " + ex.Message);
            }
            finally
            {
                ls.hide();
            }
        }
예제 #11
0
        private void InitializeChart()
        {
            var         loadCompletedCount = 0;
            var         chart      = new ChartGenerator();
            var         query      = this.GetQueryCritiera();
            IEnumerable list       = null;
            IEnumerable uniqueList = null;


            this.ShowLoading();
            this.BtnSearch.IsEnabled = false;

            this.m_restClient.Query <ObservableCollection <LoginStatisticsModel> >("QueryLoginStatistic", query, (obj, args) =>
            {
                if (args.FaultsHandle(this))
                {
                    return;
                }

                Interlocked.Increment(ref loadCompletedCount);

                list = args.Result.OrderBy(p => p.InDate).ToList();

                if (loadCompletedCount == 2)
                {
                    OnLoadCompleted(chart, list, uniqueList);
                }
            });

            this.m_restClient.Query <ObservableCollection <LoginStatisticsModel> >("QueryUniqueLoginStatistic", query, (obj, args) =>
            {
                if (args.FaultsHandle(this))
                {
                    return;
                }

                Interlocked.Increment(ref loadCompletedCount);

                uniqueList = args.Result.OrderBy(p => p.InDate).ToList();


                if (loadCompletedCount == 2)
                {
                    OnLoadCompleted(chart, list, uniqueList);
                }
            });
        }
예제 #12
0
 private void Button1_Click(object sender, EventArgs e)
 {
     if (validateData())
     {
         LoadingSpinner ls = new LoadingSpinner(this, AppMessages.messages["data_save"]);
         try
         {
             ls.show();
             ExcelReader excelReader = new ExcelReader();
             excelReader.saveExcelFromDataGridView(
                 new DataGridView[1] {
                 dataGridView1
             },
                 new int[1] {
                 1
             },
                 new string[1] {
                 "Market Analysis"
             }
                 );
             TableGenerator tbl = new TableGenerator();
             tbl.Generate(dataGridView1, "market_analysis.rtf");
             ChartGenerator cgen = new ChartGenerator();
             cgen.generatePieChart(dataGridView1, "generated.png", "Market Analysis");
             cgen.ImageToRtf("market_analysis.rtf", "generated.png");
             Label       l    = mw.Controls.Find("label4", true)[0] as Label;
             ProgressBar pbar = mw.Controls.Find("progressBar1", true)[0] as ProgressBar;
             dgp.updateProgress("market_analysis.rtf", dataGridView1.Rows.Count > 0 ? 1 : 0);
             l.Text     = dgp.completedSteps().ToString() + " /";
             pbar.Value = dgp.completedSteps();
             l.Refresh();
         }
         catch (Exception ex)
         {
             MessageBox.Show("Exception: " + ex.Message);
         }
         finally
         {
             ls.hide();
         }
     }
     else
     {
         MessageBox.Show("Percentage cannot exceed 100 !");
     }
 }
        public ActionResult AllAssetBreakdownChart(AssetBreakdown assetBreakdown)
        {
            List<string> keys = new List<string>();
            List<decimal> values = new List<decimal>();

            keys.Add("Total Cash");
            keys.Add("Total Real Estate");
            keys.Add("Total Stocks");
            keys.Add("Total Bonds");

            values.Add(assetBreakdown.TotalCash ?? 0);
            values.Add(assetBreakdown.TotalRealEstate ?? 0);
            values.Add(assetBreakdown.TotalStock ?? 0);
            values.Add(assetBreakdown.TotalBonds ?? 0);

            ChartGenerator cg = new ChartGenerator();
            MemoryStream ms = cg.GenerateChart(keys.ToArray(), values.ToArray(), SeriesChartType.Pie, 400, 200, false, true, false);
            return File(ms.ToArray(), "image/png", "mychart.png");
        }
예제 #14
0
        private void ProcessChartRequest(HttpRequestMessage request, HttpResponseMessage response)
        {
            ChartData chartData;
            XElement  chartElement;
            string    title;

            NameValueCollection parameters = request.RequestUri.ParseQueryString();
            int           chartID          = Convert.ToInt32(parameters["chartID"]);
            ChartIdentity chartIdentity    = new ChartIdentity(m_eventID, m_templateID, chartID);

            if (s_chartLookup.TryGetValue(chartIdentity, out chartData))
            {
                chartElement = chartData.ChartElement;
            }
            else
            {
                XDocument doc = XDocument.Parse(ApplyTemplate(request), LoadOptions.PreserveWhitespace);
                chartElement = doc.Descendants("chart").Skip(chartID).FirstOrDefault();
            }

            if ((object)chartElement == null)
            {
                response.StatusCode = HttpStatusCode.NotFound;
                return;
            }

            title = (string)chartElement.Attribute("yAxisTitle");

            using (DataContext dataContext = new DataContext())
                using (DbAdapterContainer dbAdapterContainer = new DbAdapterContainer((SqlConnection)dataContext.Connection.Connection))
                {
                    response.Content = new StreamContent(ChartGenerator.ConvertToChartImageStream(dbAdapterContainer, chartElement));
                    response.Content.Headers.ContentDisposition          = new ContentDispositionHeaderValue("attachment");
                    response.Content.Headers.ContentDisposition.FileName = title + ".png";
                    response.Content.Headers.ContentType = new MediaTypeHeaderValue("image/png");
                }
        }
예제 #15
0
    void Start() //pass parameters to visualization creation
    {
        //disable component so that views are not created from it
        ChartGenerator chartgen = gameObject.AddComponent <ChartGenerator>();

        //chartgen.autostart = true;

        //Passing parameters for visualization creation
        chartgen.charttype = ChartGenerator.ChartType.BarChartVertical;
        chartgen.title     = "Chart title";
        chartgen.xlabel    = "x label";
        chartgen.x         = "orange, pineapple, apple, blueberry";
        chartgen.ylabel    = "y label";
        chartgen.y         = "2, 2.30, 6, 2.1";
        //chartgen.zlabel = "z label";
        //chartgen.z = "xiaomi, xbox, hp, aoc";

        Color[] colors = { Color.blue, Color.gray, Color.magenta, Color.white };
        chartgen.colors = colors;


        //getchart voilà - only with autostart == false
        chartgen.getchart();
    }
예제 #16
0
    // ReadDatabaseGenVis datasetbuffer = new ReadDatabaseGenVis(); // TODO: buffer every dataset on a object (big think: is it possible to save on disk pkl like?)

    void OnEnable()
    {
        script = (ChartGenerator)target;
    }
예제 #17
0
 public EmailManager()
 {
     _dataManager    = ContainerHelper.Container.Resolve <IDataManager>();
     _chartGenerator = new ChartGenerator();
 }
예제 #18
0
        public ActionResult Index()
        {
            ViewBag.Message = "Modify this template to jump-start your ASP.NET MVC application.";
            //List<SensorLog> log = _sensorService.GetSensorLog(1);
            //List<SensorLog> log2 = _sensorService.GetSensorLog(2);

            List <SensorLog> log      = new List <SensorLog>();
            List <SensorLog> log2     = new List <SensorLog>();
            string           dataFile = Server.MapPath("~/Data/datalog.txt");
            // Read the file and display it line by line.
            string line;

            System.IO.StreamReader file = new System.IO.StreamReader(dataFile);
            while ((line = file.ReadLine()) != null)
            {
                string[] row = line.Split(':');

                int      microSecond = int.Parse(row[0]);
                string[] values      = row[1].Split(';');

                int pot1 = int.Parse(values[0]);
                int pot2 = int.Parse(values[1]);
                int pot3 = int.Parse(values[2]);

                SensorLog logRecord = new SensorLog();
                logRecord.SensorId    = 1;
                logRecord.MicroSecond = microSecond;
                logRecord.Value       = pot1;
                log.Add(logRecord);

                SensorLog logRecord2 = new SensorLog();
                logRecord2.SensorId    = 2;
                logRecord2.MicroSecond = microSecond;
                logRecord2.Value       = pot2;
                log2.Add(logRecord2);
            }

            file.Close();

            SensorChart  chart = new SensorChart();
            SensorSeries fl    = new SensorSeries();

            fl.SensorData         = log;
            fl.XField             = "MicroSecond";
            fl.YField             = "Value";
            fl.LineColor          = "Red";
            chart.FrontLeftSensor = fl;

            SensorSeries fr = new SensorSeries();

            fr.SensorData          = log2;
            fr.XField              = "MicroSecond";
            fr.YField              = "Value";
            fr.LineColor           = "Blue";
            chart.FrontRightSensor = fr;

            ChartGenerator chartGenerator = new ChartGenerator();
            string         imagePath      = Server.MapPath("~/images/charts/sensorLog.png");

            chartGenerator.GenerateChart(imagePath, chart, "Milli Seconds", "Sensor Value");

            return(View());
        }
        public void BuildReportHtml(string chartType)
        {
            ChartGenerator chartGenerator = new ChartGenerator(ChartDataModel, chartType);

            ReportHtml = chartGenerator.GenerateChart();
        }
예제 #20
0
    //! Setup of reagent liquid in all machines.
    public void Setup(string reagent, float concentration)
    {
        Compound realReagent = CompoundFactory.GetInstance().GetCupboardCompound(reagent) as Compound;

        if (realReagent == null)
        {
            Debug.LogWarning("Reagent not seted in database");
            return;
        }


        allowShowFloat   = false;
        allowShowTexture = false;

        bool showFloat = false;

        switch (myType)
        {
        default:
        {
            setupFloat       = 0f;
            setupTexture     = null;
            allowShowFloat   = false;
            allowShowTexture = false;
        }
        break;

        case MACHINES.CONDUTIVIMETER:
        {
            setupFloat = realReagent.Conductibility;
            showFloat  = true;

            InventoryController inventory = FindObjectOfType(typeof(InventoryController)) as InventoryController;
        }
        break;

        case MACHINES.SPCTROPHOTOMETER_UV:
        {
            setupTexture     = realReagent.uvSpecter;
            allowShowTexture = true;

            InventoryController inventory = FindObjectOfType(typeof(InventoryController)) as InventoryController;
        }
        break;

        case MACHINES.SPCTROPHOTOMETER_IR:
        {
            setupTexture     = realReagent.irSpecter;
            allowShowTexture = true;

            InventoryController inventory = FindObjectOfType(typeof(InventoryController)) as InventoryController;
        }
        break;

        case MACHINES.TURBIDOMETER:
        {
            setupFloat = realReagent.Turbidity;
            showFloat  = true;

            InventoryController inventory = FindObjectOfType(typeof(InventoryController)) as InventoryController;
        }
        break;
        }

        if (showFloat)
        {
            resultFloat *= concentration;

            string errorStringForm = "0";
            if (errorPrecision > 0)
            {
                errorStringForm = "0.";
                for (int i = 0; i < errorPrecision; i++)
                {
                    errorStringForm += "0";
                }
            }

            textResult.text = applyErrorInFloat(resultFloat).ToString(errorStringForm);
        }

        if (allowShowTexture)
        {
            setupTexture = ChartGenerator.GenerateWithTextureConectingDots(setupTexture, concentration, 0.8f);
            HudText.SetText("O grafico foi Impresso!");
            GameObject.FindObjectOfType <PrinterUse>().SendFileToPrinter(setupTexture);
            timeToShowPrintTextAcc = Time.time;
        }
    }
        public ActionResult NetWorthChart(decimal totalAssets, decimal totalLiabilities, decimal netWorth)
        {
            List<string> keys = new List<string>();
            List<decimal> values = new List<decimal>();

            keys.Add(string.Format("Net worth {0:C}", netWorth));
            keys.Add(string.Format("Total Liabilities {0:C}", totalLiabilities));
            keys.Add(string.Format("Total Assets {0:C}", totalAssets));

            values.Add(netWorth);
            values.Add(totalLiabilities);
            values.Add(totalAssets);

            ChartGenerator cg = new ChartGenerator();
            MemoryStream ms = cg.GenerateChart(keys.ToArray(), values.ToArray(), SeriesChartType.Bar, 400, 200, true, false, true);
            return File(ms.ToArray(), "image/png", "mychart.png");
        }
        public ActionResult RetirementEstimateChart(decimal totalAssets, decimal amountToCoverExpenses)
        {
            List<string> keys = new List<string>();
            List<decimal> values = new List<decimal>();

            decimal remainingAssetsNeeded = amountToCoverExpenses - totalAssets;
            keys.Add("Remaing needed");
            keys.Add("Total accumulated");

            values.Add(remainingAssetsNeeded);
            values.Add(totalAssets);

            ChartGenerator cg = new ChartGenerator();
            MemoryStream ms = cg.GenerateChart(keys.ToArray(), values.ToArray(), SeriesChartType.Pie, 400, 200, false, true, false);
            return File(ms.ToArray(), "image/png", "mychart.png");
        }
        public ActionResult ExpensesChart(bool isManditory)
        {
            List<string> keys = new List<string>();
            List<decimal> values = new List<decimal>();
            List<ExpenseAverage> expenseAverages;

            if (isManditory)
                expenseAverages = repository.GetMandatoryExpenseAverages(UserId);
            else
                expenseAverages = repository.GetDiscretionaryExpenseAverages(UserId);

            foreach (ExpenseAverage avg in expenseAverages)
            {
                keys.Add(avg.Name);
                values.Add(avg.Average);
            }

            ChartGenerator cg = new ChartGenerator();
            MemoryStream ms = cg.GenerateChart(keys.ToArray(), values.ToArray(), SeriesChartType.Pie, 700, 500, false, false, true);
            return File(ms.ToArray(), "image/png", "mychart.png");
        }
예제 #24
0
    //! Uses of reagent liquid in all machines.
    public void Use(string reagent, float concentration)
    {
        Compound realReagent = CompoundFactory.GetInstance().GetCupboardCompound(reagent) as Compound;

        if (realReagent == null)
        {
            Debug.LogWarning("Reagent not seted in database");
            return;
        }

        switch (myType)
        {
        case MACHINES.PHMETER:
        {
            resultFloat      = realReagent.PH;
            allowShowFloat   = true;
            allowShowTexture = false;
        }
        break;

        case MACHINES.CONDUTIVIMETER:
        {
            resultFloat      = realReagent.Conductibility - setupFloat;
            allowShowFloat   = true;
            allowShowTexture = false;
        }
        break;

        case MACHINES.SPCTROPHOTOMETER_UV:
        {
            resultTexture    = realReagent.uvSpecter;
            allowShowFloat   = false;
            allowShowTexture = true;
        }
        break;

        case MACHINES.SPCTROPHOTOMETER_IR:
        {
            resultTexture    = realReagent.irSpecter;
            allowShowFloat   = false;
            allowShowTexture = true;
        }
        break;

        case MACHINES.SPCTROPHOTOMETER_FLAME:
        {
            resultTexture = Resources.Load <Texture2D>("specter/grafico_sem_fitting");
            //resultTexture = realReagent.flameSpecter;
            allowShowFloat   = false;
            allowShowTexture = true;
        }
        break;

        case MACHINES.POLARIMETER:
        {
            resultFloat      = realReagent.Polarizability;
            allowShowFloat   = true;
            allowShowTexture = false;
        }
        break;

        case MACHINES.HPLC:
        {
            resultTexture    = realReagent.hplc;
            allowShowFloat   = false;
            allowShowTexture = true;
        }
        break;

        case MACHINES.REFRATOMETER:
        {
            resultFloat      = realReagent.Refratometer;
            allowShowFloat   = true;
            allowShowTexture = false;
        }
        break;

        case MACHINES.TURBIDOMETER:
        {
            resultFloat      = realReagent.Turbidity - setupFloat;
            allowShowFloat   = true;
            allowShowTexture = false;
        }
        break;
        }

        InventoryController inventory = FindObjectOfType(typeof(InventoryController)) as InventoryController;

        //!Prints the chart
        if (allowShowTexture)
        {
            resultTexture = ChartGenerator.GenerateWithTextureConectingDots(resultTexture, concentration, 0.8f);
            GameObject.FindObjectOfType <PrinterUse>().SendFileToPrinter(setupTexture);

            HudText.SetText("O grafico foi Impresso!");
            timeToShowPrintTextAcc = Time.time;
        }

        if (allowShowFloat)
        {
            resultFloat *= concentration;
        }
    }