Area-spline

优质
小牛编辑
137浏览
2023-12-01

我们已经在Highcharts Configuration Syntax一章中看到了用于绘制图表的配置 。 现在,让我们看一个使用样条曲线的面积图示例。 我们还将了解其他配置。 我们在图表中更改了type属性。

图表

将图表类型配置为“areaspline”。 chart.type决定图表的系列类型。 这里,默认值是“line”。

chart.setType(Type.AREA_SPLINE);

例子 (Example)

HelloWorld.java

package cn.xnip.client;
import org.moxieapps.gwt.highcharts.client.Chart;
import org.moxieapps.gwt.highcharts.client.ChartSubtitle;
import org.moxieapps.gwt.highcharts.client.Credits;
import org.moxieapps.gwt.highcharts.client.Legend;
import org.moxieapps.gwt.highcharts.client.Series.Type;
import org.moxieapps.gwt.highcharts.client.Style;
import org.moxieapps.gwt.highcharts.client.ToolTip;
import org.moxieapps.gwt.highcharts.client.ToolTipData;
import org.moxieapps.gwt.highcharts.client.ToolTipFormatter;
import org.moxieapps.gwt.highcharts.client.labels.AxisLabelsData;
import org.moxieapps.gwt.highcharts.client.labels.AxisLabelsFormatter;
import org.moxieapps.gwt.highcharts.client.labels.YAxisLabels;
import org.moxieapps.gwt.highcharts.client.plotOptions.AreaPlotOptions;
import com.google.gwt.core.client.EntryPoint;
import com.google.gwt.user.client.ui.RootPanel;
public class HelloWorld implements EntryPoint {
   public void onModuleLoad() {
      Chart chart = new Chart()
         .setType(Type.AREA_SPLINE)  
         .setChartTitleText("Average fruit consumption during one week")  
         .setChartSubtitle(new ChartSubtitle()  
            .setStyle(new Style()
               .setPosition("absolute")  
               .setRight("0px")  
               .setBottom("0px")  
            )
         )   
         .setLegend(new Legend()  
            .setLayout(Legend.Layout.VERTICAL)  
            .setAlign(Legend.Align.RIGHT)  
            .setVerticalAlign(Legend.VerticalAlign.TOP)  
            .setX(-150)  
            .setY(100)  
            .setFloating(true)  
            .setBorderWidth(1)  
            .setBackgroundColor("#FFFFFF")  
         )  
         .setToolTip(new ToolTip()  
            .setFormatter(  
               new ToolTipFormatter() {  
                  public String format(ToolTipData toolTipData) {  
                     return "<b>" + toolTipData.getSeriesName() + "</b><br/>" +  
                        toolTipData.getXAsString() + ": " + toolTipData.getYAsLong();  
                  }  
               }  
            )  
         )  
         .setCredits(new Credits()  
            .setEnabled(false)  
         )  
         .setAreaPlotOptions(new AreaPlotOptions()  
            .setFillOpacity(0.5)  
         );  
         chart.getXAxis()  
            .setCategories(  
               "Monday",  "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"  
            );  
         chart.getYAxis()  
            .setAxisTitleText("Y-Axis")  
            .setLabels(new YAxisLabels()  
            .setFormatter(new AxisLabelsFormatter() {  
               public String format(AxisLabelsData axisLabelsData) {  
                  return String.valueOf(axisLabelsData.getValueAsLong());  
               }  
            })  
         );  
         chart.addSeries(chart.createSeries()  
            .setName("John")  
            .setPoints(new Number[] {3, 4, 3, 5, 4, 10, 12})  
         );  
         chart.addSeries(chart.createSeries()  
            .setName("Jane")  
            .setPoints(new Number[] {1, 3, 4, 3, 3, 5, 4})  
         );  
      RootPanel.get().add(chart);
   }
}

结果 (Result)

验证结果。

面积图使用样条曲线

最后更新:

类似资料

  • 从一系列的点中,创建一个平滑的二维样条曲线。内部使用Interpolations.CatmullRom来创建曲线。 代码示例 // Create a sine-like wave const curve = new THREE.SplineCurve( [ new THREE.Vector2( -10, 0 ), new THREE.Vector2( -5, 5 ), new THRE

  • 我们已经在Highcharts Configuration Syntax一章中看到了用于绘制图表的配置 。 下面给出了每秒更新的样条图表的示例。 配置 (Configurations) 现在让我们看一下所采取的其他配置/步骤。 series.addPoint 添加以1000毫秒的间隔随机创建的新点。 Timer tempTimer = new Timer() { @Override

  • 以下是带有绘图带的样条图的示例。 我们已经在Highcharts Configuration Syntax一章中看到了用于绘制图表的配置 。 现在,让我们了解带有绘图带的样条图的示例,其中采用其他配置/步骤。 配置 (Configurations) 使用yAxis.plotBands属性配置波段。 使用'from'和'to'属性设置波段范围。 使用'color'属性设置band的颜色。 使用'la

  • 我们已经在Highcharts Configuration Syntax一章中看到了用于绘制此图表的配置 。 现在让我们考虑以下示例来进一步了解带有符号的样条曲线图。 配置 (Configurations) 使用marker.symbol属性将符号添加到一系列图表中。 它可以是预先配置的符号,如“square”,“diamond”或图像的url。 标记也可以添加到系列数据的任何位置。 chart.

  • 我们已经在Highcharts Configuration Syntax一章中看到了用于绘制此图表的配置 。 现在让我们考虑以下示例来进一步理解具有反向轴的样条曲线。 配置 (Configurations) 将图表类型配置为基于样条线。 chart.type决定图表的系列类型。 这里,默认值是“line”。 配置要反转的轴。 当真正的x轴是垂直的而y轴是水平的时 - 如果图表中存在条形系列,则相反

  • 我们已经在Highcharts Configuration Syntax一章中看到了用于绘制图表的配置 。 下面给出了每秒更新的样条图表的示例。 配置 (Configurations) 现在让我们看一下所采取的其他配置/步骤。 chart.events 将一个load方法添加到chart.event属性中。 此方法以1000毫秒的间隔向系列添加随机创建的新点。 chart: { events

开发工具

Spline Library