Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Java type Config Object to get chart URL instead of providing non-formatted json string #9

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

nimaidev
Copy link

@nimaidev nimaidev 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.

2 participants