Hii all,
Created a report with a bar chart and placed a script in the bar chart. In the Preview tab, check that the x-axis 'ist_date' is not showing and the y-axis 'total_totalizer' data is showing.
Created store procedure for the fetch the data from database.
Bar chart configuration.
Defined data key : 'Monthly'
Configured the script for the custom bar chart.
def configureChart(data, chart):
from org.jfree.data.category import DefaultCategoryDataset
# Get the original dataset from the chart
originalDataset = chart.getCategoryPlot().getDataset()
# Create a new dataset
filteredDataset = DefaultCategoryDataset()
# Extract data from the original dataset
for row in range(originalDataset.getRowCount()):
for col in range(originalDataset.getColumnCount()):
category = originalDataset.getColumnKey(col) # Assume this is 'ist_date'
series = originalDataset.getRowKey(row) # Series name (e.g., 'total_totalizer')
value = originalDataset.getValue(row, col) # Data value
# Add only 'total_totalizer' values to the new dataset
if series == 'total_totalizer' and value is not None:
# Scale the value by 1000
filteredDataset.addValue(value * 1000, series, category)
# Set the new dataset to the chart
chart.getCategoryPlot().setDataset(filteredDataset)
When the preview tab the ist_date not displayed.