# Cartesian plane

const config = {
  type: 'scatter',
  options: {
    layout: {
      padding: {
        top: 20,
        left: 20,
        right: 20
      }
    },
    onClick(e, elements, chart) {
      rect = calculateBox(e, chart);
      chart.update();
    },
    elements: {
      labelAnnotation: {
        display: () => !!rect,
        borderWidth: 0,
        padding: 0,
        font: {
          size: 20,
          style: 'oblique'
        }
      }
    },
    scales: {
      x: {
        min: MIN,
        max: MAX,
        grid: {
          drawTicks: false
        },
        ticks: {
          display: false,
          stepSize: 0.5
        }
      },
      y: {
        min: MIN,
        max: MAX,
        grid: {
          drawTicks: false
        },
        ticks: {
          display: false,
          stepSize: 0.5
        }
      }
    },
    plugins: {
      annotation: {
        clip: false,
        common: {
          drawTime: 'beforeDraw'
        },
        annotations: {
          xAxis,
          yAxis,
          box,
          A, B, C, D,
          summary
        }
      },
      title: {
        display: true,
        text: 'Click on the chart to set the point to build the rectangle',
        position: 'bottom',
        padding: {
          top: 16,
          bottom: 0
        }
      }
    }
  }
};
Last Updated: 5/15/2023, 12:03:46 PM