Question

I Serialized my data in code behind as;

Dim classes As List(Of SerializedJsonDT) = SerializedJsonDT.GetJsonFriendlyClasses(dt)
jsonNTMS = JsonConvert.SerializeObject(classes)

Then I received this data from aspx page as;

<script type="text/javascript">
        var obj = JSON.parse('<%=jsonNTMS%>');
        var catName = obj[0].name;
        var ser1Name = obj[1].name;
        var ser2Name = obj[2].name;

        var catData = obj[0].data;
        var ser1Data = obj[1].data;
        var ser2Data = obj[2].data;

        var cSstopHere2 = 2;

        var chart;
        $(document).ready(function () {
            chart = new Highcharts.Chart({
                chart: {
                    renderTo: 'container',
                    height: 400,
                    width: 600,
                    spacingRight: 20,
                    type: 'spline',
                    backgroundColor: '#1a1818',
                    events: {
                        load: function () {
                            this.series[1].setData(eval(ser1Data), true, true);
                            this.series[0].setData(eval(ser2Data), true, true);
                        }
                    }
                },
                title: {
                    text: 'GÜNLÜK DÖVİZ STATİĞİ - USD',
                    style: {
                        color: '#ffffff',
                        font: 'bold 16px "Trebuchet MS", Verdana, sans-serif'
                    }
                },
                xAxis: {
                    categories: catData, 
                    labels: {
                        style: {
                            color: '#ffffff',
                            fontSize: '10px'
                        }
                    },
                    tickInterval: 1,
                    gridLineWidth: 0.2,
                    lineColor: '#ffffff'
                },
                yAxis: {
                    title: {
                        text: '1 USD = ? TL',
                        style: {
                            color: '#ffffff',
                            font: 'bold 12px "Trebuchet MS", Verdana, sans-serif'
                        },
                    },
                    min: 2.1,
                    gridLineWidth: 0.2,
                    lineColor: '#ffffff'
                },

                plotOptions: {
                    series: {
                        dataLabels: {
                            enabled: true,
                            style: {
                                color: '#ffffff'
                            }
                        },
                        lineWidth: 2
                    }
                },
                series: [{
                    name: "USD: " + ser1Name,
                    data: []
                },{
                    name: "USD: " + ser2Name,
                    data: []
                }],
            });
            chart.redraw
        });
    </script>

I can see my chart container but only the categories shown. I cant see my series in my highchart.

The web form I have;

<body>
    <script src="http://code.highcharts.com/highcharts.js"  type="text/javascript"></script>
    <script src="http://code.highcharts.com/modules/exporting.js" type="text/javascript"></script>
    <form id="form1" runat="server">
        <div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
    </form>
</body>

Does anyone knows how to make my highcharts shows my series?

My categories was time values and I convert them to string before serialized. (08:17, 09:45 etc). And my series data originally was decimal values and I convert them to string before serialized. I did place ser1Data first and didn't work. So I try to use set data events. I guess I have to convert my series data in javascript to decimal. But I rather use this process in my custom "Public Class SerializedJsonDT" class. mason help me to build the class.

Kind Regards...

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top