最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - Using Highcharts and displaying a message over or on the chart when there is no data - Stack Overflow

programmeradmin4浏览0评论

I'd like to know if there is a built-in or accepted way to show a label or message over the chart (or where the chart would be) if there are no data series.

I couldn't find anything in the Highcharts docs and I'm trying to stay away from using jQuery (or just JavaScript in general) to check if the result has data and then changing the DOM on my own.

The data is ing in as json from a MVC 3 controller call if that helps or changes anything.

Ideally it would be a message that displays over an empty chart so users know a chart object is there.

Thanks!

I'd like to know if there is a built-in or accepted way to show a label or message over the chart (or where the chart would be) if there are no data series.

I couldn't find anything in the Highcharts docs and I'm trying to stay away from using jQuery (or just JavaScript in general) to check if the result has data and then changing the DOM on my own.

The data is ing in as json from a MVC 3 controller call if that helps or changes anything.

Ideally it would be a message that displays over an empty chart so users know a chart object is there.

Thanks!

Share Improve this question edited May 8, 2013 at 23:54 Josh R asked May 8, 2013 at 21:38 Josh RJosh R 2,2303 gold badges30 silver badges46 bronze badges 8
  • 1 Why avoid javascipt if you are already using json? – Travis J Commented May 8, 2013 at 21:41
  • And highcharts is JS based...so, there is that – Tommy Commented May 8, 2013 at 23:28
  • I don't think I phrased my question correctly - I'm looking for a Highcharts API that allows me to overlay a message on top of the chart if no data is loaded, or until data is loaded. I don't want to write a one-off jQuery or plain JavaScript function because nobody else on my team writes JS and they might want to change the message. – Josh R Commented May 8, 2013 at 23:41
  • 1 try loading options api.highcharts./highcharts#loading – Strikers Commented May 9, 2013 at 9:16
  • Strikers: Thanks for the information. Using the loading property and changing the message displayed via the lang object is exactly what I needed. – Josh R Commented May 9, 2013 at 21:55
 |  Show 3 more ments

1 Answer 1

Reset to default 5

There is now an official plugin which shows a 'No Data to Display' message, after the loading message, when there is no data loaded into the chart. I've found it to be quite handy when the user is allowed to select a time range from search and filter form, and no results are returned from the search. It looks much better than having an empty chart.

Here is a link announcing the plugin, and jsfiddle example.

http://highcharts.uservoice./forums/55896-general/suggestions/1065633-display-no-data-to-display

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论