【发布时间】:2021-07-24 15:16:29
【问题描述】:
我在我的项目中使用 AMCharts,我想要完成这个:
给定1。数据点:
const data = [{x: 23, y: 0},{x: 24, y: 0},{x: 25, y: 23},...,{x: 26, y: 24}]
我想从序列中提取给定 X 值的任何 Y 值...
我用来创建图表的部分代码:
this.chart = am4core.create(this.chartDiv, am4charts.XYChart);
this.title = this.chart.titles.create();
// chartData is just an array of x,y values
this.chart.data = this.props.chartData;
const X_AXIS = this.chart.xAxes.push(new am4charts.ValueAxis());
X_AXIS.title.text = "X VALUES";
const Y_AXIS = this.chart.yAxes.push(new am4charts.ValueAxis());
Y_AXIS.title.text = "Y VALUES";
this.series = this.chart.series.push(new am4charts.LineSeries());
this.series.dataFields.valueX = "xValue";
this.series.dataFields.valueY = "yValue";
// cursor
this.chart.cursor = new am4charts.XYCursor();
this.chart.cursor.xAxis = X_AXIS;
this.chart.cursor.yAxis = Y_AXIS;
this.chart.cursor.snapToSeries = this.series;
我怎样才能做到这一点?在 JS 中说 X = 24 的 Y 值(类似于 this.series.get(25))
【问题讨论】:
标签: javascript reactjs amcharts amcharts4