<div class="gmail_quote">On Tue, Jun 28, 2011 at 3:16 PM, Amitesh Kumar <span dir="ltr"><<a href="mailto:amiteshagarwal@gmail.com">amiteshagarwal@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div><span>Thank you very much for your reply! My apology for writing late but it is only today that I finally gotten around to test my code. I have one final question regarding vtk charts. If my x-axis labels are string or char* then how can I display them? In my case my x-axis labels are in the form of "x1-x2". I first tried using xLegends (in my code) as vtkStringArray with actual xAxis labels in there but that didn't work as my guess was that vtkCharts API tried to sort the points in the table. When that didn't work I tried using xLegends as vtkIntArray with indices 0 to n-1 for n bars in the bar plot which correctly created the plot. However 0 to n-1 is clearly not the right label in my case and I want use the values stored in xLabels (vtkStringArray) for my x-axis labels. I tried using setindexedLabels method as shown below but that </span>absolutely didn't seem to have any effect on the x-axis labels which were all int<span>. </span></div>
<div><br></div><div><span style="color:rgb(37, 53, 85);font-family:'Lucida Grande', Verdana, Geneva, Arial, sans-serif;font-size:12px;font-weight:bold;white-space:nowrap">void vtkPlot::SetIndexedLabels(<a href="http://www.vtk.org/doc/nightly/html/classvtkStringArray.html" style="color:rgb(61, 87, 140);font-weight:bold;text-decoration:none" target="_blank">vtkStringArray</a> * <em style="font-style:normal">labels</em>)</span></div>
<div><span style="color:rgb(37, 53, 85);font-family:'Lucida Grande', Verdana, Geneva, Arial, sans-serif;font-size:12px;font-weight:bold;white-space:nowrap"><br>
</span></div><div>My plotting part of the code is as following. Note I am using vtk nightly 5.9 for this. Do you have any idea how to solve this problem.</div><div><br></div></blockquote><div>The function you outline above is for setting tooltip text for points in a plot, so if you plotted a table,</div>
<div><br></div><div> x | y | labels</div><div> 0 | 0 | zero</div><div> 1 | 3 | three</div><div> 2 | 9 | nine</div><div><br></div><div>If you set x and y as normal for the plot, and used a vtkStringArray as that third column (labels) then the tooltip text when your mouse is over the point would be the "zero", "three" and "nine" for example.</div>
<div><br></div><div>What I think you want is custom labels on vtkAxis. So you would want to fetch the axis you are interested in, and set the custom text there. For a full example of custom labels on points in plots see the scatter plot test,</div>
<div><br></div><div><a href="http://vtk.org/gitweb?p=VTK.git;a=blob;f=Charts/Testing/Cxx/TestScatterPlot.cxx">http://vtk.org/gitweb?p=VTK.git;a=blob;f=Charts/Testing/Cxx/TestScatterPlot.cxx</a></div><div><br></div><div>For an example of setting custom axis labels from strings see test stacked bar graph,</div>
<div><br></div><div><a href="http://vtk.org/gitweb?p=VTK.git;a=blob;f=Charts/Testing/Cxx/TestStackedBarGraph.cxx">http://vtk.org/gitweb?p=VTK.git;a=blob;f=Charts/Testing/Cxx/TestStackedBarGraph.cxx</a></div><div><br></div>
<div>Specifically using a vtkDoubleArray and a vtkStringArray for the locations and strings at those locations,</div><div><br></div><div><div>axis->SetTickPositions(dates);</div><div>axis->SetTickLabels(strings);</div>
</div><div><br></div><div>Hope that helps, the tests should be a good source of up to date, well tested examples.</div><div><br></div><div>Marcus</div></div>