MapViewer Html5 API. Error with Variable Pie Chart Style Model
Hello,
I have a serious problem related to Variable Pie Chart Style. MapViewer - Mapbuilder version: 11.1.1.7.3.
[ALERT] MAPVIEWER_9023:Cannot load style.
Source: OM.style.StyleStore.parseXMLStyle
OMS: oracle.mapviewer.share.stylex.VariablePieChartStyleModel cannot be cast to oracle.mapviewer.share.stylex.BucketStyleModel
In Mapbuilder, I have a geometry theme with rendering style, an advanced variable pie with variable range, style. This is the XML of advanced style:
<?xml version="1.0" ?>
<AdvancedStyle>
<VariablePieChartStyle startradius="5" increment="4">
<PieSlice name="T004_2009" color="#0033FF"/>
<PieSlice name="T004_2010" color="#FF0033"/>
<PieSlice name="T004_2011" color="#33FF00"/>
<Buckets>
<RangedBucket seq="0" label="0 - 20%" low="0" high="100000"/>
<RangedBucket seq="1" label="20 - 40%" low="100001" high="370000"/>
<RangedBucket seq="2" label="40 - 60%" low="370001" high="1000000"/>
<RangedBucket seq="3" label="60 - 80%" low="1000001" high="2500000"/>
<RangedBucket seq="4" label="80 - 100%" low="2500001" high="2.0E7"/>
</Buckets>
</VariablePieChartStyle>
</AdvancedStyle>
and this is the XML of the theme:
<?xml version="1.0" standalone="yes"?>
<styling_rules key_column="ID" caching="NONE">
<hidden_info>
<field column="INSTITUTION1" name="Port Name"/>
<field column="T004_2009_CHAR" name="2009"/>
<field column="T004_2010_CHAR" name="2010"/>
<field column="T004_2011_CHAR" name="2011"/>
<field column="T004_2012_CHAR" name="2012"/>
<field column="T004_2013_CHAR" name="2013"/>
<field column="T004_2014_CHAR" name="2014"/>
</hidden_info>
<rule column="PASSENGERS_2009,PASSENGERS_2010,PASSENGERS_2011">
<features style="V.T004_PASSENGERS_VPIE"> (NVL(PASSENGERS_2009, 0) !=0 AND NVL(PASSENGERS_2010,0) != 0 AND NVL(PASSENGERS_2011, 0) != 0) </features>
<label column="INSTITUTION1" style="T.CITY_NAME_H"> 1 </label>
</rule>
</styling_rules>
When I preview the theme in mapbuilder everything seems fine.
The problem arises, when I try to add a layer with this theme and style in my map in my APEX (version:4.2.6) application.
This is the javascript:
layer = new OM.layer.VectorLayer("layer1",
def:{
type:OM.layer.VectorLayer.TYPE_PREDEFINED,
dataSource:ds, theme:themename,
url: baseURL
map.addLayer(layer) ;
and this is the error I get:
[ALERT] MAPVIEWER_9023:Cannot load style.
Source: OM.style.StyleStore.parseXMLStyle
OMS: oracle.mapviewer.share.stylex.VariablePieChartStyleModel cannot be cast to oracle.mapviewer.share.stylex.BucketStyleModel
I' d appreciate any help.
Thanks in advance,
Vasso
Hi,
You're setting XML data in a JSON model, that's why the binding is incorrect.
Depending on what your MII transaction is returning, you need to either retrieve the JSON part in the XML, or use a XML Model.
Regards,
Tanguy
Similar Messages
-
MV 11gPr1 - variable pie chart issue
Hi,
Trying out advanced style - variable pie chart - we faced some issue - if data source contains bigger numbers (e.g. 100000,200000....) something causes that radius of all pies is the same. with smaller values (10,20...) the pie radius is variable.
thanks,
BranislavHi Joao,
here is the definition of that advanced style:
<?xml version="1.0" ?>
<AdvancedStyle>
<VariablePieChartStyle startradius="25" increment="15">
<PieSlice name="H" color="#005BBF"/>
<PieSlice name="O" color="#FC074F"/>
<PieSlice name="U" color="#00FF00"/>
<Buckets>
<RangedBucket seq="0" label="-Infinity - 4000" low="-Infinity" high="4000"/>
<RangedBucket seq="1" label="4000 - 6000" low="4000" high="6000"/>
<RangedBucket seq="2" label="6000 - 8000" low="6000" high="8000"/>
<RangedBucket seq="3" label="8000 - Infinity" low="8000" high="Infinity"/>
</Buckets>
</VariablePieChartStyle>
</AdvancedStyle>
thanks,
Branislav -
Issues with multilevel pie chart drill down with push button
I am new to Xcelsius. I am trying to build a multilevel pie chart drill down (one pie chart drilling down to another etc) and I am able to achieve that. Now I want to add a Back Button using Push Button so that I can go up. When I preview, the Push Button goes into two state and I have to double click to go back. Can anyone tell me what I am doing wrong. I am using the latest Xcelsius. [The source code is here|http://www.woofiles.com/dl-195360-3lTyVM8Z-piechartdrilldownwithpushbutton.xlf]
Thankyou.Hi Murali
This is exactly the same what i tried to do,
Drill down to 4 levels State -> City-> store etc with 4 pie charts and similar push button to close each level to
go back to previous chart, first run from 1 to 4 works fine, then after closing all the levels and when i am at the pie chart 1
if i click any pie slice it will jump to Pie chart 4 straight,
I tried tracking the issue, all i could find is some how the previous dynamic visibility values are back even after erasing
the data with the PUSH button (Destination cell insertion with blank or 0).
did you find a solution for this issue ?
Thanks
Chandra -
Error with variable substitution..
Hi
I am getting following error message for variable substitution
*Message processing failed. Cause: com.sap.aii.af.ra.ms.api.RecoverableException: Error during variable substitution: com.sap.aii.adapter.file.varsubst.VariableDataSourceException: The following variable was not found in the message payload: date_stamp: com.sap.aii.adapter.file.configuration.DynamicConfigurationException: Error during variable substitution: com.sap.aii.adapter.file.varsubst.VariableDataSourceException: The following variable was not found in the message payload: date_stamp
<?xml version="1.0" encoding="UTF-8" ?>
- <I813_EModMCS_IB_MT>
- <Records>
<ModMod>111</ModMod>
<DesModdcr>222</DesModdcr>
- <Date_Stamp>
<Date_Stamp>20080338</Date_Stamp>
</Date_Stamp>
</Records>
</I813_EModMCS_IB_MT>
date_stamp payload:I813_EModMCS_IB_MT,1,Records,2,Date_Stamp,3,Date_Stamp,1
Would appriciate if you can correct the variable substitution...
RegardsTo reference the element that is in bold in the example, the following expression is used: payload:root,1,e1,1,e2,2
The parser searches for the first occurrence of the root element at the first level. It then searches for the first occurrence of e1 at the second level and for the second occurrence of e2 at the third level. The content of the last element (u201CExample Valueu201D) is set as the value for a specified variable.
<?xml version="1.0" encoding="UTF-8" ?>
<root>
<dummy>
<e1>
<e2>Data_1</e2>
<f/>
<g attr="abc">text</g>
<e2>Data_2</e2>
</e1>
</dummy>
<e1>
<e2>illegal/value</e2>
<f/>
<g attr="abc">text</g>
<e2 attr="fghij">Example Value</e2>
</e1>
</root>
Edited by: Progirl Progirl on Jul 17, 2008 8:04 AM -
Hi Gurus
I try to do a pie chart and a i´ve a problem .in the format Categories i use percent 0.00% for to see the value but i can´t see the name of the categories .it´s possible and how ?
thanks GursHi,
you can use $Category to display the category name in your format of a pie label. Combined with a line break your format string would look like <b>$Category$br$Percent0.00 "%"</b>.
Note that you must have IGS 7.00 patch 10 to use this feature. See also SAP notes <a href="http://service.sap.com/sap/support/notes/1076634">1076634</a> and <a href="http://service.sap.com/sap/support/notes/1064448">1064448</a> for more information.
Best regards
Matthias -
I tried to create 3D Pie Chart using the code below but it come back with no chart data available. I tested the select statement in sqlplus, it works. Is there something wrong with my select statement??
SELECT NULL LINK, 'Saturday' LABEL, DECODE(SUM(hours1),NULL,0,SUM(hours1)) VALUE
FROM Ewbs e,
Timesheet t
WHERE t.Company = 'A1000'
AND t.Entity_item = '504586'
AND t.Timesheet_date > NVL(TO_DATE('07-NOV-2008','DD-MON-YYYY'),TO_DATE('01-JAN-1900','DD-MON-YYYY'))
AND t.Timesheet_date <= TO_DATE(SYSDATE,'DD-MON-YYYY')
AND e.Ewbs_code = t.Ewbs_code
AND e.Hour_class = '13'
AND TO_CHAR(t.Timesheet_date,'YYYY') = TO_CHAR(SYSDATE,'YYYY')
UNION
SELECT NULL LINK, 'Sunday' LABEL, DECODE(SUM(hours2),NULL,0,SUM(hours2)) VALUE
FROM Ewbs e,
Timesheet t
WHERE t.Company = 'A1000'
AND t.Entity_item = '504586'
AND t.Timesheet_date > NVL(TO_DATE('07-NOV-2008','DD-MON-YYYY'),TO_DATE('01-JAN-1900','DD-MON-YYYY'))
AND t.Timesheet_date <= TO_DATE(SYSDATE,'DD-MON-YYYY')
AND e.Ewbs_code = t.Ewbs_code
AND e.Hour_class = '13'
AND TO_CHAR(t.Timesheet_date,'YYYY') = TO_CHAR(SYSDATE,'YYYY');Hello,
Can you create the same query you use for your chart as a report please?
Just to make sure you get actual data. One other thing, you can write DECODE(SUM(hours1),NULL,0,SUM(hours1)) as NVL(SUM(hours1),0)
Regards,
Dimitri
http://dgielis.blogspot.com/
http://www.apex-evangelists.com/
http://www.apexblogs.info/
REWARDS: Please remember to mark helpful or correct posts on the forum -
Hi
I wrote a program that is supposed to call a method that returns 21 numbers with doubles from the user, then the program is supposed to call a method that displays the highest and lowest numbers entered as well as the average of the numbers. But... I get 2 errors that say cannot resolve symbol for lines 17 and 18 (which is this part number(arrays) and display(arrays) and another one that says cannot resolve symbols for line 40 int average = numbers.getAverage(); heres the program
import javax.swing.JOptionPane;
import java.util.*;
public class array
public static void main (String [] args)
number(arrays);
display(arrays);
int[] numbers = new int[21];
public static double number(int[] numbers)
for(int i = 0; i < numbers.length; i++)
numbers[i] = Integer.parseInt(JOptionPane.showInputDialog("Choose a number"));
public static double display(int[] numbers)
Arrays.sort(numbers);
System.out.println(numbers[0] + "is your lowest number");
System.out.println(numbers[21] + "is your highest number");
int average = numbers.getAverage();
System.exit(0);
}thanksyou loop through and assign the numbers in numbers to
a variable called sum then divide by numbers.length,
would that be how you do it?It might just be a case of sloppy wording, but as written, no, that's not quite what you'd want to do.
for (...) {
sum = numbers[ix];
} That's what your wording says to me. That may not be what you meant, but if it is, try it and see what happens. -
Errors with variable declarations
Hi,
Is it possible that when I declare a variable using the scriplet tags:
<% String test; %>
That it is not being declared properly and I cannot use it later on in the page?
<% test="Hello"; %>
I keep getting error messages and they seem to be centered around some of my variables that have been declared with scriptlet tags.
Thanks,
PreetiInstead of
<% String test; %>
use
<%! String test; %>
Then test will be accessible throughout instead of just the service method.
If the problem persists just post your code & specify the exact error.
null -
Help With Displaying Pie Chart
Hi, I've put some code together but cannot seem to get my chart to display. I hope it's something simple but being very new to this I'm having a difficult time.Thanks in advance.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.NumberFormat;
import java.awt.Color;
public class MortgageCalc_wk5 extends JFrame implements ActionListener {
private static final long serialVersionUID = 6L;
private static final Rectangle Rectangle = null;
//Set up panels for Frame
JPanel topPanel = new JPanel();
JPanel bottomPanel = new JPanel();
JPanel radioPanel = new JPanel();
JPanel grfxPanel = new JPanel(); //new line
//Set up Layout
FlowLayout flowLayout = new FlowLayout();
BorderLayout borderLayout = new BorderLayout();
//Radio Choice Style Buttons
JRadioButton Choice1 = new JRadioButton ("User Input", true);
JRadioButton Choice2 = new JRadioButton ("User Selection", false);
//Set up JLabels, JButtons, and JTextFields
JLabel amountLabel = new JLabel("Loan Amount");
JTextField loanField = new JTextField(7);
JLabel termLabel = new JLabel("Term(Yrs)");
JTextField termField = new JTextField(4);
JLabel rateLabel = new JLabel("Rate");
JTextField rateField = new JTextField(4);
JComboBox options = new JComboBox();
JLabel optionsLabel = new JLabel();
JButton calcButton = new JButton("Calculate");
JButton resetButton = new JButton("Reset");
JButton exitButton = new JButton("Exit");
JButton grfxButton = new JButton("Display Graphics"); //new line
JLabel paymentLabel = new JLabel("Monthly Payment =");
JTextField paymentField = new JTextField(6);
JLabel outputLabel = new JLabel("Loan Amoritization Chart");
JTextArea calcField = new JTextArea(10, 25);
JScrollPane scroll = new JScrollPane(calcField, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
ButtonGroup radioSelect = new ButtonGroup();
JLabel grfxLabel =new JLabel ("Graphic Chart"); //new line
JTextField grfxField = new JTextField ("Graphics"); // new line
//Default constructor
public MortgageCalc_wk5() {
super("Tony's Calculator - Week 5");
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setVisible(true);
//add ActionListeners
loanField.addActionListener(this);
termField.addActionListener(this);
rateField.addActionListener(this);
options.addActionListener(this);
calcButton.addActionListener(this);
grfxButton.addActionListener(this); //new line
resetButton.addActionListener(this);
exitButton.addActionListener(this);
Choice1.addActionListener(this);
Choice2.addActionListener(this);
//Top Panel Layout
topPanel.setLayout(flowLayout);
topPanel.add(amountLabel);
topPanel.add(loanField);
radioSelect.add(Choice1);
radioSelect.add(Choice2);
topPanel.add(Choice1);
topPanel.add(Choice2);
//Loan Term Options For JComboBox
options.addItem("7 years @ 5.35%");
options.addItem("15 years @ 5.5%");
options.addItem("30 years @ 5.75%");
options.setEnabled(false);
topPanel.add(options);
topPanel.add(termLabel);
topPanel.add(termField);
topPanel.add(rateLabel);
topPanel.add(rateField);
topPanel.add(paymentLabel);
topPanel.add(paymentField);
paymentField.setEditable(false);
//Was Bottom Panel Now East Panel, Calculate Reset,Exit, and Display Buttons
bottomPanel.add(calcButton);
bottomPanel.add(resetButton);
bottomPanel.add(exitButton);
bottomPanel.add(grfxButton); //new line
calcButton.setBackground(Color.blue);
resetButton.setBackground(Color.white);
exitButton.setBackground(Color.red);
calcField.setBackground(Color.orange);
grfxPanel.setBackground(Color.green); //new line
grfxPanel.add(grfxField); // new line
//add Container
Container pane = getContentPane();
pane.setLayout(borderLayout);
pane.add(topPanel, BorderLayout.NORTH);
pane.add(calcField, BorderLayout.WEST);
pane.add(grfxPanel, BorderLayout.SOUTH); //new line
pane.add(bottomPanel, BorderLayout.EAST);
calcField.setLineWrap(true);
calcField.setWrapStyleWord(true);
calcField.setEditable(false);
pane.add(scroll);
scroll.setViewportView(calcField);
pack();
grfxPanel.setBounds(Rectangle); //new line
//actionEvent Listeners
public void actionPerformed(ActionEvent event) {
Object source = event.getSource();
if (source == calcButton) {
startCalculations();
if (source == resetButton) {
reset();
if (source == grfxButton) { //new line
ChartPanel();
if (source == exitButton) {
end();
if (source == Choice1) {
options.setEnabled(false);
termField.setEnabled(true);
rateField.setEnabled(true);
if (source == Choice2) {
options.setEnabled(true);
termField.setEnabled(false);
rateField.setEnabled(false);
public void ChartPanel() { //newline
JFrame grfxPanel = new JFrame();
grfxPanel.setSize(400, 300);
double[] values = new double[3];
String[] names = new String[3];
values[0] = 1;
names[0] = "Item 1";
values[1] = 2;
names[1] = "Item 2";
values[2] = 4;
names[2] = "Item 3";
grfxPanel.getContentPane().add(new ChartPanel(values, names, "title"));
public class ChartPanel extends JPanel {
private static final long serialVersionUID = 6L;
public double[] values;
public String[] names;
public String title;
public ChartPanel(double[] v, String[] n, String t) {
names = n;
values = v;
title = t;
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (values == null || values.length == 0)
return;
double minValue = 0;
double maxValue = 0;
for (int i = 0; i < values.length; i++) {
if (minValue > values)
minValue = values[i];
if (maxValue < values[i])
maxValue = values[i];
Dimension d = getSize();
int clientWidth = d.width;
int clientHeight = d.height;
int barWidth = clientWidth / values.length;
Font titleFont = new Font("SansSerif", Font.BOLD, 20);
FontMetrics titleFontMetrics = g.getFontMetrics(titleFont);
Font labelFont = new Font("SansSerif", Font.PLAIN, 10);
FontMetrics labelFontMetrics = g.getFontMetrics(labelFont);
int titleWidth = titleFontMetrics.stringWidth(title);
int y = titleFontMetrics.getAscent();
int x = (clientWidth - titleWidth) / 2;
g.setFont(titleFont);
g.drawString(title, x, y);
int top = titleFontMetrics.getHeight();
int bottom = labelFontMetrics.getHeight();
if (maxValue == minValue)
return;
double scale = (clientHeight - top - bottom) / (maxValue - minValue);
y = clientHeight - labelFontMetrics.getDescent();
g.setFont(labelFont);
for (int i = 0; i < values.length; i++) {
int valueX = i * barWidth + 1;
int valueY = top;
int height = (int) (values[i] * scale);
if (values[i] >= 0)
valueY += (int) ((maxValue - values[i]) * scale);
else {
valueY += (int) (maxValue * scale);
height = -height;
g.setColor(Color.red);
g.fillRect(valueX, valueY, barWidth - 2, height);
g.setColor(Color.black);
g.drawRect(valueX, valueY, barWidth - 2, height);
int labelWidth = labelFontMetrics.stringWidth(names[i]);
x = i * barWidth + (barWidth - labelWidth) / 2;
g.drawString(names[i], x, y);
//Calculation Section
void startCalculations() {
NumberFormat currency = NumberFormat.getCurrencyInstance();
//Variables
double amount = 0;
double term = 0;
double interest = 0;
double moIn = 0;
double moTerm = 0;
double payment = 0;
double newPrin = amount;
boolean Exception = false;
//Input Validation
try {
amount = Double.parseDouble(loanField.getText());
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog(null, "Commas, Letters, and Puncuation NOT Allowed",
"Message Dialog", JOptionPane.ERROR_MESSAGE);
loanField.setText(null);
calcField.setText(null);
//User's Loan Choice
if (Choice2.isSelected())
if(options.getSelectedIndex() == 0)
term=7;
interest=5.35;
else if(options.getSelectedIndex() ==1)
term=15;
interest=5.5;
else
term=30;
interest=5.75;
else
//More Validation
try
term = Double.parseDouble(termField.getText());
catch (NumberFormatException e)
JOptionPane.showMessageDialog(this,"Enter amounts greater than zero","Please enter new amount",JOptionPane.ERROR_MESSAGE);
Exception=true;
termField.setText(null);
try
interest= Double.parseDouble(rateField.getText());
catch (NumberFormatException e)
JOptionPane.showMessageDialog(this,"Enter an Amount Greater Than Zero, % Not Allowed","Please enter Another Amount",JOptionPane.ERROR_MESSAGE);
Exception=true;
rateField.setText(null);
if ((amount <= 0 || term <= 0 || interest <= 0) && (Exception == false)) {
JOptionPane.showMessageDialog(null, "Please Enter a Number Greater Than ZERO.",
"Message Dialog", JOptionPane.ERROR_MESSAGE);
if(amount <= 0)
loanField.setText(null);
paymentField.setText(null);
calcField.setText(null);
termField.setText(null);
rateField.setText(null);
//Amortization Results Chart
if (amount >7) {
amount = Double.parseDouble(loanField.getText());
moIn = (interest / 12) / 100;
moTerm = term * 12;
payment = amount * (moIn / (1 - java.lang.Math.pow((1 + moIn), (-moTerm))));
paymentField.setText("" + currency.format(payment));
calcField.append("Period");
calcField.append(" ");
calcField.append("Payment Amount");
calcField.append(" ");
calcField.append("Interest Paid");
calcField.append(" ");
calcField.append("Principle Paid");
calcField.append(" ");
calcField.append("Loan Balance");
calcField.append(" \n");
for (int i = 1; i <= moTerm; i++) {
double newIn = moIn * amount;
double reduct = payment - newIn;
newPrin = amount - reduct;
amount = newPrin;
calcField.append(" " + i);
calcField.append(" " + currency.format(payment));
calcField.append(" " + currency.format(newIn));
calcField.append(" " + currency.format(reduct));
calcField.append(" " + currency.format(newPrin) + "\n");
calcField.setCaretPosition(0);
// Program Reset, User Can Calculate Another Amount or Choose A Different Style
void reset () {
loanField.setText(null);
paymentField.setText(null);
calcField.setText(null);
termField.setText(null);
rateField.setText(null);
// Exit Command
void end() {
System.exit(0);
// main method
public static void main(String args[]) {
MortgageCalc_wk5 calc = new MortgageCalc_wk5();
calc.pack();
calc.setVisible(true);
// end of programWill you please describe the problem.
Your program works fine for one who doesn't know your precise requirement.
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.NumberFormat;
import java.awt.Color;
public class MortgageCalc_wk5 extends JFrame implements ActionListener {
private static final long serialVersionUID = 6;
private static final Rectangle rectangle = null;
//Set up panels for Frame
JPanel topPanel = new JPanel();
JPanel bottomPanel = new JPanel();
JPanel radioPanel = new JPanel();
JPanel grfxPanel = new JPanel();
//Set up Layout
FlowLayout flowLayout = new FlowLayout();
BorderLayout borderLayout = new BorderLayout();
//Radio Choice Style Buttons
JRadioButton Choice1 = new JRadioButton ("User Input", true);
JRadioButton Choice2 = new JRadioButton ("User Selection", false);
//Set up JLabels, JButtons, and JTextFields
JLabel amountLabel = new JLabel("Loan Amount");
JTextField loanField = new JTextField(7);
JLabel termLabel = new JLabel("Term(Yrs)");
JTextField termField = new JTextField(4);
JLabel rateLabel = new JLabel("Rate");
JTextField rateField = new JTextField(4);
JComboBox options = new JComboBox();
JLabel optionsLabel = new JLabel();
JButton calcButton = new JButton("Calculate");
JButton resetButton = new JButton("Reset");
JButton exitButton = new JButton("Exit");
JButton grfxButton = new JButton("Display Graphics");
JLabel paymentLabel = new JLabel("Monthly Payment =");
JTextField paymentField = new JTextField(6);
JLabel outputLabel = new JLabel("Loan Amoritization Chart");
JTextArea calcField = new JTextArea(10, 25);
JScrollPane scroll
= new JScrollPane(calcField, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,
JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
ButtonGroup radioSelect = new ButtonGroup();
JLabel grfxLabel =new JLabel ("Graphic Chart");
JTextField grfxField = new JTextField ("Graphics");
//Default constructor
public MortgageCalc_wk5() {
super("Tony's Calculator - Week 5");
setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
setVisible(true);
//add ActionListeners
loanField.addActionListener(this);
termField.addActionListener(this);
rateField.addActionListener(this);
options.addActionListener(this);
calcButton.addActionListener(this);
grfxButton.addActionListener(this);
resetButton.addActionListener(this);
exitButton.addActionListener(this);
Choice1.addActionListener(this);
Choice2.addActionListener(this);
//Top Panel Layout
topPanel.setLayout(flowLayout);
topPanel.add(amountLabel);
topPanel.add(loanField);
radioSelect.add(Choice1);
radioSelect.add(Choice2);
topPanel.add(Choice1);
topPanel.add(Choice2);
//Loan Term Options For JComboBox
options.addItem("7 years @ 5.35%");
options.addItem("15 years @ 5.5%");
options.addItem("30 years @ 5.75%");
options.setEnabled(false);
topPanel.add(options);
topPanel.add(termLabel);
topPanel.add(termField);
topPanel.add(rateLabel);
topPanel.add(rateField);
topPanel.add(paymentLabel);
topPanel.add(paymentField);
paymentField.setEditable(false);
//Was Bottom Panel Now East Panel, Calculate Reset,Exit, and Display Buttons
bottomPanel.add(calcButton);
bottomPanel.add(resetButton);
bottomPanel.add(exitButton);
bottomPanel.add(grfxButton);
calcButton.setBackground(Color.blue);
resetButton.setBackground(Color.white);
exitButton.setBackground(Color.red);
calcField.setBackground(Color.orange);
grfxPanel.setBackground(Color.green);
grfxPanel.add(grfxField);
//add Container
Container pane = getContentPane();
pane.setLayout(borderLayout);
pane.add(topPanel, BorderLayout.NORTH);
pane.add(calcField, BorderLayout.WEST);
pane.add(grfxPanel, BorderLayout.SOUTH);
pane.add(bottomPanel, BorderLayout.EAST);
calcField.setLineWrap(true);
calcField.setWrapStyleWord(true);
calcField.setEditable(false);
pane.add(scroll);
scroll.setViewportView(calcField);
pack();
grfxPanel.setBounds(new Rectangle(0, 0, 400, 400));
//actionEvent Listeners
public void actionPerformed(ActionEvent event) {
Object source = event.getSource();
if (source == calcButton) {
startCalculations();
else if (source == resetButton) {
reset();
else if (source == grfxButton) {
chartPanel();
else if (source == exitButton) {
end();
else if (source == Choice1) {
options.setEnabled(false);
termField.setEnabled(true);
rateField.setEnabled(true);
else if (source == Choice2) {
options.setEnabled(true);
termField.setEnabled(false);
rateField.setEnabled(false);
public void chartPanel() {
JFrame grfxFrame = new JFrame();
grfxFrame.setSize(400, 300);
double[] values = new double[3];
String[] names = new String[3];
values[0] = 1;
names[0] = "Item 1";
values[1] = 2;
names[1] = "Item 2";
values[2] = 4;
names[2] = "Item 3";
grfxFrame.getContentPane().add(new ChartPanel(values, names, "title"));
grfxFrame.setVisible(true);
// public class ChartPanel extends JPanel {
class ChartPanel extends JPanel {
private static final long serialVersionUID = 6;
public double[] values;
public String[] names;
public String title;
public ChartPanel(double[] v, String[] n, String t) {
names = n;
values = v;
title = t;
public void paintComponent(Graphics g) {
super.paintComponent(g);
if (values == null || values.length == 0){
return;
double minValue = 0;
double maxValue = 0;
for (int i = 0; i < values.length; i++) {
if (minValue > values){
minValue = values[i];
if (maxValue < values[i]){
maxValue = values[i];
Dimension d = getSize();
int clientWidth = d.width;
int clientHeight = d.height;
int barWidth = clientWidth / values.length;
Font titleFont = new Font("SansSerif", Font.BOLD, 20);
FontMetrics titleFontMetrics = g.getFontMetrics(titleFont);
Font labelFont = new Font("SansSerif", Font.PLAIN, 10);
FontMetrics labelFontMetrics = g.getFontMetrics(labelFont);
int titleWidth = titleFontMetrics.stringWidth(title);
int y = titleFontMetrics.getAscent();
int x = (clientWidth - titleWidth) / 2;
g.setFont(titleFont);
g.drawString(title, x, y);
int top = titleFontMetrics.getHeight();
int bottom = labelFontMetrics.getHeight();
if (maxValue == minValue){
return;
double scale = (clientHeight - top - bottom) / (maxValue - minValue);
y = clientHeight - labelFontMetrics.getDescent();
g.setFont(labelFont);
for (int i = 0; i < values.length; i++) {
int valueX = i * barWidth + 1;
int valueY = top;
int height = (int) (values[i] * scale);
if (values[i] >= 0){
valueY += (int) ((maxValue - values[i]) * scale);
else {
valueY += (int) (maxValue * scale);
height = -height;
g.setColor(Color.red);
g.fillRect(valueX, valueY, barWidth - 2, height);
g.setColor(Color.black);
g.drawRect(valueX, valueY, barWidth - 2, height);
int labelWidth = labelFontMetrics.stringWidth(names[i]);
x = i * barWidth + (barWidth - labelWidth) / 2;
g.drawString(names[i], x, y);
//Calculation Section
void startCalculations() {
NumberFormat currency = NumberFormat.getCurrencyInstance();
//Variables
double amount = 0;
double term = 0;
double interest = 0;
double moIn = 0;
double moTerm = 0;
double payment = 0;
double newPrin = amount;
boolean Exception = false;
//Input Validation
try {
amount = Double.parseDouble(loanField.getText());
} catch (NumberFormatException e) {
JOptionPane.showMessageDialog
(null, "Commas, Letters, and Puncuation NOT Allowed",
"Message Dialog", JOptionPane.ERROR_MESSAGE);
loanField.setText(null);
calcField.setText(null);
//User's Loan Choice
if (Choice2.isSelected()){
if(options.getSelectedIndex() == 0){
term=7;
interest=5.35;
else if(options.getSelectedIndex() ==1){
term=15;
interest=5.5;
else{
term=30;
interest=5.75;
else{
//More Validation
try{
term = Double.parseDouble(termField.getText());
catch (NumberFormatException e){
JOptionPane.showMessageDialog
(this,"Enter amounts greater than zero","Please enter new amount",
JOptionPane.ERROR_MESSAGE);
Exception=true;
termField.setText(null);
try{
interest= Double.parseDouble(rateField.getText());
catch (NumberFormatException e){
JOptionPane.showMessageDialog
(this, "Enter an Amount Greater Than Zero, % Not Allowed",
"Please enter Another Amount", JOptionPane.ERROR_MESSAGE);
Exception=true;
rateField.setText(null);
if ((amount <= 0 || term <= 0 || interest <= 0) && (Exception == false)) {
JOptionPane.showMessageDialog
(null, "Please Enter a Number Greater Than ZERO.",
"Message Dialog", JOptionPane.ERROR_MESSAGE);
if(amount <= 0)
loanField.setText(null);
paymentField.setText(null);
calcField.setText(null);
termField.setText(null);
rateField.setText(null);
//Amortization Results Chart
if (amount >7) {
amount = Double.parseDouble(loanField.getText());
moIn = (interest / 12) / 100;
moTerm = term * 12;
payment
= amount * (moIn / (1 - java.lang.Math.pow((1 + moIn), (-moTerm))));
paymentField.setText("" + currency.format(payment));
calcField.append("Period");
calcField.append(" ");
calcField.append("Payment Amount");
calcField.append(" ");
calcField.append("Interest Paid");
calcField.append(" ");
calcField.append("Principle Paid");
calcField.append(" ");
calcField.append("Loan Balance");
calcField.append(" \n");
for (int i = 1; i <= moTerm; i++) {
double newIn = moIn * amount;
double reduct = payment - newIn;
newPrin = amount - reduct;
amount = newPrin;
calcField.append(" " + i);
calcField.append(" " + currency.format(payment));
calcField.append(" " + currency.format(newIn));
calcField.append(" " + currency.format(reduct));
calcField.append
(" " + currency.format(newPrin) + "\n");
calcField.setCaretPosition(0);
// Program Reset, User Can Calculate Another Amount or Choose A Different Style
void reset () {
loanField.setText(null);
paymentField.setText(null);
calcField.setText(null);
termField.setText(null);
rateField.setText(null);
// Exit Command
void end() {
System.exit(0);
// main method
public static void main(String args[]) {
java.util.Locale.setDefault(java.util.Locale.US);
MortgageCalc_wk5 calc = new MortgageCalc_wk5();
calc.pack();
calc.setVisible(true);
// end of program
Message was edited by:
hiwa -
I am new to Java and am having problems and I am in need of some help. I have written the code for my Mortgage Calculator but do not know how to get my chart to work. I found an example of the chart code in my text book but I am not sure if I wrote it wrong. When I run the MortCalc code it compiles but the Pie Chart code won't. I tried to run the chart code by itself but it prints out another calculator. My question is 1.) Is my chart code written wrong? and 2.) How do i enter it into my MortCalc code so that I get my chart?
**Below I have included the assignment(so you know what I am doing exactly) and below that the pie chart code just in case you have questions. Thanks for any advice you can give.
**If you need the rest of the code I can post it too. It was too long to post with the pie chart code.
Assignment:
Write the program in Java(w/ a GUI) and have it calculate and display the mortgage payment amount from user input of the amount of the mortgage adn the user's selection from a menu of availible mortgage loans:
--7 yrs @ 5.35%
--15 yrs @ 5.5%
--30 yrs @ 5.75%
Use an array for the mortgage data for the different loans. Read the interst rates to fill the array from a sequential file. Display the mortgage payment amount followed by the loan balance and interest paid for each payment over the term of the loan. Add graphics in the form of a chart.Allow the user to loop back and enter a new amount and make a new selection of quit. Please insert comments in the program to document the program.
CODE:
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Rectangle;
//Class to hold a value for a slice
public class PieValue {
double value;
Color color;
public PieValue(double value, Color color) {
this.value = value;
this.color = color;
// slices is an array of values that represent the size of each slice.
public void drawPie(Graphics2D g, Rectangle area, PieValue[] slices) {
// Get total value of all slices
double total = 0.0D;
for (int i=0; i<slices.length; i++) {
total += slices.value;
// Draw each pie slice
double curValue = 0.0D;
int startAngle = 0;
for (int i=0; i<slices.length; i++) {
// Compute the start and stop angles
startAngle = (int)(curValue * 360 / total);
int arcAngle = (int)(slices[i].value * 360 / total);
// Ensure that rounding errors do not leave a gap between the first and last slice
if (i == slices.length-1) {
arcAngle = 360 - startAngle;
// Set the color and draw a filled arc
g.setColor(slices[i].color);
g.fillArc(area.x, area.y, area.width, area.height, startAngle, arcAngle);
curValue += slices[i].value;// Draw each pie slice
double curValue = 0.0D;
int startAngle = 0;
for (int i=0; i<slices.length; i+) {
// Compute the start and stop angles
startAngle = (int)(curValue 360 / total);
int arcAngle = (int)(slices.value * 360 / total);Look here and i think you will find some syntax errors.
Count the brackets. -
Create Multiple Pie Charts with Drill Down capability(foreach in mainreport
Hello All,
i need to create a report with 4 pie charts, which should have drilldown capability. i tried to do that, and i can do only for two charts. i need for the rest 2 also.
Please help.
ThanksSee this thread:
BO Design studio Chart Component issue ...!! | SCN
If Chart is bound to DS_1 and On Select event of chart is as below:
DS_2.setFilter(dimension, CHART_1.getSelectedMember(dimension));"
This works when you click a value on one chart it will select another.
I haven't tried it with hierarchies. -
Hi Experts!!
I've a little problem with a Pie Chart, I want to present a Pie Chart with 3 values which are defined on the Data Series, when I deploy I get the message: "Expected exactly 1 data series in XXXXX chart. Extra data series ignored". I don't understand why, because if I try to do a Column Chart with the same information, it works Ok!
Can anybody help me please?.
Emilio.Multiple data series with Pie Chart is not possible. you must have one series if u r using pie chart
-
Pie chart problem with label!
Hello,
I found this example of pie chart, I tried to use several pie charts but the label square move in some chart. It shows the square moved down when it uses the vi.
I attached the example with 4 pie charts and sometimes it show the 4 sqaures and sometimes down one. Any way to fit it?.
I would like to see some example with 3d pie chart. Do you know any example?.
Thanks in advance!.
Fred
Solved!
Go to Solution.
Attachments:
Pie Charts.vi 25 KB
PieCreateChart.vi 13 KBSorry guys!. i got it.
Changing the first time call to comparison of For Loop = 0, so always start with the value fixed to draw the square.
Thanks. -
Error with cursor position on Chart
Hello
I'm getting an error with a simple Chart. I'm trying to show the chart position (using labels and a crosshair) and I'm getting an exception ONLY (it seems) when the program starts up with the cursor above the chart. If I move the cursor off to
the side or something I don't get the error.
Error: PositionToValue method cannot be called prior to calculating position of all chart area elements.
The error occurs in the MouseMove event handler.
private void crtPlotData_MouseMove(object sender, MouseEventArgs e)
Point mousePoint = new Point(e.X, e.Y);
crtPlotData.ChartAreas[0].CursorX.Interval = 0;
crtPlotData.ChartAreas[0].CursorY.Interval = 0;
crtPlotData.ChartAreas[0].CursorX.SetCursorPixelPosition(mousePoint, true);
crtPlotData.ChartAreas[0].CursorY.SetCursorPixelPosition(mousePoint, true);
lblXposition.Text = "Pixel X Position: " + crtPlotData.ChartAreas[0].AxisX.PixelPositionToValue(e.X).ToString();
lblYposition.Text = "Pixel Y Position: " + crtPlotData.ChartAreas[0].AxisY.PixelPositionToValue(e.Y).ToString();
HitTestResult result = crtPlotData.HitTest(e.X, e.Y);
if (result.PointIndex > -1 && result.ChartArea != null)
lblXvalue.Text = "X-Value: " + result.Series.Points[result.PointIndex].XValue.ToString();
lblYvalue.Text = "Y-Value: " + result.Series.Points[result.PointIndex].YValues[0].ToString();
}...etc.
The exception occurs at the "lblXposition.Text" statement.
For whatever reason if the cursor is above the chart at start up I get the error but I don't know how to prevent it long enough for "calculating position of all chart area elements".
Any help would be appreciated.
ThanksYet the event DOES work as long as the cursor is not within the chart boundaries at start up. ???
It happens to, but I would rely on the documentation. However, you can set a flag to true in the Paint event of the chart, and in the mouseMove handler, exit if the flag has not been set yet.
Armin -
How to show pie chart in Oracle Map?
I created predefined theme with pie chart style using MapBuilder. When I requested map using XML map request, the pie chart are shown with background and base map behind. Unfortunately, I tried to use Oracle Maps JavaScript Client API and it showed only background with base map behind.
I’m using this code
themebasedfoi = new MVThemeBasedFOI('themebasedfoi1','geoadmin.pie_province ');
themebasedfoi.setBringToTopOnMouseOver(true);
mapview.addThemeBasedFOI(themebasedfoi);
geoadmin is my username and pie_province is my pie chart predefined theme
Sorry for my English
Many thanks
581554Hi
You can create chart by chart wizard in layout model in report 6i.
1. Create Query in data model
2. Go Layout model and right click
3. Select Chart Wizard then select Chart type
4. Select Axis (X axis column and Y axis column)
5. Choose your chart placement
PS
Maybe you are looking for
-
I'm trying to edit a talking head video and want to find an straightforward way to mark a spot at the end of a statement made by the subject and then cut the clip at that point. Can you help? Thanks.
-
Interface Determination Conditions
Dear All, I have 2 different mappings. My source XML contains a "NAME" field. If this name field is having some value then mapping 1 should get executed. But if "NAME" field does not exists in source XML then mapping 2 should get executed. Note that
-
Images are not displaying(PHP MySQL)
Hi, I've created a database table (MySQL) to store file path of images stored in a folder but the only problem is that the images are not displaying on the web page. Here's the procedure that I've used: -Placed the cusor at the insertion point (div).
-
I need help please with my connection
ok i just bought a Sony KDL-32L5000 HDTV and I also own a PS3. Now my problem is how can I connect it to my Audio system which doesnt have HDMI port and Optical port? OR recomend a cheap one. It's for my bedroom. Thanks Solved! Go to Solution.
-
A got a message erreur (-43) when l try to update ios5 whit my iphone 4?