0

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

在此处输入图像描述

在 HighChart 站点,这是一个相同类型的演示,显示每条记录的数据点。

我的代码如下,请您帮助和指导我。我非常感谢您的时间、分享和帮助。

感谢期待。

下面的代码生成图表:

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;
  }
4

1 回答 1

0

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

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

于 2013-11-03T12:11:47.683 回答