0

I have created a chart with 3 points. I have added two graphical elements as circle and rectangle (line) for dragging the points. Circle dragging should apply for all three points in the graph as in the expected behavior screenshot below. Line dragging is a vertical shift for graph to move it vertically. Circle dragging does not apply for all 3 points when I return both graphical elements in the elements array as in the code. It just applies only for 1st point. When I return one graphical element at a time it works.

Current Behaviour image of how chart works now

Below I have included the code which returns graphic elements

myChart.setOption({
    graphic: data.map(function (item, dataIndex) {
      
      let rec = {
        type: 'group',
        left: 'center',
        position: myChart.convertToPixel('grid', item),
        draggable: 'vertical',
        ondrag: function (dx, dy) {
          onPointDraggingLine(dataIndex, [this.x, this.y]);
        },

        children: [
          {
            type: 'rect',
            top: '200x',
            shape: {
              width: 470,
              height: 0
            },
            style: {
              stroke: 'gray',
              lineWidth: 5,
              lineDash: [6]
            },
            cursor: 'move'
          }
        ]
      };
      let onlyCrc = {
        type: 'circle',
        position: myChart.convertToPixel('grid', item),
        draggable: true,
        ondrag: function (dx, dy) {
          onPointDragging(dataIndex, [this.x, this.y]);
        },
        shape: {
          cx: 0,
          cy: 0,
          r: symbolSize / 2
        },
        invisible: false,

        z: 100,
        cursor: 'move'
      };
   
      return { elements: [rec, onlyCrc] };
       
    })
  }); 

I have tried to return graphical elements as array of objects .And I have tried by giving a condition for dataIndex while mapping. but didn't work. Expected behavior is as below.

Expected Behavior. image of how chart should work

Below I have attached the whole code I tried in Codepen.

Link to Minimal Reproduction https://codepen.io/rushaidrilaf/pen/bGKONRj

Rushaid
  • 5
  • 4

1 Answers1

0

I was able to Solve this. Started to resolve it by pointing the dragging function to 2nd point in the graph and updating the position of circular graphical element while dragging the horizontal line.

solution can be viewed from this link https://codepen.io/rushaidrilaf/pen/bGKONRj

enter code here
Rushaid
  • 5
  • 4
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Dec 09 '22 at 16:38