How to remove whitespace of null xLabel in Morris.js

17 Views Asked by At

I'm working with morris.js. I don't want to display Saturday and Sunday data on the chart.

Morris.Line({
    element: "x-dashboard-linesystem",
    data: [
        { y: "2023-10-13", StockCodeID23106208754414: 0, StockCodeID23108465313606: 0 },
        { y: "2023-10-16", StockCodeID23106208754414: 0, StockCodeID23108465313606: 0 },
        { y: "2023-10-17", StockCodeID23106208754414: 0, StockCodeID23108465313606: 0 },
        { y: "2023-10-18", StockCodeID23106208754414: 0, StockCodeID23108465313606: 0 },
        { y: "2023-10-19", StockCodeID23106208754414: 0, StockCodeID23108465313606: 0 },
        { y: "2023-10-20", StockCodeID23106208754414: 0, StockCodeID23108465313606: 0 },
        { y: "2023-10-23", StockCodeID23106208754414: 0, StockCodeID23108465313606: 0 },
        { y: "2023-10-24", StockCodeID23106208754414: 0, StockCodeID23108465313606: 0 },
        { y: "2023-10-25", StockCodeID23106208754414: 1902, StockCodeID23108465313606: 1000 },
        { y: "2023-10-26", StockCodeID23106208754414: 1902, StockCodeID23108465313606: 1000 },
        { y: "2023-10-27", StockCodeID23106208754414: 1902, StockCodeID23108465313606: 1000 }
    ],
    xkey: "y",
    ykeys: ["StockCodeID23106208754414", "StockCodeID23108465313606"],
    labels: ["E-Copitrade", "VN-Index"],
    lineColors: ["#FF00FF", "#CC9900"],
    postUnits: "%",
    grid: false,
    pointStrokeColors: ["transparent"],
    gridTextColor: "#fff",
    gridTextWeight: "bold",
    xLabelMargin: 100,
    xLabelFormat: function (d) {
        if (d.getDay() !== 0 && d.getDay() !== 6) {
            return ("0" + d.getDate()).slice(-2) + "/" + ("0" + (d.getMonth() + 1)).slice(-2);
        }
        return null;
    },
    dateFormat: function (x) {
        return moment(x).format("DD-MM-YYYY");
    },
});

However, how to remove the distance between Saturday and Sunday in xLabelFormat when it has no value. I tried checking to rule it out. However, it still shows the distance as shown below in the image I attached

enter image description here

Looking forward to everyone's help. Thank you!

0

There are 0 best solutions below