简体   繁体   中英

How to change chart font-size in Britecharts React?

I am unable to change the font-size of the x and y-axis using Britecharts - React. (see https://britecharts.github.io/britecharts-react/#bar ). From the docs it seems that the method is "labelsSize" but this is not currently working. A forked codepen showing the issue is here: https://codepen.io/mvolny/pen/XWZrmXR . Thanks.

const {Bar} = window['britecharts-react'];
const barData = [
  {
      name: 'Radiating',
      value: 2,
  },
  {
      name: 'Opalescent',
      value: 4,
  },
  {
      name: 'Shining',
      value: 3,
  },
  {
      name: 'Vibrant',
      value: 6,
  },
  {
      name: 'Vivid',
      value: 6,
  },
  {
      name: 'Brilliant',
      value: 1,
  },
];
const marginObject = {
  left: 100,
  right: 40,
  top: 40,
  bottom: 40,
};

ReactDOM.render(
<Bar
  data={barData}
  width={400}
  isHorizontal={true}
  margin={marginObject}
  labelsSize={50}
/>, 
document.getElementById('app')
);

Found this out asking around in the Brightcharts-React github page. Basically, you need to target the elements of the chart via css. See example for changing the font-size:

.tick text {
  font-size: 16px !important;
}

similarly,

.vertical-grid-line {
display: none !important;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM