How to Set Chart Series Colors in MVC 3?

后端 未结 5 1293
抹茶落季
抹茶落季 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 11:09

    For MVC projects I find it easier to fine tune chart appearance by putting the theme into an external XML file. E.g. you can put an XML file into your Content folder and then reference it in the Chart constructor like this:

    var myChart = new Chart(width: 600, height: 200, themePath: "/Content/chart/ChartTheme.xml")
    

    You can then style all aspects, including colour Palette in the XML. The structure of the XML reflects the various classes and properties used in the a Chart instance. For guidance you can check the MSDN documentation of the classes, starting here.

    For changing the ColorPallette specifically check https://crmchartguy.wordpress.com/2012/08/23/palette-custom-colors-in-charts/

    This is a sample chart theme in XML:

     
    
          
              
                  
               
             
                  
                
                  
             
               
                  
               
           
          
            
             
          
       
    
    

提交回复
热议问题