您好,请参考以下代码:
- var chart1 = sheet.charts.add(
- "chart1",
- GC.Spread.Sheets.Charts.ChartType.xyScatter,
- 130,
- 5,
- 500,
- 350,
- "A1:B13",
- GC.Spread.Sheets.Charts.RowCol.columns
- );
- var axes = chart1.axes();
- axes.primaryValue.title.text = "Items sold";
- axes.primaryCategory.title.text = "Advertising";
- axes.primaryCategory.majorGridLine.visible = true;
- axes.primaryCategory.majorUnit = 10;
- chart1.axes(axes);
- var targetSeriesIndex = 0;
- var targetSeries = chart1.series().get(targetSeriesIndex);
- var linearTrendline = {
- displayEquation: true,
- displayRSquared: true,
- type: GC.Spread.Sheets.Charts.TrendlineType.linear,
- style: {
- color: "red",
- width: 2,
- },
- };
- targetSeries.trendlines = [linearTrendline];
- chart1.series().set(targetSeriesIndex, targetSeries);
复制代码
|