Tell me more ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I need help. I'm trying to populate highcharts with data from a database.

This works perfectly:

    public ActionResult Index()
    {
        Highcharts chart1 = new Highcharts("chart1")
        .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Zmiana" } })
        .SetTitle(new Title { Text = "Zmiany wartości portfela w czasie" })
        .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
        .SetLegend(new Legend { Enabled = false })
        .SetXAxis(new XAxis { Categories = new[] { "Styczeń", "Luty", "Marzec", "Kwiecień" } })
        .SetSeries(new Series { Data = new Data(new object[] { 1, 8, 9, 6 }), Name = "Miesiąc" });

But this does not:

public ActionResult Index()
        {
             Highcharts chart1 = new Highcharts("chart1")
            .SetYAxis(new YAxis { Title = new YAxisTitle { Text = "Zmiana" } })
            .SetTitle(new Title { Text = "Zmiany wartości portfela w czasie" })
            .InitChart(new Chart { DefaultSeriesType = ChartTypes.Column })
            .SetLegend(new Legend { Enabled = false })

            .SetXAxis(new XAxis { Type = AxisTypes.Datetime })
            .SetSeries(new[] 
                        { 
                            new Series 
                            { 
                                Name = "Miesiąc" ,
                                Data = new Data(db.Wyniki.Select(x=> new Point {X=x.ID, Y=x.ID}).ToArray())             
                            }
                        });

I have this error:

Unable to cast the type 'System.Int32' to type 'DotNet.Highcharts.Helpers.Number'. LINQ to Entities only supports casting EDM primitive or enumeration types

I tried many solutions, but couldn't solve that and populate highcharts with data.

share|improve this question
add comment

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.