Skip to content

Conversation

@nimxch
Copy link

@nimxch nimxch commented Nov 6, 2024

If user want to provide your Chart.js config in a neat manner instead of doing all the string formatting, you can use getUrlV2()

Example:

// Instanciate ChartConfig object
ChartConfig config = new ChartConfig();

// Set the char type. e.g bar, line etc
config.setType("bar");
//Instantiate ChartData
ChartData data = new ChartData();
// Set the labels and chart Data
data.setLabels(List.of("Q1", "Q2", "Q3", "Q4"));  //labels

//Dataset 1
Dataset dataset = new Dataset();
dataset.setLabel("Users");
dataset.setData(List.of("50", "60", "70", "180"));

//Dataset 2
Dataset dataset2 = new Dataset();
dataset2.setLabel("Revenue");
dataset2.setData(List.of("100", "200", "300", "400"));

//Set the required Data
data.setDatasets(List.of(dataset, dataset2));
config.setData(data);
chart.setChartConfig(config);

//get the URL
chart.getUrlV2()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant