Forum Discussion

i1's avatar
i1
Frequent Visitor
8 years ago

use theme json to disable chart gridlines

Hi, 

I would like to know if there is a way how to set up the theme json so that horizontal gridlines in column charts are not displayed by default.

 

i.e. I think that i need to know the string with which to replace the "gridlines" in the snippet below. Other than that, it should be ok:

 

"visualStyles": {
  "columnChart": {
    "*": {
      "valueAxis": [{
        "show":true,
        "gridlines":false
       }]
    }
  }
}

 

Thank you,

 

Ira

 

6 Replies

  • Sorry to resurrect an old post, but I just figured out how to do this myself!

     

    The solution you're looking for (and anybody else in the futureā„¢) is:

     

    "visualStyles": {
      "columnChart": {
        "*": {
          "valueAxis": [{
               "gridlinesShow":false,
                "gridlinesColor":{
                    solid: {
                        color: '#f00',
                    }
                },
           }]
        }
      }
    }

    The documentation is not an exhaustive list of cardNames you can specify.

    The best thing I've found to do is follow the menu structure of PowerBI for the cardNames and attempt to find the names of the properties through trial and error.

    • Anonymous's avatar
      Anonymous
      Not applicable

      I'm unable to get this to work. I'm not super familiar with JSON, though, so struggling to pinpoint what I'm doing wrong in my specific theme. I noticed "color" and "solid" were missing quotes...is the rest of the syntax correct?

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

         

        Below is the part of the full code I have for this chart. If you have a current JSON, it can be complicated to understand where to place the code due to missing , or [ or }. The piece of code below is to append to an existing JSON file. If you have issues to append it or create a new one, let me know.

        Basically, if you want (or do not want) the grid on/off by default, you need to change to true or false below argument "gridlineShow": true = always on false = always off

        "valueAxis": [{
            "show": true,
            "position": "Right",
            "axisScale": "Linear",
            "start": 0,
            "end": 10,
            "labelColor": { "solid": { "color": "#01B8AA"}},
            "fontSize": 14,
            "fontFamily": "Courier New",
            "labelDisplayUnits": "0",
            "labelPrecision": "Auto",
            "showAxisTitle": true,
            "axisStyle": "showTitleOnly",
            "color": { "solid": { "color": "01B8AA"}},
            "titleText": "",
            "titleFontSize": 12,
            "titleFontFamily": "Courier New",
            "gridlineShow": true,
            "gridlineColor": { "solid": { "color": "#01B8AA"}},
            "gridlineThickness": 2,
            "gridlineStyle": "dashed"
        }],

         

         

        "columnChart": {
        			"*": {
        				"general": [{
        					"responsive": true
        				}],
        				"categoryAxis": [{
        					"show": true,
        					"position": "Right",
        					"labelColor": { "solid": { "color": "#01B8AA"}},
        					"fontSize": 12,
        					"fontFamily": "Segoe UI",
        					"preferredCategoryWidth": 30,
        					"maxMarginFactor": 28,
        					"innerPadding": 22,
        					"concatenateLabels": true,
        					"showAxisTitle": true,
        					"axisStyle": "showTitleOnly",
        					"titleColor": { "solid": { "color": "#01B8AA"}},
        					"titleText": "",
        					"titleFontSize": 12,
        					"titleFontFamily": "Segoe UI"
        				}]

         

         
        Cheers

  • v-frfei-msft's avatar
    v-frfei-msft
    Community Support

    Hi i1,

     

    Based on my research there is no way to use theme json to disable chart gridlines, as the online document, there is no option for that. For more details, please check the online document. Here I suggest to change the setting manually.

     

     

    Regards,

    Frank