使用asp.net MVC剃须刀在图表中未显示x轴值 [英] x-axis values are not displayed in the chart using asp.net MVC razer

查看:100
本文介绍了使用asp.net MVC剃须刀在图表中未显示x轴值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

x轴值未显示在图表中.但是y轴显示正确.


使用以下代码,图表也正确显示了X轴和Y轴值.


x-axis values are not displayed in the chart using asp.net MVC razer. but y axis are displayed properly.


with the below code the chart is dispalying properly with X-axis and Y-axis values too.


public ActionResult Index()
      {
          var key = new Chart(width: 600, height: 400)
             .AddSeries(
                 chartType: "bar",
                 legend: "Rainfall",
                  xValue: new[] { "Jan", "Feb", "Mar", "Apr", "May" },
                  yValues: new[] { "20", "20", "40", "10", "10"}

                  ).Write();

          return null;

      }




但是当我尝试使用以下代码时,图表显示出来,但是X轴值显示不正确





but when i tried with the below code the chart is displaying but the X-axis values are not displayed properly


 public ActionResult Index()
   {
       Chart chart = new Chart(width: 1080, height: 1280);
       chart.AddSeries(
       chartType: "stackedbar",
    xValue: new[] { "a", "b", "c", "d", "e", "f", "g", "h", "i" , "j", "k", "l", "m", "n", "o" , "p", "q", "r", "s", "t", "u" },
   yValues: new[] { "200", "400", "600", "200", "400", "600", "200", "400", "600" , "200", "400", "600", "200", "400", "600"  , "200", "400", "600", "200", "400", "600" }
           ).Write();

     return null;
}


任何帮助将不胜感激..


any help will be appreciated..

推荐答案

public ActionResult Index()
{
System.Web.UI.DataVisualization.Charting.Chart c =新的System.Web.UI.DataVisualization.Charting.Chart();
ChartArea区域=新的ChartArea();
area.AxisX.IsLabelAutoFit = true;
area.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep30;
area.AxisX.LabelStyle.Enabled = true;
area.AxisX.Interval = 1;
area.AxisY.Interval = 1;
//System.Web.UI.DataVisualization.Charting.Axis
//c.ChartAreas.Add(new ChartArea());
c.ChartAreas.Add(area);
c.Width = 200;
c.高度= 200;
Series mySeries = new Series();
mySeries.Points.DataBindXY(
new string [] {"1","2","3","4","5","6","7","8","9","10","11","1," 2," 3," 4," 5," 6," 7," 8," 9," 10," 11},
新字符串[] {一个",两个",三个",四个",五个",六个",七个",八个",九个",十个",十一个",一",二",三",四",五",六",七",八",九",十",十一"}

);

c.Series.Add(mySeries);
//c.ChartAreas[0].AxisX.LabelStyle.Angle = 45;


//chart.Series.Add(series);
var returnStream = new MemoryStream();
c.ImageType = ChartImageType.Png;
c.SaveImage(returnStream);
returnStream.Position = 0;
返回新的FileStreamResult(returnStream,"image/png");

}
public ActionResult Index()
{
System.Web.UI.DataVisualization.Charting.Chart c = new System.Web.UI.DataVisualization.Charting.Chart();
ChartArea area = new ChartArea();
area.AxisX.IsLabelAutoFit = true;
area.AxisX.LabelAutoFitStyle = LabelAutoFitStyles.LabelsAngleStep30;
area.AxisX.LabelStyle.Enabled = true;
area.AxisX.Interval = 1;
area.AxisY.Interval = 1;
//System.Web.UI.DataVisualization.Charting.Axis
//c.ChartAreas.Add(new ChartArea());
c.ChartAreas.Add(area);
c.Width = 200;
c.Height = 200;
Series mySeries = new Series();
mySeries.Points.DataBindXY(
new string[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11" },
new string[] { "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven" }

);

c.Series.Add(mySeries);
//c.ChartAreas[0].AxisX.LabelStyle.Angle = 45;


// chart.Series.Add(series);
var returnStream = new MemoryStream();
c.ImageType = ChartImageType.Png;
c.SaveImage(returnStream);
returnStream.Position = 0;
return new FileStreamResult(returnStream, "image/png");

}


这篇关于使用asp.net MVC剃须刀在图表中未显示x轴值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆