Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions jspwiki-plugins/jspwiki-plugins-chartist/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.jspwiki</groupId>
<artifactId>jspwiki-plugins</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>
<artifactId>jspwiki-plugins-chartist</artifactId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>jspwiki-main</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

</project>
68 changes: 68 additions & 0 deletions jspwiki-plugins/jspwiki-plugins-chartist/readme.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
!!! How to include this plugin with your jspwiki deployment (using maven)

If you're building out your infrastructure, maven can help.

You probably have a project that includes the jspwiki war file as a dependency.

All that's needed to add a dependency for this library.

<dependency>
<groupId>org.apache.jspwiki</groupId>
<artifactId>jspwiki-plugins-chartist</artifactId>
<version>LATEST</version>
</dependency>

Then build as normal.

!!! How to include this plugin with your jspwiki deployment (without maven)

Download the jspwiki chartist-plugin jar file.
Add it to ./webapps/jspwiki/WEB-INF/lib, replace "jspwiki" with your context path.
Restart the server.

!!! Removing the plugin from your jspwiki deployment.

Just delete the file from ./WEB-INF/lib/jspwiki-plugins-chartist-VERSION.jar
and restart the server.

!!! Upgrading

New version? just replace the old jar file with the new one, then restart the server.

!!! Usage

Edit a wiki page. Then include the chartist plugin. Only one instance is required per wiki page.

[{org.apache.jspwiki.plugins.chartist.ChartistPlugin}]

Then insert the chart anywhere you need it. Copy inbetween example-start and example-end.
Note: when copy and pasting, the plain text editor will auto wrap the text in {{{ and }}}.
You'll need to remove those. In addition, the plugin reference may get an extra '['. Remove that too.

example-start

%%chartist-line {
high: 15,
low: -5
}
|| Monday || Tuesday || Wednesday || Thursday || Friday
| 12| 9 | 7 | 8 | 5
| 2 | 1 | 3.5| 7 | 3
| 1 | 3 | 4 | 5 | 6
/%

example-end

Then save the page. Hopefully a chart will render. If it does not, check the browser console for potential clues.

!!! Maintenance notes

Currently, this is at chartist v1.5.0.
sourced Dec 2025 by pulling the webjar, then extracting
the umd.js and css files and placing in the src/main/resources/META-INF/chartist-plugin

The webjar, at this point in time, has a directory with a "." as a path, which is strange.
This caused the java compiled to to complain, otherwise the webjar is the way to go.

Chartist is MIT licensed.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
/*
* Copyright 2025 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.apache.jspwiki.plugins.chartist;

import java.util.Locale;
import java.util.Map;
import org.apache.wiki.api.core.Context;
import org.apache.wiki.api.exceptions.PluginException;
import org.apache.wiki.api.plugin.Plugin;

/**
* Chartlist-js plugin for JSPWiki.
*
* See readme for deployment and usage guide.
* @since 3.0.0
*/
public class ChartistPlugin implements Plugin {

@Override
public String execute(Context context, Map<String, String> params) throws PluginException {
StringBuilder sb = new StringBuilder();
sb.append("""
<style type="text/css">
.chartist-options,.chartist-table{
display:none;
}
.ct-chart .ct-label,.ct-chart .ct-label.ct-vertical,.ct-chart .ct-label.ct-horizontal{
font-size:1em;
}
.ct-chart-pie .ct-label{
fill:rgba(255,255,255,.8);
}

</style>
<script>
const script = document.createElement('script');
script.src = 'chartist-plugin/index.umd.js';
document.head.appendChild(script);

const behavior = document.createElement('script');
behavior.src = 'chartist-plugin/Wiki.Chartist.Behavior.js';
document.head.appendChild(behavior);

const stylesheet = document.createElement('link');
stylesheet.rel = 'stylesheet';
stylesheet.type = 'text/css';
stylesheet.href = 'chartist-plugin/index.css';
document.head.appendChild(stylesheet);
</script>

""");
//<link rel="stylesheet" href="webjars/chartist/dist/index.css" />
//<script type="text/javascript" src="webjars/chartist/dist/index.umd.js"></script>

return sb.toString();
}

@Override
public String getSnipExample() {
return Plugin.super.getSnipExample();
}

@Override
public String getDisplayName(Locale locale) {
return Plugin.super.getDisplayName(locale);
}
}

Loading
Loading