hkkwon89
07-21-2022Cloud Apps
Goal line in a bar/column chart, is it possible to take an user input to set the goal?
I have currently implemented the benchmark target line from
https://www.binextlevel.com/post/add-target-benchmark-line-to-a-chart-in-sisense
I was wondering if it's possible to have a user input using Blox to set that benchmark line instead of using a static number in a script. Or any other way other than using Blox?
Thank you in advance
Hi hkkwon89 ,
Create a blox using below code and update "widgetToModify" with id of bar/column chart:
{ "style": "", "script": "", "title": "", "showCarousel": true, "carouselAnimation": { "delay": 0, "showButtons": false }, "body": [ { "type": "Container", "items": [ { "type": "ColumnSet", "columns": [ { "type": "Container", "items": [ { "type": "Input.Text", "id": "data.benchmark", "title": "New Input", "placeholder": "Benchmark Value" } ] } ] } ] } ], "actions": [ { "type": "plotlineInChart", "title": "Plot Line", "data": { "widgetToModify": [ "85694c8aa77683002ear6sdfc" ], "benchmark": 300 } } ] }Then create an action in blox using below script and name it as "plotlineInChart":
const benchmark = payload.data.benchmark; var widgetId = payload.data.widgetToModify; payload.widget.dashboard.widgets.$$widgets .filter(i => widgetId == i.oid) .forEach(function (widget) { widget.on('processresult', function(se, ev){ ev.result.yAxis[0].plotLines = [{ color: '#2ec7b5', dashStyle: 'LongDash', width: 4, value: benchmark, zIndex: 5, label: { text: 'Target' } }] }) widget.changesMade() widget.refresh() })-Hari