请问这样的图片怎样绘制:
 第一个图是柱状图不使用flash,第二个图也可称为折线图吧,都使c# GDI+进行绘制。

解决方案 »

  1.   

    参看《GDI+中文帮助》第一个图很简单。
    第二个,只有折线是绘制的么?其他的文字表格用什么做的?
      

  2.   

    (1) 第一个的话,直接用DrawLine()划线,中间的矩形框用蓝色的刷子FillRectangle()
    (2) 第二个不会连表格和内容也要画出来吧。。(OMG)。后面的划线的话,你需要根据人格因素的得分知道每个得分点的坐标,再划线链接来就可以了。
      

  3.   

    绘制吧,就麻烦一点。不是很复杂的,能把这两个图画出来,
    gdi+的各种方法也算基本接触到了。
      

  4.   


    其实也不是很复杂,只要把每行的位置记录清楚就行了,计算起来,就是一个for循环的事情
      

  5.   


    有几个难点:
    第一张图:y轴刻度是不确定的,x轴点个数是不确定的(这个好办)
    第二张图:使用Aspose.Cells生成excel存成图片,问题是怎样获得选中点,除非将标准分一列看成坐标,
    那就对这个图片进行重绘,关于重绘又是一无所知,本身这个项目(心理测评)难度重重,可以交工了,就剩这点不太完美,请各位达人献计献策,自己也潜心研究。
      

  6.   

    public static Image DrawAnalysisPic(DataTable dt)
           {
               
               Aspose.Chart.Chart chart = new Aspose.Chart.Chart();
               chart.Height = 300;
               chart.Width = 500;
               int Rc = dt.Rows.Count;
               Series[] seriesArray = new Series[Rc];
               
               for (int seriesIdx = 0; seriesIdx < seriesArray.Length; seriesIdx++)
               {
                   int colIdx = seriesIdx + 1;
                   Series series = new Series();
                   series.ChartType = ChartType.Bar;
                   series.CustomAttributes.IsAreaStacked = true;
                   series.Name = dt.Rows[seriesIdx][0].ToString();
                   seriesArray[seriesIdx] = series;
                   series.IsPrimaryAxisX = true;
                   series.CustomAttributes.BarWidthRate = (float)0.5;
                   //series.CustomAttributes.IsBarHorizontal = true;//垂直
                  // series.CustomAttributes.IsBarCone = true;//尖角
                   //series.CustomAttributes.BarWidth = (float)10;
               }
                           double minY = double.MaxValue;
               double maxY = double.MinValue;
                
               int i = 0;
               for (int rowIdx = 0; rowIdx < Rc; rowIdx++)
               {
                   i++;
                   double GenvelValue = Convert.ToDouble(dt.Rows[rowIdx][1].ToString());
                   seriesArray[rowIdx].DataPoints.Add(i, GenvelValue);
                   minY = Math.Min(minY, GenvelValue);
                   maxY = Math.Max(maxY, GenvelValue);
               }           chart.ChartArea.AxisX.IsAutoCalc = false;
               chart.ChartArea.AxisY.IsAutoCalc = false;
               chart.ChartArea.AxisX.IntervalType = IntervalType.String;
              
            
               chart.ChartArea.AxisX.Minimum = 0;
               chart.ChartArea.AxisX.Maximum = Rc + 8;
               chart.ChartArea.AxisY.Minimum = 0;
               chart.ChartArea.AxisY.Maximum = maxY;
               chart.ChartArea.ClusterWidthRate = 0.1F;           for (int seriesIdx = 0; seriesIdx < seriesArray.Length; seriesIdx++)
               {
                   chart.SeriesCollection.Add(seriesArray[seriesIdx]);
                  
               }
               chart.ChartArea.ClusterWidthRate = (float)0.8;
               return chart.GetChartImage(); 
           } 现在使用Aspose.Chart进行解决,但不完美的地方是,柱图之间的间距还有就是x轴使用文字而非数字,右边的标示怎样去掉,官方没有demo,摸索着,苦恼~~
      

  7.   


    第一幅图已经搞定第二幅图 还是没想到该咋弄弄成这样的也行,如下图:
    我生成的图片如下图,怎样能生成多个Y轴呢,使用的是Owc11生成的。
    相关代码如下,怎样生成本回答中的类似于第二幅图呢,
    try
                {
                    Microsoft.Office.Interop.Owc11.ChartSpace objCSpace = new Microsoft.Office.Interop.Owc11.ChartSpaceClass();
                    Microsoft.Office.Interop.Owc11.ChChart objChart = objCSpace.Charts.Add(0);
                    objChart.Type = Microsoft.Office.Interop.Owc11.ChartChartTypeEnum.chChartTypeBarStacked;
                    objChart.HasLegend = false;                objChart.HasTitle = false;
                    objChart.Axes[0].HasTitle = false;
                    objChart.Axes[1].Position = ChartAxisPositionEnum.chAxisPositionTop;
                    objChart.Axes[0].HasTickLabels = true; //X轴是否显示                string strSeriesName = "图例";
                    int Rc = dt.Rows.Count;
                    string strCategory = "";
                    string strCategory1 = "冷漠\t愚钝\t易激动\t顺从\t严肃\t权宜敷衍\t萎缩退却\t着重实际\t信赖\t合乎成规\t坦白直率\t自信\t思维保守\t依赖\t散漫\t心平气和\t";
                    string strValue = "";
                    for (int i = 0; i < Rc; i++)
                    {
                        strCategory += dt.Rows[i][0].ToString() + "\t";
                        strValue += dt.Rows[i][1].ToString() + "\t";
                    }
                    
                     
                    ChSeries myseries1 = objChart.SeriesCollection.Add(0);
                    objChart.SeriesCollection[0].SetData(Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimCategories,
                          +(int)Microsoft.Office.Interop.Owc11.ChartSpecialDataSourcesEnum.chDataLiteral, strCategory);
                    
                    objChart.SeriesCollection[0].SetData
                        (Microsoft.Office.Interop.Owc11.ChartDimensionsEnum.chDimValues,
                        (int)Microsoft.Office.Interop.Owc11.ChartSpecialDataSourcesEnum.chDataLiteral, strValue);
                    
                    ChDataLabels objDataLabelsPlan = objChart.SeriesCollection[0].DataLabelsCollection.Add();
                    objDataLabelsPlan.HasValue = true;//柱子上面的数字是否显示 
                    objDataLabelsPlan.Font.Color = "Red";//柱子上面的数字颜色是红色的
                    objDataLabelsPlan.Position = ChartDataLabelPositionEnum.chLabelPositionInsideEnd;                ChSeries myseries2 = objChart.SeriesCollection.Add(1);
                    myseries2.Type = ChartChartTypeEnum.chChartTypeBarStacked;
                    myseries2.Ungroup(true);                myseries2.SetData
                        (ChartDimensionsEnum.chDimCategories,
                        (int)ChartSpecialDataSourcesEnum.chDataLiteral, strCategory1);                string strAbsolutePath = System.Web.HttpContext.Current.Server.MapPath("../Report/RptTemp/RPT_ImageTemp.gif");
                    objCSpace.ExportPicture(strAbsolutePath, "GIF", 600, 400);
                    return true;
                }
                catch
                {
                    return false;
                }