dotnet highcharts数据点不会随每条记录而出现

时间:2013-11-01 00:56:03

标签: c# asp.net-mvc highcharts dotnethighcharts

在我使用Dotnet HighCharts的MVC应用程序中。我能够在页面中呈现图表,但作为我的新手,有一件事并不像预期的那样。我没有获得数据点(小弹出框提供有关图中某点的详细信息)。我传递给图表的数据由5000条记录组成,但我没有得到每个点的数据点。这是我的图表显示:

enter image description here

在HighChart网站this是同类演示,显示每条记录的数据点。

我的代码如下,您能帮忙指导一下吗?我高度赞赏你的时间,分享和帮助。

感谢您的期待。

以下代码生成图表:

private Highcharts GetChart(List<CurrencyConversion> conversions, DateTime dateFrom, DateTime dateTo)
    {

        Highcharts chart = null;
        string currencyFrom, currencyTo;
        if (conversions != null && conversions.Count() > 0)
        {

            object[][] data = conversions.Select(c => new object[] { c.LastUpdatedDate, c.Rate }).ToArray();

            currencyFrom = conversions.Select(c => c.CurrencyFrom).FirstOrDefault();
            currencyTo = conversions.Select(c => c.CurrencyTo).FirstOrDefault();

            chart = new Highcharts("chart")
           .SetOptions(new GlobalOptions { Global = new Global { UseUTC = false } })
           .InitChart(new Chart { ZoomType = ZoomTypes.X, SpacingRight = 20 })
           .SetTitle(new Title { Text = "" })
           .SetSubtitle(new Subtitle { Text = "Click and drag in the plot area to zoom in" })
           .SetXAxis(new XAxis
           {
               Type = AxisTypes.Datetime,
               MinRange =   3600000,
               Title = new XAxisTitle { Text = "" }
           })
           .SetYAxis(new YAxis
           {
               Title = new YAxisTitle { Text = "Exchange rate" },
               StartOnTick = false,
               EndOnTick = false,
               Min = 0.1
           })
           .SetTooltip(new Tooltip { Shared = true })
           .SetLegend(new Legend { Enabled = false })
           .SetPlotOptions(new PlotOptions
           {
               Area = new PlotOptionsArea
               {
                   FillColor = new BackColorOrGradient(new Gradient
                   {
                       LinearGradient = new[] { 0, 0, 0, 300 },
                       Stops = new object[,] { { 0, "rgb(116, 116, 116)" }, { 1, Color.LightSkyBlue } }
                   }),
                   LineWidth = 1,
                   Marker = new PlotOptionsAreaMarker
                   {
                       Enabled = false,
                       States = new PlotOptionsAreaMarkerStates
                       {
                           Hover = new PlotOptionsAreaMarkerStatesHover
                           {
                               Enabled = true,
                               Radius = 5
                           }
                       }
                   },
                   Shadow = false,
                   States = new PlotOptionsAreaStates { Hover = new PlotOptionsAreaStatesHover { LineWidth = 1 } },
                   PointInterval = 24 * 3600 * 1000,                        
                   AllowPointSelect = true, CropThreshold=10

                   //PointStart = new PointStart(startDate)
               }
           })
           .SetSeries(new Series
           {
               Type = ChartTypes.Area,
               Name = string.Format("{0} to {1}", currencyFrom, currencyTo),   //graphHeading,
               Data = new Data(data), 
           });
        }
        return chart;
  }

1 个答案:

答案 0 :(得分:0)

如果您使用highstock.js(从截图我注意到一段导航器),则启用dataGroping,默认。因此,如果您禁用它,将打印所有点。

http://api.highcharts.com/highstock#plotOptions.series.dataGrouping.enabled