//Main code for creating chart. //Note: the argument img is unused because this demo only has 1 chart. public void createChart(WinChartViewer WebChartViewer1, string img, int stockId, int timeFrameId, DateTime fromDt, DateTime toDt, int ballSize, int chartWidth, int chartHeighth, int priceType) { var stock = (from s in dataContext.stocks where s.id == stockId select s).FirstOrDefault(); if (stock == null) { errMsg(WebChartViewer1, "Инструмент не найден"); return; } var quotes = (from q in dataContext.volquotes where q.stock == stockId && q.timeframe == timeFrameId && q.datetime >= fromDt && q.datetime <= toDt.AddDays(1) orderby q.datetime ascending select q); VolQuotesLst = quotes.ToList(); if (quotes == null || quotes.Count() == 0) { errMsg(WebChartViewer1, "Данные отсутствуют"); return; } var ValueAtRisk_dt = from ml in dataContext.valueatrisk where ml.stock == stockId && ml.timeframe == timeFrameId && ml.datetime >= fromDt && ml.datetime <= toDt.AddDays(1) select ml; ValueAtRiskLst = ValueAtRisk_dt.ToList(); var timeFrame = (from t in dataContext.timeframes where t.id == timeFrameId select t).FirstOrDefault(); if (timeFrame == null) { errMsg(WebChartViewer1, "Тайм фрейм отсутствуют"); return; } string tickerKey = stock.ticker.Trim(); // The data series we want to get. if (!getData(fromDt, toDt)) { errMsg(WebChartViewer1, "Инструмент не найден"); return; } //------------- // Create the chart object using the selected size FinanceChart m = new FinanceChart(chartWidth); string[] monthNames = { "Янв", "Фев", "Мар", "Апр", "Май", "Июн", "Июл", "Авг", "Сен", "Окт", "Ноя", "Дек" }; m.setMonthNames(monthNames); m.setDateLabelFormat("{value|yyyy}", "<*font=bold*>{value|mmm yy}", "{value|mm/yy}", "<*font=bold*>{value|d mmm}", "{value|d}", "<*font=bold*>{value|d mmm<*br*>h:nna}", "{value|h:nna}"); // Set the data into the chart object m.setData(timeStamps, highData, lowData, openData, closeData, VolumeData, 0); // // We configure the title of the chart. In this demo chart design, we put the // company name as the top line of the title with left alignment. // m.addPlotAreaTitle(Chart.TopLeft, tickerKey); m.addPlotAreaTitle(Chart.BottomLeft, "<*font=Arial,size=8*>" + m.formatValue( fromDt, "dd MMM, yyyy") + " - " + m.formatValue( toDt, "dd MMM, yyyy")); // A copyright message at the bottom left corner the title area m.addPlotAreaTitle(Chart.BottomRight, " "); //-- int mainHeight = 450; int indicatorHeight = 110; // // Add the main chart // XYChart MainChart = m.addMainChart(mainHeight); m.addBarIndicator(indicatorHeight * 2, ValueAtRisk_Data, 0x0066ff, "Value-At-Risk"); //--------------------- m.addCandleStick(0x33ff33, 0xff3333); m.addVolBars(indicatorHeight, 0x99ff99, 0xff9999, 0xc0c0c0); // Output the chart WebChartViewer1.Image = m.makeImage(); }