Uliat
Uliat

Reputation: 31

Razor Chart Helper: How to change AxisX text orientation

In a view, I can not change the orientation of the text of the labels of the X axis I tried to add a property in a theme but this does not seem to work. Do you have an idea for it to work?

@{

    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

Upvotes: 1

Views: 564

Answers (1)

jsanalytics
jsanalytics

Reputation: 13188

Try this:

@{
    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

Upvotes: 2

Related Questions