Having problems with jqPlot bar chart

前端 未结 3 1923
星月不相逢
星月不相逢 2021-02-20 04:16

I\'m using jqPlot to create a bar graph, but I ran into a few problems.

Problem 1: The first and last bars on the graph are cut off. Only half of it is

3条回答
  •  -上瘾入骨i
    2021-02-20 05:00

    From how you want your plot to look, you'll save yourself a lot of trouble if you switch to using a CategoryAxisRenderer instead of the DateAxisRenderer. The CategoryAxisRenderer is a lot better at displaying discreet groupings of data as opposed to a true time series.

    var axisDates = ["Jan 19", "Jan 20", "Jan 21"]
    var chartData = [2.61,5.00,6.00]
    
            $.jqplot.config.enablePlugins = true;
                 var plot2 = $.jqplot('chart2', [chartData], {
                    title: 'Some Plot',
                     seriesDefaults:{
                         renderer: $.jqplot.BarRenderer,
                         rendererOptions: {
                            barPadding: 1,
                            barMargin: 15,
                            barDirection: 'vertical',
                            barWidth: 50
                        }, 
                        pointLabels: { show: true }
                    },
                    axes: {
                        xaxis: {                            
                                renderer:  $.jqplot.CategoryAxisRenderer,
                                ticks: axisDates
                        },
                        yaxis: {
                            tickOptions: {
                                formatString: '$%.2f'
                            }
                        }
                    },
                    highlighter: {
                        sizeAdjust: 7.5
                    },
                    cursor: {
                        show: true
                    }
                });
    

    enter image description here

提交回复
热议问题