public async Task getChartJson(string jsonResponse)
        {
            /// get the chart as a POCO
#if tracing
            JsConsole.JsConsole.GroupCollapsed(jsruntime, $"0.1 {id} getChartJson");
            Console.WriteLine("getChartJson(string jsonResponse)"); /// to capture the chart object's json from js
            Console.WriteLine(jsonResponse);                        /// to capture the chart object's json from js
            JsConsole.JsConsole.GroupEnd(jsruntime);
#endif

            chart = JsonSerializer.Deserialize <LinesChartData.Rootobject>(jsonResponse);

            //chart.subtitle.text = "Hello";// TDAChart.LongDateString;

#if tracing
            JsConsole.JsConsole.GroupCollapsed(jsruntime, $"0.2 {id} getChartJson");
            JsConsole.JsConsole.GroupTable(jsruntime, chart, $"{id} getChartJson chart");
            JsConsole.JsConsole.GroupEnd(jsruntime);
#endif

            /// We set some static chart Properties here and pass back to js

            //redraw = true;
            //chartJson = JsonSerializer.Serialize<LinesChartData.Rootobject>(chart);
            //StateHasChanged();

            //#if tracing
            //            Console.WriteLine($"2. {id} getChartJson");
            //            Console.WriteLine(chartJson); /// to capture the chart object's json from js
            //#endif
            await Task.Yield();
        }
Exemple #2
0
        private void Chart_Initialize(string jsonResponse)
        {
            try
            {
                chart = JsonSerializer.Deserialize <LinesChartData.Rootobject>(jsonResponse);
                //

                var data0 = chart.series[0].data;
                //console.log(data0);
                //chart.subtitle.text = "Hello"; // chart.series[0].data dateTime.ToLongDateString();// TDAChart.LongDateString;

                //chart.yAxis[0].title.text = "";
                //chart.yAxis[0].title.style.color = "black";
                chart.series[0].color = "forestgreen";// CONSTANTS.buysColor;
                chart.series[2].color = CONSTANTS.sellsColor;
                chart.series[3].color = "red";
                chart.series[4].color = "teal";
                chart.series[5].color = "magenta";

                if (buysField.StartsWith("asks") || buysField == "buysPriceCount" || buysField.EndsWith("Ratio"))
                {
                    chart.series[0].color = CONSTANTS.asksColor;
                    chart.series[2].color = CONSTANTS.bidsColor;

                    chart.series[0].name = "Asks";
                    chart.series[2].name = "Bids";
                    //chart.series[3].color = CONSTANTS.asksColor;
                    //chart.series[4].color = CONSTANTS.bidsColor;
                    chart.series[0].type = "spline";
                    chart.series[2].type = "spline";
                }
                else if (buysField.Contains("Above") || buysField.Contains("Below") || buysField.Contains("Sprread"))
                {
                    chart.series[0].type = "spline";
                    chart.series[2].type = "spline";
                    chart.series[0].name = "Below";
                    chart.series[2].name = "Above";
                }
                else
                {
                    chart.series[0].name = "Buys";
                    chart.series[2].name = "Sells";

                    chart.series[0].type = "spline";
                    chart.series[2].type = "spline";
                }


#if tracing
                JsConsole.JsConsole.GroupCollapsed(jsruntime, $"0.2 {id} getChartJson");
                JsConsole.JsConsole.GroupTable(jsruntime, chart, $"{id} getChartJson chart");
                JsConsole.JsConsole.GroupEnd(jsruntime);
#endif

                /// We set some static chart Properties here and pass back to js

                //redraw = true;
                chartJson = JsonSerializer.Serialize <LinesChartData.Rootobject>(chart);
            }
            catch (Exception ex)
            {
            }
        }