[]
An ISparkline defines one sparkline item in a worksheet, including the cell that displays the sparkline and the source range used to generate it. Individual sparklines are typically obtained from an ISparklineGroup.
worksheet.getRange("A1:C1").setValue(new Object[] {10, 20, 15});
ISparklineGroup group = worksheet.getRange("D1").getSparklineGroups().add(SparkType.Line, "A1:C1");
ISparkline sparkline = group.get(0);
IRange location = sparkline.getLocation();
String sourceData = sparkline.getSourceData();
voidvoidsetLocation(IRange value) voidsetSourceData(String value) toJson()Returns the IRange that represents the cell where the sparkline is displayed.
worksheet.getRange("A1:B2").setValue(new Object[][] {
{10, 20},
{30, 40}
});
ISparkline sparkline = worksheet.getRange("D1").getSparklineGroups().add(SparkType.Line, "A1:B1").get(0);
IRange location = sparkline.getLocation();
IRange object that represents the location of a single sparkline.Use this method to move the sparkline to another cell by specifying the IRange that represents its display location.
worksheet.getRange("A1:C1").setValue(new Object[] {1, 3, 2});
ISparklineGroup group = worksheet.getRange("D1").getSparklineGroups().add(SparkType.Line, "A1:C1");
ISparkline sparkline = group.get(0);
sparkline.setLocation(worksheet.getRange("E1"));
value - The IRange object that represents the location of the sparkline.Use this method to retrieve the range reference string currently used by the sparkline. To change the source range, use setSourceData(String).
worksheet.getRange("A1:C1").setValue(new Object[] {1, 3, 2});
ISparklineGroup group = worksheet.getRange("D1").getSparklineGroups().add(SparkType.Line, "A1:C1");
ISparkline sparkline = group.get(0);
String sourceData = sparkline.getSourceData();
worksheet.getRange("A1:D1").setValue(new Object[] {1, 3, 2, 4});
ISparklineGroup group = worksheet.getRange("D1").getSparklineGroups().add(SparkType.Line, "A1:C1");
ISparkline sparkline = group.get(0);
sparkline.setSourceData("A1:D1");
value - The range reference string that contains the source data for the sparkline.Use this method to restore a sparkline from a JSON string created by toJson().
worksheet.getRange("A1:C1").setValue(new Object[] {1, 3, 2});
ISparklineGroup group = worksheet.getRange("D1").getSparklineGroups().add(SparkType.Line, "A1:C1");
ISparkline sparkline = group.get(0);
String json = sparkline.toJson();
sparkline.fromJson(json);
json - The JSON string representing the sparkline.Use this method to serialize the current sparkline so it can be passed to fromJson(String) to restore the sparkline configuration.
worksheet.getRange("A1:C1").setValue(new Object[] {1, 3, 2});
ISparklineGroup group = worksheet.getRange("D1").getSparklineGroups().add(SparkType.Line, "A1:C1");
ISparkline sparkline = group.get(0);
String json = sparkline.toJson();