Razor Chart Helper:如何更改AxisX文本方向

时间:2017-01-19 11:30:21

标签: c# .net asp.net-mvc razor charts

在视图中,我无法更改X轴标签文本的方向 我试图在主题中添加一个属性,但这似乎不起作用。 你有想法让它发挥作用吗?

@{

    string myTheme = "<Chart>\r\n <ChartAreas>\r\n <ChartArea Name=\"Default\" _Template_=\"All\">\r\n <AxisX  TextOrientation=\"Rotated90\" Interval=\"1\" />\r\n  </ChartArea>\r\n </ChartAreas>\r\n \r\n \r\n</Chart>";


    var myChart = new Chart(width: 600, height: 400, theme: myTheme)
        .AddSeries(
            name: "test ",
            xValue: new[] { "Peter", "andrew" },
            yValues: new[] { "1", "2" })
             .AddLegend()
        .Write();

}

example

1 个答案:

答案 0 :(得分:2)

试试这个:

@{
    string myTheme = "<Chart>\r\n <ChartAreas>\r\n <ChartArea Name=\"Default\" _Template_=\"All\">\r\n <AxisX IsLabelAutoFit=\"false\"><LabelStyle Angle=\"-90\" Interval=\"1\"></LabelStyle></AxisX>\r\n  </ChartArea>\r\n </ChartAreas>\r\n \r\n \r\n</Chart>";


    var myChart = new Chart(width: 600, height: 400, theme: myTheme)
        .AddSeries(
            name: "test ",
            xValue: new[] { "Peter", "andrew" },
            yValues: new[] { "1", "2" })
             .AddLegend()
        .Write();
}

enter image description here