sethm

Members
  • Content count

    11
  • Joined

  • Last visited

Everything posted by sethm

  1. I have been struggling with this for awhile but I have a program working that produces charts from data from a database. It can also change between charts. However, when I switch to a Pie graph the inside of the pie chart goes grey. I have tried themes but then even the outline of the pie chart disappears leaving behind just the labels. I have also tried different pallet colors from the examples on here. Is there a reason this would be happening? Below is an example of how it looks without a theme but with pallet colors. Below is my code the creates the Pie Chart public void getPieChart() { String xmlData = "<chart caption='" + Label.Text + "' subCaption='" + SubLabel.Text + "' xAxisName='Month' yAxisName='Units' showValues='0' formatNumberScale='0' showBorder='1' palettecolors='#f8bd19,#e44a00,#008ee4,#33bdda,#6baa01,#583e78'>"; SqlConnection MySql = new SqlConnection(DatabaseConnectionString); SqlCommand cmd = new SqlCommand("selectMultipleNpsScores " + PeriodType.SelectedValue + ", '" + StartDatepicker.SelectedValue + "', '" + endDatePicker.SelectedValue + "', '" + Questions.SelectedValue + "', '" + CalculationType.SelectedValue + "', 0", MySql); cmd.Connection.Open(); SqlDataReader DBValues = cmd.ExecuteReader(); SqlConnection MySql4 = new SqlConnection(DatabaseConnectionString); SqlCommand cmd4 = new SqlCommand("selectMultipleNpsScores " + PeriodType.SelectedValue + ", '" + StartDatepicker.SelectedValue + "', '" + endDatePicker.SelectedValue + "', '" + Questions.SelectedValue + "', '" + CalculationType.SelectedValue + "', 1", MySql4); cmd4.Connection.Open(); SqlDataReader DBValues4 = cmd4.ExecuteReader(); while (DBValues.Read() && DBValues4.Read()) // Append this data to the `xmlData` object. { xmlData = xmlData + "<set label='" + DBValues["description"].ToString() + "' value='" + DBValues4["actionValue"].ToString() + "' />"; } DBValues4.Close(); DBValues.Close(); xmlData = xmlData + "</chart>"; FusionCharts.Charts.Chart column = new FusionCharts.Charts.Chart(); column.SetChartParameter(FusionCharts.Charts.Chart.ChartParameter.chartId, "myChart"); column.SetChartParameter(FusionCharts.Charts.Chart.ChartParameter.chartType, ChartType.SelectedValue); column.SetChartParameter(FusionCharts.Charts.Chart.ChartParameter.chartWidth, "600"); column.SetChartParameter(FusionCharts.Charts.Chart.ChartParameter.chartHeight, "400"); column.SetData(xmlData.ToString(), FusionCharts.Charts.Chart.DataFormat.xml); Literal1.Text = column.Render(); } Any help would be very much appreciated. I have been struggling with this some time now. Thank you!
  2. I have a working msline chart built from data straight from a database that is working great. I am trying to find a way to convert it to other types of charts (column2d, and pie2d). I have tried .chartType() as refereneced here: http://www.fusioncharts.com/dev/usage-guide/how-to-guides/change-chart-properties-at-runtime.html but it says: "FusionCharts.Charts.Chart does not contain a definition for 'chartType' and no extension method 'chartType' accepting a first argument of type 'FusionCharts.Charts.Chart' could be found (are you missing a using directive or an assembly reference?)" I do not believe I am missing a reference. I have also tried altering the reference when I use .Render(). This changes the chart to the correct chart but it loses all color and many of the labels and headers. FusionCharts.Charts.Chart myFusionChart = new FusionCharts.Charts.Chart ("msline", "myChart", "600", "350", "xml", xmlData.ToString()); // Initialize the chart. Literal1.Text = myFusionChart.Render(); I replace the middle line with one of the following two lines. ("column2D", "myChart", "600", "350", "xml", xmlData.ToString()); //////Bar graph but it is not showing time periods at the bottom or color ("pie2d", "myChart", "600", "350", "xml", xmlData.ToString());//////Pie graph but it is not showing time periods or color Not sure what I am doing wrong. Any help would be very much appreciated. Thank you, Seth
  3. That worked! Thank you so much! It was really driving me nuts!
  4. Pie Chart is not filled in

    That worked! Thank you so much! It was really driving me nuts!
  5. I am still struggling with creating a Pie chart from a database. Does it need a different syntax perhaps for the string? I have been spending days on this and I feel like I am getting nowhere. Any help would be very much appreciated. Thank you!
  6. I feel a bit foolish. It turns out that I just did not have a theme chosen for my charts. So that solves my overall issue. However, pie charts are still blanked out when I change it to a pie chart. It is being created with them same code as the other charts and so it can not be the theme issue again. Is there any reason why this might be? Thanks again!
  7. I actually am starting to think that it could have to do with the name of the chart such as ("msline" vs "line", or "column2d") I found that if I put "mscolumn2d" then I see the labels of the graph (however the color is still missing). Is a page that tells what chart names to use with specific syntax? Thank you again for all of your help!
  8. Just in case it is needed. Here is my code that I created using the same reference that Moonmi Sonowal referenced. Again, it works great for turning my database data into a linegraph but I am unable to convert it to any of the other graphs. public void getLineChart() { StringBuilder xmlData = new StringBuilder(); //Create `xmlData` StringBuilder for storing data as string. xmlData.Append("<chart caption='" + Label.Text + "' subCaption='" + SubLabel.Text + "' showBorder='1' formatNumberScale='0' rotatelabels='1' showvalues='0'>"); xmlData.AppendFormat("<categories>"); //Initialize the `<categories>` element. SqlConnection MySql = new SqlConnection(DatabaseConnectionString); SqlCommand cmd = new SqlCommand("selectMultipleNpsScores " + PeriodType.SelectedValue + ", '" + StartDatepicker.SelectedValue + "', '" + endDatePicker.SelectedValue + "', '" + Questions.SelectedValue + "', '" + CalculationType.SelectedValue + "', 0", MySql); cmd.Connection.Open(); SqlDataReader DBValues = cmd.ExecuteReader(); //Iterate through the data in the variable and add the periods as //labels to the `<category>` element. Append this data to the `xmlData` object. while (DBValues.Read()) { xmlData.AppendFormat("<category label='{0}'/>", DBValues["description"].ToString()); } DBValues.Close(); xmlData.AppendFormat("</categories>"); SqlCommand cmd2 = new SqlCommand("SelectQuestionTextByQuestionID '" + Questions.SelectedValue + "'", MySql); SqlDataReader DBValues2 = cmd2.ExecuteReader(); SqlConnection MySql4 = new SqlConnection(DatabaseConnectionString); SqlCommand cmd4 = new SqlCommand("selectMultipleNpsScores " + PeriodType.SelectedValue + ", '" + StartDatepicker.SelectedValue + "', '" + endDatePicker.SelectedValue + "', '" + Questions.SelectedValue + "', '" + CalculationType.SelectedValue + "', 1", MySql4); cmd4.Connection.Open(); SqlDataReader DBValues4 = cmd4.ExecuteReader(); while (DBValues2.Read()) // Append this data to the `xmlData` object. { //these are the names of the lines xmlData.AppendFormat("<dataset seriesName='{0}'>", DBValues2["questionText"].ToString()); while (DBValues4.Read()) { xmlData.AppendFormat("<set value='{0}'/>", DBValues4["actionValue"].ToString()); //This is the data in the graph } xmlData.AppendFormat("</dataset>"); } DBValues4.Close(); DBValues2.Close(); xmlData.AppendFormat("</chart>"); //Close the `<chart>` element. FusionCharts.Charts.Chart myFusionChart = new FusionCharts.Charts.Chart ("msline", "myChart", "600", "350", "xml", xmlData.ToString()); // Initialize the chart. //("column2D", "myChart", "600", "350", "xml", xmlData.ToString()); //////Bar graph but it is not showing time periods at the bottom or color //("pie2d", "myChart", "600", "350", "xml", xmlData.ToString());//////Pie graph but it is not showing time periods or color Literal1.Text = myFusionChart.Render(); // Render the chart. }
  9. Thank you Moonmi Sonowal for your response. That is actually where I referenced in creating my code. I used that page to create a working line chart but I am unable to convert it into any of the other graphs. When I try to it loses color and many of the labels. IS there something I am missing? The version I have above is basically what I had working before with your reference except I changed it to include the type of string that Vishalikas example used so that I could attempt to use the SetChartParameters() functions.
  10. Also, I realized that even when I leave your hard coded string in the "Pie" option does not work. It loads the chart but the actual pie is not there. It just has some lines and labels.
  11. Thank you for the example. Your example works when I leave the data hard coded into the string. However, I am struggling to get it to work with the data coming straight from the database. I noticed that the formatting for your string was much different than what I had. So I tried mine as well as yours and simply replaced the hardcoded parts with variables from the database. Below is my code reworked with your string formatting. public void getChart() { String data; data = "{\"chart\":{\"caption\":\"" + Label.Text + "\",\"xaxisname\":\"Period\",\"yaxisname\":\"Numbers\",\"subCaption:\"" + SubLabel.Text + "\",\"numberprefix\":\"$\",\"showvalues\":\"1\",\"animation\":\"0\"},"; SqlConnection MySql = new SqlConnection(DatabaseConnectionString); SqlConnection MySql3 = new SqlConnection(DatabaseConnectionString); SqlCommand cmd = new SqlCommand("selectMultipleNpsScores " + PeriodType.SelectedValue + ", '" + StartDatepicker.SelectedValue + "', '" + endDatePicker.SelectedValue + "', '" + Questions.SelectedValue + "', '" + CalculationType.SelectedValue + "', 0", MySql); SqlCommand cmd2 = new SqlCommand("SelectQuestionTextByQuestionID '" + Questions.SelectedValue + "'", MySql2); SqlCommand cmd3 = new SqlCommand("selectMultipleNpsScores " + PeriodType.SelectedValue + ", '" + StartDatepicker.SelectedValue + "', '" + endDatePicker.SelectedValue + "', '" + Questions.SelectedValue + "', '" + CalculationType.SelectedValue + "', 1", MySql3); cmd.Connection.Open(); cmd3.Connection.Open(); SqlDataReader DBValues = cmd.ExecuteReader(); SqlDataReader DBValues3 = cmd3.ExecuteReader(); while (DBValues.Read() && DBValues3.Read()) { data = data + "\"data\":[{\"label\":" + DBValues["description"].ToString() + "\",\"value\":\"" + DBValues3["actionValue"].ToString() + "\"},"; } data = data + "],\"trendlines\":[{\"line\":[{\"startvalue\":\"700000\",\"istrendzone\":\"1\",\"valueonright\":\"1\",\"tooltext\":\"AYAN\",\"endvalue\":\"900000\",\"color\":\"009933\",\"displayvalue\":\"Target\",\"showontop\":\"1\",\"thickness\":\"5\"}]}],\"styles\":{\"definition\":[{\"name\":\"CanvasAnim\",\"type\":\"animation\",\"param\":\"_xScale\",\"start\":\"0\",\"duration\":\"1\"}],\"application\":[{\"toobject\":\"Canvas\",\"styles\":\"CanvasAnim\"}]}}"; DBValues.Close(); DBValues3.Close(); FusionCharts.Charts.Chart column = new FusionCharts.Charts.Chart(); column.SetChartParameter(FusionCharts.Charts.Chart.ChartParameter.chartId, "myChart"); column.SetChartParameter(FusionCharts.Charts.Chart.ChartParameter.chartType, ChartType.SelectedValue); column.SetChartParameter(FusionCharts.Charts.Chart.ChartParameter.chartWidth, "600"); column.SetChartParameter(FusionCharts.Charts.Chart.ChartParameter.chartHeight, "400"); column.SetData(data, FusionCharts.Charts.Chart.DataFormat.xml); Literal1.Text = column.Render(); } Instead of loading the chart it simply puts up "Chart..." and the page does not seem to actually be loading anything.