private static void Series_AddItems(Dictionary <string, BookDataItem[]> bookDataItems, Surface.Series1 seriesItem, string seriesName) { foreach (var item in bookDataItems[seriesName]) /// item is one BookDataItem { /// Place bookitem Sizes in Series1 data var index = Surface3dManager.lstPrices.IndexOf(item.Price.ToString("n2")); //seriesItem.data[] var data = new Surface.Datum() { x = index, y = SurfaceChartConfigurator.isFlat ? 0 : item.Size, z = (int?)Math.Min(Math.Floor((double)seriesList.Count / 2), 100), color = dictSeriesColor[seriesName], }; seriesItem.data[index] = data; } }
private void Chart_BuildSeriesData(Dictionary <string, BookDataItem[]> bookDataItems, string[] categories, List <Surface.Series1> seriesList) { var seriesOrder = new string[] { "salesAtBid", "bids", "salesAtAsk", "asks" }; ///// Remove any over 600*4 series (10 minutes) ///// //var minutesToKeep = 10; //var seriesToKeep = minutesToKeep * seriesOrder.Length * 60; //seriesToKeep = (int)Surface3dManager.chart.zAxis.max - 1; // seriesList = seriesList.Take(seriesToKeep).ToList(); ///// Remove previous 4 series from the legend ///// They will be the first four series ///// //foreach (var series in seriesList.Take(seriesOrder.Length)) //{ // series.showInLegend = false; //} ////jsruntime.Confirm("Chart_BuildSeriesData: 1"); lstNewSeries = new List <Surface.Series1>(); /// Remove the two empty series at start // will be at end now if (seriesList.Count > 1) { seriesList.RemoveAt(0); seriesList.RemoveAt(0); } ////jsruntime.Confirm("Chart_BuildSeriesData: 2"); /// Prepare empty series to posit new values into var seriesItem = new Surface.Series1() /// Chart Series1 item { // This array needs to be the 100 slots and Size put in slot for Price data = new Surface.Datum?[Surface3dManager.lstPrices.Count()], showInLegend = false }; ////jsruntime.Confirm("Chart_BuildSeriesData: 3"); /// Populate the new series if (!SurfaceChartConfigurator.isTimeSalesOnly) { for (int i = 0; i < bookDataItems.Count; i++) { /// Create the series one series item for all 4 book types var seriesName = seriesOrder[i]; /// Dictionary where values are BookDataItem[] /// Fill out the series data (needs to be 2d) /// /// if (seriesName.Length > 4) /// Bids and Asks the Book { Series_AddItems(bookDataItems, seriesItem, seriesName); } /// Add a //item.Size; /// Add to chart Series1 as first series /// Set chart Series1 } /// Add the series to the list /// lstNewSeries.Add(seriesItem); seriesList.Insert(0, seriesItem); } ////jsruntime.Confirm("Chart_BuildSeriesData: 4"); seriesItem = new Surface.Series1() /// Chart Series1 item { // This array needs to be the 100 slots and Size put in slot for Price data = new Surface.Datum?[Surface3dManager.lstPrices.Count()], showInLegend = false }; ////jsruntime.Confirm("Chart_BuildSeriesData: 5"); for (int i = 0; i < bookDataItems.Count; i++) { /// Create the series one series item for all 4 book types var seriesName = seriesOrder[i]; /// Dictionary where values are BookDataItem[] /// Fill out the series data (needs to be 2d) /// /// if (seriesName.Length == 4) /// Time & Sales { Series_AddItems(bookDataItems, seriesItem, seriesName); } /// Add a //item.Size; /// Add to chart Series1 as first series /// Set chart Series1 } ////jsruntime.Confirm("Chart_BuildSeriesData: 6"); lstNewSeries.Add(seriesItem); seriesList.Insert(0, seriesItem); ////jsruntime.Confirm("Chart_BuildSeriesData: 7"); seriesItem.selected = true; seriesItem = new Surface.Series1() /// Chart Series1 item { // This array needs to be the 100 slots and Size put in slot for Price data = new Surface.Datum?[Surface3dManager.lstPrices.Count()], showInLegend = false }; seriesList.Insert(0, seriesItem); seriesList.Insert(0, new Surface.Series1()); ////jsruntime.Confirm("Chart_BuildSeriesData: 8"); /// TODO: /// 1. Don't remove any series data, just control how much passed to //if (seriesList.Count() > Surface3dManager.chart.zAxis.max - 2) //{ // for (var i = 0; i < 2; i++) // seriesList.Remove(seriesList.Last()); //} if (seriesList.Count() == Surface3dManager.chart.zAxis.max - 2) { SurfaceChartConfigurator.redrawChart = true; StateHasChanged(); } //else if (seriesList.Count() % 10 == 0 || seriesList.Count() % 11 == 0 && seriesList.Count() < Surface3dManager.chart.zAxis.max - 2) // SurfaceChartConfigurator.redrawChart = !SurfaceChartConfigurator.redrawChart; //jsruntime.Confirm("Chart_BuildSeriesData: 9"); if (SurfaceChartConfigurator.isTimeSalesOnly) { /// Hide all non-sales series //foreach(var series in seriesList) //{ // series. //} } }