Scott Goodman
Scott Goodman

Reputation: 7

Flot xaxis not taking any configs

I am trying to implement a flot line graph, I am able to display the graph without issue but when I try to change the xaxis so that it is represented by divisions of 1 nothing happens. Nothing I am doing has any effect on it. ie if I give it a minimum number of ticks etc the xaxis remains exactly the same. Could someone tell me where I am going wrong, have I not included an appropriate js file or is it in my code for setting up the xaxis. This chart will eventually be sales figures for a month, so I want to be able to show what they were each day.

The code I have is as follows:

<script src="<?php echo base_url('assets/js/admin/jquery.flot.js') ?>"></script>
<script src="<?php echo base_url('assets/js/admin/jquery.flot.canvas.js') ?>"></script>
<script src="<?php echo base_url('assets/js/admin/jquery.flot.time.js') ?>"></script>
30
<script type="text/javascript">

    $(function() {

        var d2 = [[1, 445.50], [2, 660.00], [3, 240.00], [4, 302.00], [5, 601.45], [6, 705.34], [7, 550.05], [8, 450.00], [9, 302.00], [10, 601.45], [11, 302.00], [12, 450.00], [13, 1300.00], [14, 601.45], [15, 302.00], [16, 450.00], [17, 450.00], [18, 340.00], [19, 630.00], [20, 450.00], [21, 302.00], [22, 550.00], [23, 440.00], [24, 100.00], [25, 230.00], [26, 200.00], [27, 302.00], [28, 450.00], [29, 430.00], [30, 230.00]];

        $.plot("#placeholder", [{
                        color: '#F6772F',
            data: d2,
                        yaxis: {},
                        xaxis: {ticks: 30}

        }]);

    });

    </script>

Upvotes: 0

Views: 79

Answers (1)

DNS
DNS

Reputation: 38189

You're mixing up the options with the data. The plot function is called like this:

$.plot(placeholder, series_array, options_object);

In your case you are placing the xaxis options within your series object; it should be in the plot options instead.

Upvotes: 1

Related Questions