Search code examples
javascriptjqueryflot

Unwanted Axis Values in Flot


I'm implementing a graph with Flot Chart JS and I'm having a little issue on implement a date axis. I'm using mode: time and formating the output as %d/%m/%Y but below the dates I have some numbers that I don't know how to remove, I already searched for it but haven't found whats wrong:

My options of axis are:

yaxis: {
    min: 0,
    max: max_value
},
xaxes: 
 [      
    {
        mode: "time",        
        tickFormatter: function (val, axis) {            
            return dayOfWeek[new Date(val).getDay()];
        },
        position: "top",
        axisLabel: "Weekday",
        timezone: "browser",
        axisLabelUseCanvas: true,
        axisLabelFontSizePixels: 12,
        axisLabelFontFamily: 'Verdana, Arial',
        axisLabelPadding: 5,
    },
    {
        mode: "time",
        timeformat:"%d/%m/%y",
        timezone: "local"
    }  
], 

The wrong values can be seen as in the image:

enter image description here


Solution

  • You have options for two x axes, so in your dataseries you have to specify which x axis to use with xaxis: 0 or xaxis:1. If you use other values (like xaxis: 2) Flot will automatically generate more x axes (without time mode). This is what you are seeing in your image. Fix the xaxis values in the dataseries and the additional x axes should disappear.