com.pingunaut.wicket.chartjs.core.LegendGeneratingChartPanel Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of wicket-chartjs Show documentation
Show all versions of wicket-chartjs Show documentation
chart.js for wicket projects. simple but nice looking charts with html5/css/js
/**
*
*/
package com.pingunaut.wicket.chartjs.core;
import org.apache.wicket.markup.head.IHeaderResponse;
import org.apache.wicket.markup.head.OnDomReadyHeaderItem;
import org.apache.wicket.model.IModel;
import com.pingunaut.wicket.chartjs.chart.ISimpleChart;
import com.pingunaut.wicket.chartjs.data.SimpleColorValueChartData;
import com.pingunaut.wicket.chartjs.options.AbstractChartOptions;
/**
* @author Martin Spielmann
*
*/
public abstract class LegendGeneratingChartPanel, D extends SimpleColorValueChartData, O extends AbstractChartOptions>
extends SimpleChartPanel {
private static final long serialVersionUID = 3754597810130287433L;
private String legendMarkupId;
public LegendGeneratingChartPanel(String id, IModel extends C> c) {
super(id, c);
}
public LegendGeneratingChartPanel(String id, IModel extends C> c,
int width, int height) {
super(id, c, width, height);
}
public String getLegendMarkupId() {
return legendMarkupId;
}
public void setLegendMarkupId(String legendMarkupId) {
this.legendMarkupId = legendMarkupId;
}
@Override
public void renderHead(final IHeaderResponse response) {
super.renderHead(response);
if (legendMarkupId != null && !"".equals(legendMarkupId)) {
CharSequence showLegend = String.format(
"$('#%1$s').html(%2$s.generateLegend());", legendMarkupId,
getChartCanvas().getMarkupId());
response.render(OnDomReadyHeaderItem.forScript(showLegend));
}
}
}