Skip to content

Commit

Permalink
fix #88
Browse files Browse the repository at this point in the history
  • Loading branch information
stockiNail committed Feb 17, 2023
1 parent ded2b21 commit 147d1ef
Showing 1 changed file with 47 additions and 45 deletions.
92 changes: 47 additions & 45 deletions src/org/pepstock/charba/client/Charba.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,49 +15,51 @@ Licensed to the Apache Software Foundation (ASF) under one
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
package org.pepstock.charba.client;

import org.pepstock.charba.client.resources.EmbeddedResources;
import org.pepstock.charba.client.resources.ResourcesType;

/**
* Entry point to initialize and inject all Charba modules.<br>
* This utility MUST be called as first statement before using Charba.
*
* @author Andrea "Stock" Stocchero
*
*/
public final class Charba {

/**
* To avoid any instantiation
*/
private Charba() {
// do nothing
}

/**
* Enables Charba in the application, injecting also the date time library.
*/
public static void enable() {
enable(true);
}

/**
* Enables Charba in the application.<br>
* If the argument is set to <code>false</code>, the date time library is not injected.
*
* @param loadDateTimeLibrary if <code>false</code>, the date time library is not injected
*/
public static void enable(boolean loadDateTimeLibrary) {
// checks if resources is not already injected
if (!ResourcesType.isInjected()) {
// creates an envelop
ChartEnvelop<EmbeddedResources> envelop = new ChartEnvelop<>(loadDateTimeLibrary ? EmbeddedResources.INSTANCE : EmbeddedResources.INSTANCE_WITHOUT_DATE_LIBRARY);
// then sets resource
ResourcesType.setResources(envelop);
}
}

*/
package org.pepstock.charba.client;

import org.pepstock.charba.client.resources.EmbeddedResources;
import org.pepstock.charba.client.resources.ResourcesType;

/**
* Entry point to initialize and inject all Charba modules.<br>
* This utility MUST be called as first statement before using Charba.
*
* @author Andrea "Stock" Stocchero
*
*/
public final class Charba {

/**
* To avoid any instantiation
*/
private Charba() {
// do nothing
}

/**
* Enables Charba in the application, injecting also the date time library.
*/
public static void enable() {
enable(true);
}

/**
* Enables Charba in the application.<br>
* If the argument is set to <code>false</code>, the date time library is not injected.
*
* @param loadDateTimeLibrary if <code>false</code>, the date time library is not injected
*/
public static void enable(boolean loadDateTimeLibrary) {
// checks if resources is not already injected
if (!ResourcesType.isInjected()) {
// creates an envelop
ChartEnvelop<EmbeddedResources> envelop = new ChartEnvelop<>(loadDateTimeLibrary ? EmbeddedResources.INSTANCE : EmbeddedResources.INSTANCE_WITHOUT_DATE_LIBRARY);
// then sets resource
ResourcesType.setResources(envelop);
// injects CHART.JS
ResourcesType.getResources().inject();
}
}

}

0 comments on commit 147d1ef

Please sign in to comment.