All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.pingunaut.wicket.chartjs.core.LegendGeneratingChartPanel Maven / Gradle / Ivy

Go to download

chart.js for wicket projects. simple but nice looking charts with html5/css/js

There is a newer version: 7.0.1
Show newest version
/**
 * 
 */
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 c) {
		super(id, c);
	}

	public LegendGeneratingChartPanel(String id, IModel 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));
		}
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy