Advertisement
Guest User

Untitled

a guest
May 6th, 2016
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.42 KB | None | 0 0
  1. if (!data || !data.length || !data.filter(function(d) { return d.values.length }).length) {
  2. var noDataText = container.selectAll('.nv-noData').data([noData]);
  3.  
  4. noDataText.enter().append('text')
  5. .attr('class', 'nvd3 nv-noData')
  6. .attr('dy', '-.7em')
  7. .style('text-anchor', 'middle');
  8.  
  9. noDataText
  10. .attr('x', margin.left + availableWidth / 2)
  11. .attr('y', margin.top + availableHeight / 2)
  12. .text(function(d) { return d });
  13.  
  14. return chart;
  15. } else {
  16. container.selectAll('.nv-noData').remove();
  17. }
  18.  
  19. nv.utils.noData = function(chart, container) {
  20. var opt = chart.options(),
  21. margin = opt.margin(),
  22. noData = opt.noData(),
  23. data = (noData == null) ? ["No Data Available."] : [noData],
  24. height = nv.utils.availableHeight(opt.height(), container, margin),
  25. width = nv.utils.availableWidth(opt.width(), container, margin),
  26. x = margin.left + width/2,
  27. y = margin.top + height/2;
  28.  
  29. //Remove any previously created chart components
  30. container.selectAll('g').remove();
  31.  
  32. var noDataText = container.selectAll('.nv-noData').data(data);
  33.  
  34. noDataText.enter().append('text')
  35. .attr('class', 'nvd3 nv-noData')
  36. .style('text-anchor', 'middle');
  37.  
  38. noDataText
  39. .attr('x', '50%')
  40. .attr('y', '50%')
  41. .text(function(t){ return t; });
  42.  
  43. .nvd3.nv-noData {
  44. position: relative;
  45. transform: translate(-50%, -50%) !important;
  46. font-size: 24px;
  47. color: #666;
  48. font-weight: 200;
  49. text-align: center;}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement