ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  For a Line chart, a user wants to hide the line between the first and second data point
Posted by Brian Litke on Feb-10-2024 06:54
Attachments:
Single Line chart. Can I turn off/hide the line segment between the first and second data point leaving the rest of the line showing?
line-hide-part-1.jpg

  Re: For a Line chart, a user wants to hide the line between the first and second data point
Posted by Peter Kwan on Feb-10-2024 18:19
Hi Brian,

The simplest way is to split it into two lines. On one line there is just one data point. On the second line, the first data point is Chart.NoValue, so it starts from the second data point onwards.

I am not sure what is your programming language. In C#, it is like:

double[] myData = {..... your data ....};

var layer = c.addLineLayer();

// Add a line with just the first data point
layer.addDataSet(new double[] { myData[0] }, 0xff0000).setDataSymbol(Chart.SquareSymbol, 7);

// Add another line with all the data points except the first point
myData[0] = Chart.NoValue;
layer.addDataSet(myData, 0xff0000).setDataSymbol(Chart.SquareSymbol, 7);

Best Regards
Peter Kwan

  Re: For a Line chart, a user wants to hide the line between the first and second data point
Posted by KeithB on Feb-12-2024 22:50
Thanks for this. I am creating a control chart with the range data. There is no "first" data since it is consumed calculating the range value starting with the next point!

  Re: For a Line chart, a user wants to hide the line between the first and second data point
Posted by Peter Kwan on Feb-13-2024 18:08
Attachments:
Hi KeithB,

When you draw a chart with ChartDirerctor, the data should be passed to ChartDirector as an array of numbers. I suppose for the chart in this post, it is an array of numbers of like "{98, 84, 78, 89, 30, 55, 73}"

You can use this array to create two lines. The first line with only the first point, and the second line with all the points except the first point. I have included the code I use to create the chart below:


// The data for the line chart
double[] myData = {98, 84, 78, 89, 30, 55, 73};

// The labels for the line chart
string[] labels = {"AAA", "BBB", "CCC", "DDD", "EEE", "FFF", "GGG"};

// Create a XYChart object of size 250 x 250 pixels
XYChart c = new XYChart(500, 480);

// Set the plotarea at (30, 20) and of size 200 x 200 pixels
c.setPlotArea(40, 20, 440, 420);

c.yAxis().setLinearScale(0, 100, 10);

var layer = c.addLineLayer();
layer.setDataLabelFormat("{value}%");

// Add a line with just the first data point
layer.addDataSet(new double[] { myData[0] }, 0xff0000).setDataSymbol(Chart.SquareSymbol, 9);

// Add another line with all the data points except the first point
myData[0] = Chart.NoValue;
layer.addDataSet(myData, 0xff0000).setDataSymbol(Chart.SquareSymbol, 9);

// Set the labels on the x axis.
c.xAxis().setLabels(labels);

// Output the chart
viewer.Chart = c;


Best Regards
Peter Kwan
test.png