JFreeChart之堆叠柱形图(StackedBar)

JAVA
JFreeChart

最近的项目使用有个功能需要使用到堆叠柱形图,看了项目以前的代码实现没有想要的结果。所以自己就先到官网下载了 DemoDemo里有个打包好的Jar包,直接运行看到效果,但是坑爹的是貌似没有对应的源码,所以只能根据class名称直接google了,所幸在github里找到对应的源码。
点我下载 访问密码 f62b
这是运行Demo找到想要实现的效果的大致图:

我最终想要实现的效果是这样的:

如果想要实现这个效果,可以使用

  1. 1extendedstackedbarrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator("{3}", 

  2. 2 NumberFormat.getPercentInstance(), new DecimalFormat("#0.0%"))); 



但是柱体的返回的值是10.1/50.1=20.2%,40.1/50.1=79.8%

这不符合预期目标,所以就去看了一下源码,在StandardCategoryItemLabelGenerator的父类AbstractCategoryItemLabelGenerator中发现有createItemArray这么一个方法:

可以发现柱体的标签值应该是由这个方法进行返回的,因此自己就对StandardCategoryItemLabelGenerator进行了继承,并重写了这个方法。
ExtendedStandardCategoryItemLabelGeneratory中增加了isPercent作为标签值是显示百分比还是仅仅格式化的判断参数,并重写了createItemArray这个方法。

此时得到的效果如图:

然而,柱体的总值还是没有格式化。再看了一下ExtendedStackedBarRenderer这个类的代码,找到了totalFormat这个属性,将其值赋为new DecimalFormat("#0.0%")。测试:

基本是想要的最终结果,下面是测试代码

  1. 1 <dependency> 

  2. 2 <groupId>jfree</groupId> 

  3. 3 <artifactId>jfreechart</artifactId> 

  4. 4 <version>1.0.13</version> 

  5. 5 </dependency> 

ExtendedStackedBarRenderer

  1. 1package com.springapp.jfreechar; 



  2. 3import java.awt.Color; 

  3. 4import java.awt.Font; 

  4. 5import java.awt.Graphics2D; 

  5. 6import java.awt.geom.Rectangle2D; 

  6. 7import java.text.DecimalFormat; 

  7. 8import java.text.NumberFormat; 



  8. 10import org.jfree.chart.axis.CategoryAxis; 

  9. 11import org.jfree.chart.axis.ValueAxis; 

  10. 12import org.jfree.chart.entity.CategoryItemEntity; 

  11. 13import org.jfree.chart.entity.EntityCollection; 

  12. 14import org.jfree.chart.labels.CategoryToolTipGenerator; 

  13. 15import org.jfree.chart.plot.CategoryPlot; 

  14. 16import org.jfree.chart.plot.PlotOrientation; 

  15. 17import org.jfree.chart.renderer.category.CategoryItemRendererState; 

  16. 18import org.jfree.chart.renderer.category.StackedBarRenderer; 

  17. 19import org.jfree.data.category.CategoryDataset; 

  18. 20import org.jfree.text.TextUtilities; 

  19. 21import org.jfree.ui.TextAnchor; 

  20. 22 

  21. 23public class ExtendedStackedBarRenderer extends StackedBarRenderer { 

  22. 24 

  23. 25 private static final long serialVersionUID = 1L; 

  24. 26 private boolean showPositiveTotal; 

  25. 27 private boolean showNegativeTotal; 

  26. 28 private Font totalLabelFont; 

  27. 29 private NumberFormat totalFormatter; 

  28. 30 public ExtendedStackedBarRenderer() { 

  29. 31 showPositiveTotal = true; 

  30. 32 showNegativeTotal = true; 

  31. 33 totalLabelFont = new Font("SansSerif", 1, 12); 

  32. 34 totalFormatter = new DecimalFormat("#0.0%"); 

  33. 35 } 

  34. 36 

  35. 37 /** 

  36. 38 * StackedBarRenderer 没有这个构造方法的,传入一个NumberFormat类,可以自定义实现每个柱体值显示格式 

  37. 39 * @param totalFormatter 

  38. 40 */ 

  39. 41 public ExtendedStackedBarRenderer(NumberFormat totalFormatter) { 

  40. 42 showPositiveTotal = true; 

  41. 43 showNegativeTotal = true; 

  42. 44 totalLabelFont = new Font("SansSerif", 1, 12); 

  43. 45 this.totalFormatter = totalFormatter; 

  44. 46 } 

  45. 47 

  46. 48 public NumberFormat getTotalFormatter() { 

  47. 49 return totalFormatter; 

  48. 50 } 

  49. 51 

  50. 52 public void setTotalFormatter(NumberFormat numberformat) { 

  51. 53 if (numberformat == null) { 

  52. 54 throw new IllegalArgumentException("Null format not permitted."); 

  53. 55 } else { 

  54. 56 totalFormatter = numberformat; 

  55. 57 return; 

  56. 58 } 

  57. 59 } 

  58. 60 

  59. 61 public void drawItem(Graphics2D graphics2d, CategoryItemRendererState categoryitemrendererstate, Rectangle2D rectangle2d, CategoryPlot categoryplot, CategoryAxis categoryaxis, 

  60. 62 ValueAxis valueaxis, CategoryDataset categorydataset, int i, int j, int k) { 

  61. 63 Number number = categorydataset.getValue(i, j); 

  62. 64 if (number == null) 

  63. 65 return; 

  64. 66 double d = number.doubleValue(); 

  65. 67 PlotOrientation plotorientation = categoryplot.getOrientation(); 

  66. 68 double d1 = categoryaxis.getCategoryMiddle(j, getColumnCount(), rectangle2d, categoryplot.getDomainAxisEdge()) - categoryitemrendererstate.getBarWidth() / 2D; 

  67. 69 double d2 = 0.0D; 

  68. 70 double d3 = 0.0D; 

  69. 71 for (int l = 0; l < i; l++) { 

  70. 72 Number number1 = categorydataset.getValue(l, j); 

  71. 73 if (number1 == null) 

  72. 74 continue; 

  73. 75 double d5 = number1.doubleValue(); 

  74. 76 if (d5 > 0.0D) 

  75. 77 d2 += d5; 

  76. 78 else 

  77. 79 d3 += d5; 

  78. 80 } 

  79. 81 

  80. 82 org.jfree.ui.RectangleEdge rectangleedge = categoryplot.getRangeAxisEdge(); 

  81. 83 double d4; 

  82. 84 double d6; 

  83. 85 if (d > 0.0D) { 

  84. 86 d4 = valueaxis.valueToJava2D(d2, rectangle2d, rectangleedge); 

  85. 87 d6 = valueaxis.valueToJava2D(d2 + d, rectangle2d, rectangleedge); 

  86. 88 } else { 

  87. 89 d4 = valueaxis.valueToJava2D(d3, rectangle2d, rectangleedge); 

  88. 90 d6 = valueaxis.valueToJava2D(d3 + d, rectangle2d, rectangleedge); 

  89. 91 } 

  90. 92 double d7 = Math.min(d4, d6); 

  91. 93 double d8 = Math.max(Math.abs(d6 - d4), getMinimumBarLength()); 

  92. 94 Rectangle2D.Double double1 = null; 

  93. 95 if (plotorientation == PlotOrientation.HORIZONTAL) 

  94. 96 double1 = new Rectangle2D.Double(d7, d1, d8, categoryitemrendererstate.getBarWidth()); 

  95. 97 else 

  96. 98 double1 = new Rectangle2D.Double(d1, d7, categoryitemrendererstate.getBarWidth(), d8); 

  97. 99 java.awt.Paint paint = getItemPaint(i, j); 

  98. 100 graphics2d.setPaint(paint); 

  99. 101 graphics2d.fill(double1); 

  100. 102 if (isDrawBarOutline() && categoryitemrendererstate.getBarWidth() > 3D) { 

  101. 103 graphics2d.setStroke(getItemStroke(i, j)); 

  102. 104 graphics2d.setPaint(getItemOutlinePaint(i, j)); 

  103. 105 graphics2d.draw(double1); 

  104. 106 } 

  105. 107 org.jfree.chart.labels.CategoryItemLabelGenerator categoryitemlabelgenerator = getItemLabelGenerator(i, j); 

  106. 108 if (categoryitemlabelgenerator != null && isItemLabelVisible(i, j)) 

  107. 109 drawItemLabel(graphics2d, categorydataset, i, j, categoryplot, categoryitemlabelgenerator, double1, d < 0.0D); 

  108. 110 if (d > 0.0D) { 

  109. 111 if (showPositiveTotal && isLastPositiveItem(categorydataset, i, j)) { 

  110. 112 graphics2d.setPaint(Color.black); 

  111. 113 graphics2d.setFont(totalLabelFont); 

  112. 114 double d9 = calculateSumOfPositiveValuesForCategory(categorydataset, j); 

  113. 115 float f = (float) double1.getCenterX(); 

  114. 116 float f2 = (float) double1.getMinY() - 4F; 

  115. 117 TextAnchor textanchor = TextAnchor.BOTTOM_CENTER; 

  116. 118 if (plotorientation == PlotOrientation.HORIZONTAL) { 

  117. 119 f = (float) double1.getMaxX() + 4F; 

  118. 120 f2 = (float) double1.getCenterY(); 

  119. 121 textanchor = TextAnchor.CENTER_LEFT; 

  120. 122 } 

  121. 123 TextUtilities.drawRotatedString(totalFormatter.format(d9), graphics2d, f, f2, textanchor, 0.0D, TextAnchor.CENTER); 

  122. 124 } 

  123. 125 } else if (showNegativeTotal && isLastNegativeItem(categorydataset, i, j)) { 

  124. 126 graphics2d.setPaint(Color.black); 

  125. 127 graphics2d.setFont(totalLabelFont); 

  126. 128 double d10 = calculateSumOfNegativeValuesForCategory(categorydataset, j); 

  127. 129 float f1 = (float) double1.getCenterX(); 

  128. 130 float f3 = (float) double1.getMaxY() + 4F; 

  129. 131 TextAnchor textanchor1 = TextAnchor.TOP_CENTER; 

  130. 132 if (plotorientation == PlotOrientation.HORIZONTAL) { 

  131. 133 f1 = (float) double1.getMinX() - 4F; 

  132. 134 f3 = (float) double1.getCenterY(); 

  133. 135 textanchor1 = TextAnchor.CENTER_RIGHT; 

  134. 136 } 

  135. 137 TextUtilities.drawRotatedString(totalFormatter.format(d10), graphics2d, f1, f3, textanchor1, 0.0D, TextAnchor.CENTER); 

  136. 138 } 

  137. 139 if (categoryitemrendererstate.getInfo() != null) { 

  138. 140 EntityCollection entitycollection = categoryitemrendererstate.getEntityCollection(); 

  139. 141 if (entitycollection != null) { 

  140. 142 String s = null; 

  141. 143 CategoryToolTipGenerator categorytooltipgenerator = getToolTipGenerator(i, j); 

  142. 144 if (categorytooltipgenerator != null) 

  143. 145 s = categorytooltipgenerator.generateToolTip(categorydataset, i, j); 

  144. 146 String s1 = null; 

  145. 147 if (getItemURLGenerator(i, j) != null) 

  146. 148 s1 = getItemURLGenerator(i, j).generateURL(categorydataset, i, j); 

  147. 149 CategoryItemEntity categoryitementity = new CategoryItemEntity(double1, s, s1, categorydataset, categorydataset.getRowKey(i), categorydataset.getColumnKey(j)); 

  148. 150 entitycollection.add(categoryitementity); 

  149. 151 } 

  150. 152 } 

  151. 153 } 

  152. 154 

  153. 155 private boolean isLastPositiveItem(CategoryDataset categorydataset, int i, int j) { 

  154. 156 boolean flag = true; 

  155. 157 Number number = categorydataset.getValue(i, j); 

  156. 158 if (number == null) 

  157. 159 return false; 

  158. 160 for (int k = i + 1; k < categorydataset.getRowCount(); k++) { 

  159. 161 Number number1 = categorydataset.getValue(k, j); 

  160. 162 if (number1 != null) 

  161. 163 flag = flag && number1.doubleValue() <= 0.0D; 

  162. 164 } 

  163. 165 

  164. 166 return flag; 

  165. 167 } 

  166. 168 

  167. 169 private boolean isLastNegativeItem(CategoryDataset categorydataset, int i, int j) { 

  168. 170 boolean flag = true; 

  169. 171 Number number = categorydataset.getValue(i, j); 

  170. 172 if (number == null) 

  171. 173 return false; 

  172. 174 for (int k = i + 1; k < categorydataset.getRowCount(); k++) { 

  173. 175 Number number1 = categorydataset.getValue(k, j); 

  174. 176 if (number1 != null) 

  175. 177 flag = flag && number1.doubleValue() >= 0.0D; 

  176. 178 } 

  177. 179 

  178. 180 return flag; 

  179. 181 } 

  180. 182 

  181. 183 private double calculateSumOfPositiveValuesForCategory(CategoryDataset categorydataset, int i) { 

  182. 184 double d = 0.0D; 

  183. 185 for (int j = 0; j < categorydataset.getRowCount(); j++) { 

  184. 186 Number number = categorydataset.getValue(j, i); 

  185. 187 if (number == null) 

  186. 188 continue; 

  187. 189 double d1 = number.doubleValue(); 

  188. 190 if (d1 > 0.0D) 

  189. 191 d += d1; 

  190. 192 } 

  191. 193 

  192. 194 return d; 

  193. 195 } 

  194. 196 

  195. 197 private double calculateSumOfNegativeValuesForCategory(CategoryDataset categorydataset, int i) { 

  196. 198 double d = 0.0D; 

  197. 199 for (int j = 0; j < categorydataset.getRowCount(); j++) { 

  198. 200 Number number = categorydataset.getValue(j, i); 

  199. 201 if (number == null) 

  200. 202 continue; 

  201. 203 double d1 = number.doubleValue(); 

  202. 204 if (d1 < 0.0D) 

  203. 205 d += d1; 

  204. 206 } 

  205. 207 

  206. 208 return d; 

  207. 209 } 

  208. 210 

  209. 211} 

  210. 212 

ExtendedStandardCategoryItemLabelGeneratory

  1. 1package com.springapp.jfreechar; 



  2. 3import org.jfree.chart.HashUtilities; 

  3. 4import org.jfree.chart.labels.AbstractCategoryItemLabelGenerator; 

  4. 5import org.jfree.chart.labels.StandardCategoryItemLabelGenerator; 

  5. 6import org.jfree.data.DataUtilities; 

  6. 7import org.jfree.data.category.CategoryDataset; 

  7. 8import org.jfree.util.ObjectUtilities; 

  8. 9import org.jfree.util.PublicCloneable; 

  9. 10 

  10. 11import java.io.Serializable; 

  11. 12import java.text.DateFormat; 

  12. 13import java.text.MessageFormat; 

  13. 14import java.text.NumberFormat; 

  14. 15 

  15. 16public class ExtendedStandardCategoryItemLabelGeneratory extends StandardCategoryItemLabelGenerator implements PublicCloneable, Cloneable, Serializable { 

  16. 17 

  17. 18 private static final long serialVersionUID = -7108591260223293197L; 

  18. 19 private String labelFormat; 

  19. 20 private String nullValueString; 

  20. 21 private NumberFormat numberFormat; 

  21. 22 private DateFormat dateFormat; 

  22. 23 private NumberFormat percentFormat; 

  23. 24 //新增加了参数,柱体series的值是否是总值的百分比,还是仅仅将原来的小数转化为百分数 

  24. 25 private boolean isPercent = false; 

  25. 26 

  26. 27 public ExtendedStandardCategoryItemLabelGeneratory(String labelFormat, NumberFormat formatter, NumberFormat percentFormatter,boolean isPercent){ 

  27. 28 super(labelFormat, formatter, percentFormatter); 

  28. 29 if(labelFormat == null) { 

  29. 30 throw new IllegalArgumentException("Null \'labelFormat\' argument."); 

  30. 31 } else if(formatter == null) { 

  31. 32 throw new IllegalArgumentException("Null \'formatter\' argument."); 

  32. 33 } else if(percentFormatter == null) { 

  33. 34 throw new IllegalArgumentException("Null \'percentFormatter\' argument."); 

  34. 35 } else { 

  35. 36 this.labelFormat = labelFormat; 

  36. 37 this.numberFormat = formatter; 

  37. 38 this.percentFormat = percentFormatter; 

  38. 39 this.dateFormat = null; 

  39. 40 this.nullValueString = "-"; 

  40. 41 if (isPercent) 

  41. 42 this.isPercent = isPercent; 

  42. 43 } 

  43. 44 

  44. 45 } 

  45. 46 

  46. 47 @Override 

  47. 48 protected String generateLabelString(CategoryDataset dataset, int row, int column) { 

  48. 49 if(dataset == null) { 

  49. 50 throw new IllegalArgumentException("Null \'dataset\' argument."); 

  50. 51 } else { 

  51. 52 String result = null; 

  52. 53 Object[] items = this.createItemArray(dataset, row, column); 

  53. 54 result = MessageFormat.format(this.labelFormat, items); 

  54. 55 return result; 

  55. 56 } 

  56. 57 } 

  57. 58 @Override 

  58. 59 protected Object[] createItemArray(CategoryDataset dataset, int row, int column) { 

  59. 60 Object[] result = new Object[]{dataset.getRowKey(row).toString(), dataset.getColumnKey(column).toString(), null, null}; 

  60. 61 Number value = dataset.getValue(row, column); 

  61. 62 if(value != null) { 

  62. 63 if(this.numberFormat != null) { 

  63. 64 result[2] = this.numberFormat.format(value); 

  64. 65 } else if(this.dateFormat != null) { 

  65. 66 result[2] = this.dateFormat.format(value); 

  66. 67 } 

  67. 68 } else { 

  68. 69 result[2] = this.nullValueString; 

  69. 70 } 

  70. 71 

  71. 72 if(value != null) { 

  72. 73 double total = DataUtilities.calculateColumnTotal(dataset, column); 

  73. 74 // 

  74. 75 double percent = 0D;// / total; 

  75. 76 if (this.isPercent) 

  76. 77 //StandardCategoryItemLabelGenerator 返回的值是百分比 

  77. 78 percent = value.doubleValue() / total; 

  78. 79 else 

  79. 80 //返回自己原来的值 

  80. 81 percent = value.doubleValue(); 

  81. 82 //格式化 

  82. 83 result[3] = this.percentFormat.format(percent); 

  83. 84 } 

  84. 85 

  85. 86 return result; 

  86. 87 } 

  87. 88 

  88. 89 

  89. 90} 

  90. 91 

StackedBarChartDemo3

  1. 1package com.springapp.jfreechar; 



  2. 3import java.awt.*; 

  3. 4import java.text.DecimalFormat; 

  4. 5import java.text.NumberFormat; 

  5. 6import java.util.Iterator; 



  6. 8import javax.swing.*; 



  7. 10import com.sun.javafx.charts.Legend; 

  8. 11import org.jfree.chart.*; 

  9. 12import org.jfree.chart.axis.*; 

  10. 13import org.jfree.chart.labels.*; 

  11. 14import org.jfree.chart.plot.CategoryPlot; 

  12. 15import org.jfree.chart.plot.PlotOrientation; 

  13. 16import org.jfree.chart.title.LegendTitle; 

  14. 17import org.jfree.data.category.CategoryDataset; 

  15. 18import org.jfree.data.category.DefaultCategoryDataset; 

  16. 19import org.jfree.ui.ApplicationFrame; 

  17. 20import org.jfree.ui.RectangleEdge; 

  18. 21import org.jfree.ui.RefineryUtilities; 

  19. 22import org.jfree.ui.TextAnchor; 

  20. 23 

  21. 24// Referenced classes of package demo: 

  22. 25// ExtendedStackedBarRenderer 

  23. 26 

  24. 27public class StackedBarChartDemo3 extends ApplicationFrame { 

  25. 28 

  26. 29 private static final long serialVersionUID = 1L; 

  27. 30 

  28. 31 public StackedBarChartDemo3(String s) { 

  29. 32 super(s); 

  30. 33 JPanel jpanel = createDemoPanel(); 

  31. 34 jpanel.setPreferredSize(new Dimension(500, 270)); 

  32. 35 setContentPane(jpanel); 

  33. 36 } 

  34. 37 

  35. 38 private static CategoryDataset createDataset() { 

  36. 39 DefaultCategoryDataset defaultcategorydataset = new DefaultCategoryDataset(); 

  37. 40 defaultcategorydataset.addValue(.101D, "Series 1", "Cross Contamination (4.3)"); 

  38. 41 defaultcategorydataset.addValue(.4D, "Series 2", "Cross Contamination (4.3)"); 

  39. 42 return defaultcategorydataset; 

  40. 43 } 

  41. 44 

  42. 45 private static JFreeChart createChart(CategoryDataset categorydataset) { 

  43. 46 

  44. 47 JFreeChart jfreechart = ChartFactory.createStackedBarChart("Stacked Bar Chart Demo 3", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); 

  45. 48 

  46. 49 CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); 

  47. 50 //柱体 

  48. 51 ExtendedStackedBarRenderer extendedstackedbarrenderer = new ExtendedStackedBarRenderer(new DecimalFormat("#0.0%")); 

  49. 52 //柱体标签是否可见 

  50. 53 extendedstackedbarrenderer.setBaseItemLabelsVisible(true); 

  51. 54 Font labelFont = new Font("Arial", Font.PLAIN, 12); 

  52. 55 extendedstackedbarrenderer.setBaseItemLabelPaint(new GradientPaint(0.0f, 0.0f, new Color(255, 255, 255), 0.0f, 0.0f, new Color(0, 0, 0))); 

  53. 56 //设置柱体标签值的格式 

  54. 57 ExtendedStandardCategoryItemLabelGeneratory generator = new ExtendedStandardCategoryItemLabelGeneratory("{3}", 

  55. 58 NumberFormat.getPercentInstance(), new DecimalFormat("#0.0%"),false); 

  56. 59 extendedstackedbarrenderer.setBaseItemLabelGenerator(generator); 

  57. 60 //自定义柱体颜色 

  58. 61 Paint p0 = new GradientPaint(0.0f, 0.0f, new Color(237, 125, 49), 0.0f, 0.0f, new Color(237, 125, 49)); 

  59. 62 extendedstackedbarrenderer.setSeriesPaint(0, p0); 

  60. 63 Paint p1 = new GradientPaint(0.0f, 0.0f, new Color(91, 155, 213), 0.0f, 0.0f, new Color(91, 155, 213)); 

  61. 64 extendedstackedbarrenderer.setSeriesPaint(1, p1); 

  62. 65 

  63. 66 categoryplot.setRenderer(extendedstackedbarrenderer); 

  64. 67 

  65. 68 //Y 轴 

  66. 69 NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); 

  67. 70 //不设置是自动显示步长 

  68. 71 numberaxis.setTickUnit(new NumberTickUnit(0.05)); 

  69. 72 numberaxis.setLowerMargin(0.14999999999999999D); 

  70. 73 numberaxis.setUpperMargin(0.14999999999999999D); 

  71. 74 //设置是否是百分率 

  72. 75 numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance()); 

  73. 76 

  74. 77 //X 辆 

  75. 78 CategoryAxis categoryAxis = categoryplot.getDomainAxis(); 

  76. 79 //x轴旋转 

  77. 80 categoryAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); 

  78. 81 

  79. 82 //标注 

  80. 83 LegendTitle legendtitle = (LegendTitle)jfreechart.getLegend(); 

  81. 84 legendtitle.setBorder(0, 0, 0, 0); 

  82. 85 return jfreechart; 

  83. 86 } 

  84. 87 

  85. 88 public static JPanel createDemoPanel() { 

  86. 89 JFreeChart jfreechart = createChart(createDataset()); 

  87. 90 return new ChartPanel(jfreechart); 

  88. 91 } 

  89. 92 

  90. 93 public static void main(String args[]) { 

  91. 94 StackedBarChartDemo3 stackedbarchartdemo3 = new StackedBarChartDemo3("Stacked Bar Chart Demo 3"); 

  92. 95 stackedbarchartdemo3.pack(); 

  93. 96 RefineryUtilities.centerFrameOnScreen(stackedbarchartdemo3); 

  94. 97 stackedbarchartdemo3.setVisible(true); 

  95. 98 } 

  96. 99} 

  97. 100 

  98. 101 

JFreeChart之堆叠柱形图(StackedBar)的更多相关文章

  1. hcharts实现堆叠柱形图

    <!DOCTYPE > <html> <head> <meta charset="utf-8"><link rel=" ...

  2. 【前端统计图】hcharts实现堆叠柱形图(与后台数据交互)

    原型图类似如下: 图片.png <!DOCTYPE > <html> <head> <meta charset="utf-8">&l ...

  3. XCL-Charts图表库中柱形图的同源风格切换介绍

    柱形图是被使用最多的图之中的一个,在写XCL-Charts这个Android图表库时,为它花费的时间相当多,不是由于有多难绘制,而是要在设计时怎样才干保证图基类能适应各种情况,能灵活满足足够多的需求, ...

  4. R语言-画柱形图

    barplot()函数 1.柱形图 > sales<-read.csv("citysales.csv",header=TRUE) #读取数据 > barplot( ...

  5. 图表(Chart & Graph)你真的用对了吗?

    欢迎大家持续关注葡萄城控件技术团队博客,更多更好的原创文章尽在这里~~ 工作中,我们常常会遇到各式各样的数据,例如网站性能,销售业绩,客户服务 .营销活动等数据.对于这些数据,有哪些行之有效的方法来形 ...

  6. C#实现DevExpress本地化实例详解

    using System; using System.Collections.Generic; using System.Text; using DevExpress.XtraGrid.Localiz ...

  7. MPAndroidChart Wiki(译文)~Part 2

    7. 填充数据 这一章节将讲解给各式各样的图表设置数据的方法. 7.1 LineChart(线形图) 想给图表添加数据,使用如下方法: public void setData(ChartData da ...

  8. Python3 读取和写入excel

    https://blog.csdn.net/weixin_43094965/article/details/82226263一.Excel 1.Excel文件三个对象 workbook: 工作簿,一个 ...

  9. pandas可视化:各种图的简单使用

    一.Matplotlib中几种图的名字 折线图:plot 柱形图:bar 直方图:hist 箱线图:box 密度图:kde 面积图:area 散点图:scatter 散点图矩阵:scatter_mat ...

随机推荐

  1. On branch master nothing to commit, working tree clean ERROR: Repository not found. fatal: Could not read from remote repository.

    将gitbash部署hexo到github:hexo deploy 报以下错误: Administrator@liu MINGW64 /Hexo $ hexo d INFO Deploying: gi ...

  2. Sping——使用注解创建切面

    为讲解例子,我们首先定义一个Performance接口: package aoptest; public interface Performance { public void perform(); ...

  3. 初级模拟电路:3-1 BJT概述

    回到目录 1.   名称由来 BJT的全称是双极性结型晶体管(Bipolar Junction Transistor),国内俗称三极管.其实,在英语中,三极管(triode)特指以前的真空电子管形式的 ...

  4. Maven中更改默认JDK版本

    只要在settings.xml文件中加上如下标签即可.(我这里是默认的1.7版本) <profiles> <profile> <id>jdk-1.7</id& ...

  5. 11.best fields策略(dis_max参数设置)

    主要知识点 常规multi-field搜索结果分析 dis_max参数设置     一.为帖子数据增加content字段     POST /forum/article/_bulk { "u ...

  6. Vue.js:使用vue-cli快速构建项目

    vue-cli是什么? vue-cli 是vue.js的脚手架,用于自动生成vue.js模板工程的. vue-cli怎么使用? 安装vue-cli之前,需要先安装了vue和webpack,不知道怎么安 ...

  7. 洛谷 P1308 统计单词数【字符串处理】

    题目描述 一般的文本编辑器都有查找单词的功能,该功能可以快速定位特定单词在文章中的位置,有的还能统计出特定单词在文章中出现的次数. 现在,请你编程实现这一功能,具体要求是:给定一个单词,请你输出它在给 ...

  8. 【codeforces 767D】Cartons of milk

    [题目链接]:http://codeforces.com/problemset/problem/767/D [题意] 每个牛奶都有最晚可以喝的时间; 每天喝K瓶牛奶; 你有n瓶牛奶->已知每个牛 ...

  9. VNC Server Installation on CentOS 6.5

    In my case I have a fresh installed CentOS6.5 Server on which I will be installing the VNC-server so ...

  10. 洛谷 P2827 BZOJ 4721 UOJ #264 蚯蚓

    题目描述 本题中,我们将用符号表示对c向下取整,例如:. 蛐蛐国最近蚯蚓成灾了!隔壁跳蚤国的跳蚤也拿蚯蚓们没办法,蛐蛐国王只好去请神刀手来帮他们消灭蚯蚓. 蛐蛐国里现在共有n只蚯蚓(n为正整数).每只 ...