Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to remove decimal values on x-axis of bar chart : Highcharts

I am having trouble setting integer only values to the x-axis of the bar chart. Can someone help me as to how to solve this.

This is my sandbox: https://codesandbox.io/s/react-line-chart-forked-0409lk?file=/src/LineChart.js

Have tried, allowDecimal: false, min:0, float:0. Nothing worked out.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Help is appreciated

import * as React from "react";
import Highcharts from "highcharts";
import HighchartsReact from "highcharts-react-official";
import HC_exporting from "highcharts/modules/exporting";
HC_exporting(Highcharts);

function Chart(props) {
  const chartOptions = {
    chart: {
      type: "bar",
      height: 250
    },
    xAxis: {
      type: "category",
      visible: true,
      gridLineWidth: 1,
      floor: 0,
      tickInterval: 1,
      min: 0
    },
    yAxis: {
      min: 0,
      title: {
        text: null
      }
    },
    plotOptions: {
      column: {
        dataLabels: {
          enabled: true,
          crop: false,
          overflow: "none"
        }
      }
    },
    series: [{ data: props.chartData }]
  };
  return <HighchartsReact highcharts={Highcharts} options={chartOptions} />;
}

export default Chart;

>Solution :

You should put the tickInterval: 1, in the yAxis

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading