- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
在我的项目中我使用 GWT 图表 -
<inherits name="com.googlecode.gwt.charts.Charts"/>
我想从所有条开始的地方删除垂直线,并减少条之间的空间。是否可以?我已经尝试了几次,但没有成功。这是我的 Java 代码:
BarChart chart = new BarChart();
BarChartOptions opt = BarChartOptions.create();
opt.setEnableInteractivity(true);
opt.setTitle("Statistic");
DataTable dataTable = DataTable.create();
dataTable.addColumn(ColumnType.STRING, "Name");
dataTable.addColumn(ColumnType.NUMBER, "Stocks!");
dataTable.addRows(3);
dataTable.setValue(0, 0, "Units");
dataTable.setValue(1, 0, "Stock");
dataTable.setValue(2, 0, "Invoices");
dataTable.setValue(0, 1, 743644);
dataTable.setValue(1, 1, 22628);
dataTable.setValue(2, 1, 10);
// Draw the chart
chart.draw(dataTable, opt);
I found the way to reduce the size between bars with this:
ChartArea chartArea = ChartArea.create();
chartArea.setHeight(50);
opt.setChartArea(chartArea);
最佳答案
您只能通过将其设置为与背景相同的颜色来移除垂直轴条。在这种情况下,白色:
AxisOptions hAxisOptions = AxisOptions.create();
hAxisOptions.setBaselineColor("#FFF");
opt.setHAxisOptions(hAxisOptions);
如果您还想删除网格线,请将它们也设置为背景色,因为您可以指定的最小网格线数为 2:
opt.setGridlineColor("#FFF");
如果您希望轴线看起来与网格线相同,只需将它们设置为相同的颜色即可:
AxisOptions hAxisOptions = AxisOptions.create();
hAxisOptions.setBaselineColor("#CCC");
opt.setGridlineColor("#CCC");
opt.setHAxisOptions(hAxisOptions);
您可以查看 Google Charts 文档 here指定所有可能的条形图选项以验证这是达到预期效果的唯一方法。这不仅仅是 GWT 可视化 API 的限制。
GWT Visualization API 似乎不直接支持它,但 Google Charts 支持它。通过添加 native JavaScript 方法,您可以绕过此限制。
首先,扩展 com.google.gwt.visualization.client.visualizations.corechart.Options 类以包含 native 方法:
public class BarChartOptions extends Options {
protected BarChartOptions() {
}
public final native void setGroupWidth(String groupWidth) /*-{
this.bar = { groupWidth: groupWidth }
}-*/;
public static BarChartOptions create() {
return JavaScriptObject.createObject().cast();
}
}
新的 setGroupWidth 方法现在允许您将条形宽度指定为字符串百分比。例如。 “95%”。
BarChartOptions opts = BarChartOptions.create();
opts.setGroupWidth("95%");
// Set other chart options here
// E.g. Removing the axis line
AxisOptions axisOptions = AxisOptions.create();
axisOptions.setBaselineColor("#FFF");
opts.setHAxisOptions(axisOptions);
关于java - GWT BarChart 如何减少条形之间的空间并删除起始线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22659063/
有人知道如何在数组字段中插入以竖线/竖线分隔的数组吗? 逗号可以正常工作,但是当我将其更改为 bar 时,它会产生错误“格式错误的数组文字” 示例(有效): insert into table (ar
我尽力阅读与我的问题相关的问题。最相关的是:question .但是我无法弄清楚如何解决我的问题。我有一个像这样的数据集 structure(list(COMPANY = structure(1
在使用 matplotlib 挣扎了比我想承认的时间更长的时间之后,我试图在我使用过的几乎任何其他绘图库中做一些轻而易举的事情,我决定向 Stackiverse 寻求一些见解。简而言之,我需要的是创建
如何实现带有条形样式的 Activity 指示器。根据以下文档http://developer.android.com/design/building-blocks/progress.html “Ac
我正在尝试使用数组中的数据制作水平条形图 $values = implode(',', array_values($type)); $labels = implode('|', array_keys(
这个问题在这里已经有了答案: Two-tone background split by diagonal line using css (7 个答案) Create a slanted edge
我正在处理一个范围非常大的图表,我发现条形图偏离了轴。我怎样才能阻止这个?这是我在教程中编写的一个示例,因为我的数据是通过读取大量文件获取的。这说明了我遇到的问题。我给出了标准差,意味着一个很大的范围
我在 Swift 2.2 中创建了一个 UIProgressView(条形),现在想改变它的高度。其他一些帖子建议使用 CGAffineTransformScale 来更改高度。但是,出于某种原因,这
我想在条形图上绘制两组具有不同比例的值。例如,对于一周中的每一天,我都有一个比例(比如那天同事迟到的比例)和一个值(他们平均迟到多长时间)。 这两个值可以绘制在两个单独的图表上,但将它们放在同一个图表
我想制作一个具有隐藏/显示功能的组合(线/条)图。我遇到的问题是我不知道如何指定索引更改(对于 javascript 来说是新的)这是我的示例(取消选中前两个复选框之一并重新选中它以查看问题): ht
我安装了 YCM(你完成了我),当我编码时,我发现命令 $ 不工作。它不会跳到行尾,而是跳到最后一行。例如,a.cpp 中的一行: #include| 现在光标在 include 之后,然后我键
我想在条形图顶部显示自定义标签。 下面是我的 stacklabel 代码,这里的问题是我想在 stacklabel 的格式化程序中使用堆栈的类别名称,我该如何访问它。 stackLabels: {
我是一名优秀的程序员,十分优秀!