Search code examples
javascriptflot

Flot JS turn target into diamond shape


I've three series of data: for green bars, red bard and target like

var dataBarsRed = {
    data: [
        [2, 3], ],
    label: 'Bars in Red',
    color: 'red'
};
var dataBarsGreen = {
    data: [
        [1, 2],
        [3, 1],
        [4, 3]
    ],
    label: 'Bars in Green',
    color: 'green'
};
var dataLines = {
    data: [
        [1, 3, 3],
        [2, 3.5, 3.5],
        [3, 1.5, 1.5],
        [4, 2.5, 2.5]
    ],
    label: 'Lines',
    color: 'navy',
    bars: {
        barWidth: 0.5
    }
};

I've attached the fiddle for it. It is possible to make the target as diamond (this) using Flot JS?


Solution

  • You can customize the point shape by specifying it in the series options (or each individual series). The symbol plugin can be used access more shapes:

    var options = {
        series: {
            points: {
                shape: "diamond"
            }
        }
    }
    

    This updated JSFiddle uses the symbols plugin to show diamonds as the point marker.