Histogram mark line


#1

Hello, i want to show a mark line in the in the histogram for the XAxis when a value is in a specific range, but in Studio i can only use the mark line in the YAxis for avarage, min, max or a specific value, how can i use this in the xAxis to specifying a value?


Label in markline
#2

Yes there is a way to do that, but you need to know in where range is the value you want to show, let me show you an example using an event in your histogram:

// this event should be executed just one time
.once("execute:stop", () => {
            const viz = cf.getVisualization('histogram_id');// this is your histogram
            const data = viz.get("data"); // you get then data

            // here you get the position of the value you want to show
            const pos = data.findIndex(d => {
                return Number(your_value) >= d.group[0][0] && Number(your_value) < d.group[0][1];
            });

            // Create the line
            let lines = cf.MarkLine()
                .data([
                    {"xAxis": pos, "label": { "show": false } }
                ]);

            // set the line and execute with no query
            viz.set("markline", lines);
            viz.execute(false);
})

#3

It works good, but the markline does not show the value, is there a way to show the value that is selected?


#4

Actually, no, you should not show the value of the mark line because is the value of the position of the range, not. the value in that range


#6

Got it, there should be a way, I’ll review e-charts configs