首页
学习
活动
专区
工具
TVP
发布
精选内容/技术社群/优惠产品,尽在小程序
立即前往

在JavaFX LineChart中,有没有办法连续断开两个点的连接?

在JavaFX LineChart中,可以通过设置数据点的值为null来实现连续断开两个点的连接。具体步骤如下:

  1. 创建一个LineChart对象,并设置x轴和y轴的标签。LineChart<Number, Number> lineChart = new LineChart<>(new NumberAxis(), new NumberAxis()); lineChart.getXAxis().setLabel("X轴"); lineChart.getYAxis().setLabel("Y轴");
  2. 创建一个XYChart.Series对象,并添加数据点。XYChart.Series<Number, Number> series = new XYChart.Series<>(); series.getData().add(new XYChart.Data<>(1, 10)); series.getData().add(new XYChart.Data<>(2, null)); series.getData().add(new XYChart.Data<>(3, 20)); series.getData().add(new XYChart.Data<>(4, null)); series.getData().add(new XYChart.Data<>(5, 15));
  3. 将series对象添加到lineChart中。lineChart.getData().add(series);

通过将某个数据点的值设置为null,可以在LineChart中实现连续断开两个点的连接。在上述示例中,第2个和第4个数据点的值为null,因此它们之间的连接将被断开。

关于JavaFX LineChart的更多信息和使用方法,可以参考腾讯云的JavaFX LineChart产品文档:JavaFX LineChart产品文档

页面内容是否对你有帮助?
有帮助
没帮助

相关·内容

Python 利用Python操作excel表格之openyxl介绍Part2

## 绘图 c = LineChart() # 设置图标类型:LineChart 连线图 AreaChart 面积图 c.title = 'CPU利用率' # 设置生成图的报告名称 c.style = 10 # 设置图例样式 c.y_axis.title = '百分比' # 设置 Y 轴名称 c.x_axis.title = '时间' # 设置 X 轴名称 c.y_axis.scaling.min = 0 # 设置y轴坐标最的小值 c.y_axis.majorUnit = 10 # 设置主y轴坐标,两个“坐标刻度”直接的间隔 c.y_axis.scaling.max = 100 # 设置主y轴坐标的最大值 # 设置 data引用数据源:第2列到第列(包括第2,10列),第1行到第30行,包括第1, 30行 data = Reference(sheet, min_col=2, max_col=10, min_row=1, max_row=30) c.add_data(data, titles_from_data=True) # 设置x轴 坐标值,即轴标签(Label)(从第3列,第2行(包括第2行)开始取数据直到第30行(包括30行)) x_labels = Reference(sheet, min_col=1, min_row=2, max_row=30) c.set_categories(x_labels) c.width = 18 # 设置图表的宽度 单位 cm c.height = 8 # 设置图表的高度 单位 cm # 设置插入图表位置 cell = "A10" sheet.add_chart(c, cell) # 绘制双y坐标轴图表 sheet = work_book['DEV'] c1 = AreaChart() # 面积图 c1.title = '磁盘活动统计报告' c1.style = 10 # 10 13 11 c1.y_axis.title = '平均时长(毫秒)' c1.x_axis.title = '时间' c1.y_axis.majorGridlines = None first_row = [] # 存储第一行记录 # 获取第一行记录 for row in sheet.rows: for cell in row: first_row.append(cell.value) break # 拼接系列的方式 target_columns = ['await', 'svctm'] for target_column in target_columns: index = first_row.index(target_column) ref_obj = Reference(sheet, min_col=index + 1, min_row=2, max_row=300) series_obj = Series(ref_obj, title=target_column) c1.append(series_obj) x_labels = Reference(sheet, min_col=1, min_row=2, max_row=300) c1.set_categories(x_labels) c1.width = 18 c1.height = 8 c2 = LineChart() c2.y_axis.title = '磁盘利用率' c2.y_axis.scaling.min = 0 # 设置y轴坐标最的小值 #c2.y_axis.majorUnit = 5 # 设置主y轴坐标的坐标单位 c2.y_axis.scaling.max = 100 # 设置主y轴坐标的最大值 ref_obj = Reference(sheet, min_col=8, min_row=2, max_row=300) series_obj = Series(ref_obj, title='%util') c2.append(series_obj) s = c2.series[0] # 获取添加第一个系列 # 设置线条填充颜色,也是图例的颜色 s.graphicalProperties.line.solidFill = "DEB887" # 设置线形 可选值如下: # ['solid', 'dot', 'dash', 'lgDash', 'dashDo

02
领券