/// <summary> /// 绘制噪声数据比较分析图 /// </summary> private void CreateChart(int line) { if (sRecorder == null) { return; } XYChart c = new XYChart(700, 360); c.setBackground(c.linearGradientColor(0, 0, 0, 100, 0x99ccff, 0xffffff), 0x888888); ChartDirector.TextBox title = c.addTitle("噪声数据比较分析图", "Arial Bold", 13); title.setPos(0, 20); c.setPlotArea(80, 80, 580, 230, 0xffffff, -1, -1, c.dashLineColor( 0xaaaaaa, Chart.DotLine), -1); LegendBox legendBox = c.addLegend(350, 80, false, "Arial", 8); legendBox.setAlignment(Chart.BottomCenter); legendBox.setBackground(Chart.Transparent, Chart.Transparent); legendBox.setLineStyleKey(); legendBox.setFontSize(8); c.xAxis().setIndent(true); c.xAxis().setTitle("噪声频率(Hz)"); c.yAxis().setTitle("噪声幅度(%)"); LineLayer layer1; ChartDirector.DataSet ds; double[] dataSet; double[] da; dataSet = sRecorder.Data.Amplitude.Skip(4).ToArray(); da = sRecorder.Data.Frequency.Skip(4).ToArray(); switch (line) { case 0: layer1 = c.addLineLayer(); ds = layer1.addDataSet(dataSet, GetRandomColor(0), "记录仪" + sRecorder.ID); layer1.setLineWidth(2); layer1.setXData(da); break; case 1: layer1 = c.addSplineLayer(); ds = layer1.addDataSet(dataSet, GetRandomColor(0), "记录仪" + sRecorder.ID); layer1.setLineWidth(2); layer1.setXData(da); break; } if (eRecorder != null && sRecorder.ID != eRecorder.ID) { dataSet = eRecorder.Data.Amplitude.Skip(4).ToArray(); da = eRecorder.Data.Frequency.Skip(4).ToArray(); switch (line) { case 0: layer1 = c.addLineLayer(); ds = layer1.addDataSet(dataSet, GetRandomColor(1), "记录仪" + eRecorder.ID); layer1.setLineWidth(2); layer1.setXData(da); break; case 1: layer1 = c.addSplineLayer(); ds = layer1.addDataSet(dataSet, GetRandomColor(1), "记录仪" + eRecorder.ID); layer1.setLineWidth(2); layer1.setXData(da); break; } } c.xAxis().setLabelStep(15); c.yAxis().setDateScale(0, 120); winChartViewer1.Chart = c; winChartViewer1.ImageMap = c.getHTMLImageMap("clickable", "", "title='噪声频率: {x}Hz, \n{dataSetName}: {value}%'"); }