How to Set Chart Series Colors in MVC 3?

后端 未结 5 1327
抹茶落季
抹茶落季 2020-12-31 10:32

I\'m using

System.Web.Helpers.Chart

to display charts in my MVC3 application.

@{
    var myChart = new Chart(w         


        
5条回答
  •  独厮守ぢ
    2020-12-31 10:58

    You need to create a ChartTheme if you want to customise the chart. Unfortuantely these look a little bit hacky...

    Eg. try setting a theme like this:

    var myChart = new Chart(width: 600, height: 400, theme: ChartTheme.Green)
    

    You'll notice your chart looks different. If you click on ChartTheme.Green and press F12 (Go To Definition), you'll see the ChartTheme class is full of huge strings defining how the charts are styled:

    public const string Blue = @"
        
             
        
        
             
        
         
      ";
    

    There's a huge amount of stuff you can customise in this XML (why XML? I don't know!), though the type of chart etc. that you use will influence much of what you can do. You can find the docs for this here:

    http://msdn.microsoft.com/en-us/library/dd456696.aspx

    Edit: This link may also be useful:

    New asp.net charting controls - will they work with MVC (eventually)?

提交回复
热议问题