OpenLayers饼图

时间:2017-07-19 12:45:26

标签: openlayers-3

如何在Openlayers上整合饼图?尝试使用OPenlayer样式圈实现相同,但圆不能转换为半圆,因此不能作为图表放置 请提供合适的例子。

1 个答案:

答案 0 :(得分:3)

我建议您在ol3-ext处查看import gab.opencv.*; import java.nio.*; import org.opencv.imgproc.Imgproc; import org.opencv.core.Mat; import org.opencv.core.CvType; import org.opencv.core.Core; OpenCV opencv; Imgproc imgproc; PImage canny; PImage src, out; Mat one, two; double a = 20.0; double b = 10.0; void setup() { src = loadImage("cat.jpg"); size( 429, 360); System.loadLibrary(Core.NATIVE_LIBRARY_NAME); one = new Mat( width, height, CvType.CV_8UC3); two = new Mat( width, height, CvType.CV_8UC3); one = toMat(src); imgproc.pyrMeanShiftFiltering( one, two, a, b); out = toPImage(two); } void draw() { image(out, 0, 0, width, height); } Mat toMat(PImage image) { int w = image.width; int h = image.height; Mat mat = new Mat(h, w, CvType.CV_8UC3); byte[] data8 = new byte[w*h*4]; int[] data32 = new int[w*h]; arrayCopy(image.pixels, data32); ByteBuffer bBuf = ByteBuffer.allocate(w*h*4); IntBuffer iBuf = bBuf.asIntBuffer(); iBuf.put(data32); bBuf.get(data8); mat.put(0, 0, data8); return mat; } PImage toPImage(Mat mat) { int w = mat.width(); int h = mat.height(); PImage image = createImage(w, h, ARGB); byte[] data8 = new byte[w*h*4]; int[] data32 = new int[w*h]; mat.get(0, 0, data8); ByteBuffer.wrap(data8).asIntBuffer().get(data32); arrayCopy(data32, image.pixels); return image; }

<强>示例:

  1. 简单饼图:https://github.com/Viglino/ol-ext

  2. 包含值的图表:http://viglino.github.io/ol-ext/examples/style/map.style.chart.html