0

I have a problem with jQuery plot chart it works fine but when I load data from php and json it doesnt work it show me nothing.

This is my result from php

[{"label":"Patrik","data":4},{"label":"Miroslav","data":28}]

And flot

            $.getJSON( "http://"+window.location.hostname+"/dashboard/getChartData", function( data ) {
            console.log(data);

            var options = {
                series: {
                    bars: {
                        show: true
                    }
                },
                bars: {
                    align: "center",
                    barWidth: 0.5
                },
                xaxis: {
                    ticks: data.title
                },
                legend: {
                    noColumns: 0,
                    labelBoxBorderColor: "#fff",
                    position: "nw"
                },
                grid: {
                    hoverable: true,
                    borderWidth: 1,
                    borderColor: "#cecece",
                    backgroundColor: { colors: ["#ffffff", "#EDF5FF"] }
                }
            };

            $.plot($("#chart_1_1"), [ data ], options);
        });

1 Answer 1

1

The Json Data that You Receive needs to be converted to Array of arrays Format [[key,value],[key,value]] before you can give it to jqplot. Currently You are having array of objects

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.