|
Charts in Visual Studio |
Posted by Victor on Aug-27-2017 08:29 |
|
I was able to download the Python and C# VB versions, as the Python seems not to be working for me in Rodeo or Python Notebook. Now, I Visual Studio 2017, I am able to view the sample files.
Also was able to install the Dll. This only have one sample chart, that when dragged into the windows form, and run in Visual Studio, the windows open but no chart.
I got the demo version.
Would I be able to view real time stock charts on these too?
Thanks a lot. |
Re: Charts in Visual Studio |
Posted by Peter Kwan on Aug-29-2017 03:58 |
|
Hi Victor,
I assume you mean you have downloaded "ChartDirector for .NET", and have tried the sample Visual Studio solution (such as the "ChartDirector/NetWinCharts/NetWinCharts.sln") and all the sample code work normally and you can see all the sample charts. You have also successfully install the ChartDirector WinChartViewer control in your Visual Studio toolbox.
Then you created a brand new Windows Forms project, drag the WinChartViewer onto the Form. Have you entered the charting code for the chart you want to create? If you just add the control without any charting code, nothing will be displayed. Also, you need to run the code. If you just copy the sample code file to your project, but do not run it (call its methods in your code), then there would be any chart to display.
As a simple example, you can put the following code (copied from the Simple Bar Chart sample code) into the Form Load event handler, so it gets executed during Form Load. (The code assumes the WinChartViewer control in your Form is called winChartViewer1.)
// The data for the bar chart
double[] data = {85, 156, 179.5, 211, 123};
// The labels for the bar chart
string[] labels = {"Mon", "Tue", "Wed", "Thu", "Fri"};
// Create a XYChart object of size 250 x 250 pixels
XYChart c = new XYChart(250, 250);
// Set the plotarea at (30, 20) and of size 200 x 200 pixels
c.setPlotArea(30, 20, 200, 200);
// Add a bar chart layer using the given data
c.addBarLayer(data);
// Set the labels on the x axis.
c.xAxis().setLabels(labels);
// Output the chart
winChartViewer1.Chart = c;
//include tool tip for the chart
winChartViewer1.ImageMap = c.getHTMLImageMap("clickable", "", "title='{xLabel}: {value} GBytes'")
The above should produce a Simple Bar Chart. If it works, it confirms ChartDirector is working in your project. You can change it to some finance chart code to plot financial chart. (To being, you may try the Finance Chart sample code.) You can then modify the code to use your real data instead of using the random numbers in the code. Finally, you can modify the code to update in real time by following the various Real time chart example.
For using ChartDirector in Python Notebook or Rodeo, if it is not working, would you mind to clarify what is the error message?
Note that you would need to install the ChartDirector for Python library in the Python module search path, so that the Python interpreter can find it. Also, you must use the ChartDirector edition that matches your Python architecture. For example, if you are using 64-bit Python on Windows, please use the 64-bit Python Windows edition of ChartDirector. If you are using 32-bit Python on Windows, please use the 32-bit Python Windows edition of ChartDirector (even if your Windows is 64-bit). See:
http://www.advsofteng.com/doc/cdpython.htm#install.htm
Please make sure your are installing ChartDirector in the machine that runs Python, which may or may not be the machine that displays the chart. (I have not tried Rodeo myself, but in Python Notebook, sometimes the Python can run in a separate machine different from the machine that contains the user interface.)
Regards
Peter Kwan |
|