Search code examples
javajfreechart

JFreeChart Bars and lines from different starting points on the x.axis


CategoryDataSet and LineAndShapeRenderer

Postby sabonzo » Tue Jan 06, 2015 2:36 pm Hi I have a DefaultCategoryDataset which I am using for a Line chart. It creates stacked bars using a KeyToGroupMap and GroupedStackedBarRenderer. on the top of the bars I would like to create a line chart , that is why i use the LineAndShapeRenderer to make it. It works fine, my x-Axis starts from year 2015 to year 2024 so for each year there is a stacked bar (2 colors, red for internal-costs and blue for external-costs) and also for each year there is a datapoint for the line chart from year 2015 to year 2024 I would like to display the chart as following: the bars using the GroupedStackedBarRenderer range from year 2015 to 2024 the lines using the LineAndShapeRenderer range from year 2018 to 2021

is that possible? Can anyone help me?

Best regards, sabonzo


Solution

  • In the dataset that you use for the line chart, set the values for 2015, 2016 and 2017 to null. Then the line will start from 2018 only.