0

I'm new using highcharts and JSON.

My javascript code is this:

$(document).ready(function() {

    var options = {
        chart: {
            renderTo: 'grafica',
            type: 'spline'
        },
        series: [{}]
    };

    $.getJSON('ajax/gettipomov.aspx', function(data) {
        options.series[0].data = data;
        var chart = new Highcharts.Chart(options);
    });
});

And the data returned by the server and received by JavaScript is this:

[{"tipoMov":"Ajuste negativo","valorTipoMov":5},{"tipoMov":"Ajuste     positivo","valorTipoMov":5},{"tipoMov":"Compra","valorTipoMov":5},    {"tipoMov":"Transferencia","valorTipoMov":5},{"tipoMov":"Venta","valorTipoMov":5}]

The problem is that chart is not showing any data, the chart is blank: image The JSON Encoding that I use is:

var encoder = new JavaScriptSerializer();
    return encoder.Serialize(obj);
1
  • 2
    This format is not supported, instead of tipoMov and valorTipoMov should be name and y. Commented Sep 13, 2013 at 11:56

1 Answer 1

1

That's the format expected:

{ "name": "Ajuste negativo", "y": 5 },
{ "name": "Ajuste positivo", "y": 5 },
{ "name": "Compra", "y": 5},
{ "name": "Transferencia", "y": 5},
{ "name": "Venta", "y": 5}

tipoMov and valorTipoMov mean nothing to Highcharts, so change your Object to return the properties named accordingly.

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

1 Comment

Thanks but i can´t format this from C# code, i will try make this with the returned code in javascript. Thanks!

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.