Charting in windows phone app - windows-phone-8

I want to create a chart using amchart in windows phone application.This is my code when i run i have this message"Can not implicitly convert type 'string' to 'System.Windows.Media.Brush"how can i solve this
InitializeComponent();
XDocument data = XDocument.Load("Data.xml");
var results = from query in data.Descendants("year")
select new ResultModel((string)query.Element("month"),
(int)query.Element("actual"));
var chart = new SerialChart
{
CategoryValueMemberPath = "month",
AxisForeground="White",
PlotAreaBackground="Black",
GridStroke="DarkGray"
};
chart.SetBinding(SerialChart.DataSourceProperty, new Binding("results"));
var lineGraph = new LineGraph
{
Title = "Sales",
ValueMemberPath = "actual",
};
chart.Graphs.Add(lineGraph);
sta.Children.Add(chart);
}

The properties in SerialChart, such as AxisForeground, PlotAreaBackground, GridStroke, their type is Brush. So you can set it like:
AxisForeground = new SolidColorBrush(Colors.White);
PlotAreaBackground = new SolidColorBrush(Colors.Black);
GridStroke = new SolidColorBrush(Colors.DarkGray);

Related

How to combine a bar chart and a line chart in JFreeChart

I want to combine a line chart and a bar chart in a JFreeChart chart. What I've got so far is two lines. I have to change the renderer of one of the lines to a BarRenderer somehow. This is what I've got so far:
barDataset = new TimeSeriesCollection();
lineDataset = new TimeSeriesCollection();
totalDistanceSeries = new TimeSeries("Total Distance");
movingAverageSeries = new TimeSeries("Moving Average");
while (rs.next()) {
myDate = rs.getDate("Date");
d = new Day(myDate);
totalDistance = rs.getDouble("TotaleAfstand");
movingAverage = rs.getDouble("MovingAverage");
totalDistanceSeries.add(d,totalDistance);
movingAverageSeries.add(d,movingAverage);
}
barDataset.addSeries(totalDistanceSeries);
lineDataset.addSeries(movingAverageSeries);
String chartTitle = "Monthly Chart with Moving Average";
String xAxisLabel = "Date";
String yAxisLabel = "TotalDistance";
JFreeChart chart = ChartFactory.createTimeSeriesChart(chartTitle,
xAxisLabel, yAxisLabel, lineDataset);
XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) chart.getXYPlot().getRenderer();
renderer.setBaseShapesVisible(true);
XYPlot plot = (XYPlot) chart.getXYPlot();
plot.setDataset(1, barDataset);
chartPanel = new ChartPanel(chart);
chartPanel.setLocation(10,60);
chartPanel.setSize(1850, 900);
add(chartPanel);
Does someone know how to do this?
I needed a XYBarRenderer instead of just a BarRenderer. This is the code I added below
plot.setDataset(1, barDataset); :
XYBarRenderer renderer2=new XYBarRenderer(0.20);
plot.setRenderer(1, renderer2);

Table is distorted while comparing HTML data using daisydiff.jar

Left side table is distorted while comparing two HTML table data using daisydiff.jar.
I need your support to fix this issue. Thanks in advance
Using below code
StringWriter finalResult = new StringWriter();
SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance(); TransformerHandler result = tf.newTransformerHandler();
result.getTransformer().setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
result.getTransformer().setOutputProperty(OutputKeys.INDENT, "no");
result.getTransformer().setOutputProperty(OutputKeys.METHOD, "html");
result.getTransformer().setOutputProperty(OutputKeys.ENCODING, "UTF-8");
result.setResult(new StreamResult(finalResult));
ContentHandler postProcess = result;
Locale locale = Locale.getDefault();
String prefix = "diff";
NekoHtmlParser cleaner = new NekoHtmlParser();
InputSource oldSource = new InputSource (new String reader(html1));
InputSource newSource = new InputSource (new String reader(html2));
DomTreeBuilder oldHandler = new DomTreeBuilder ();
cleaner.parse(oldSource, oldHandler);
TextNodeComparator leftComparator = new TextNodeComparator (oldHandler, locale);
DomTreeBuilder newHandler = new DomTreeBuilder ();
cleaner.parse(newSource, newHandler);
TextNodeComparator rightComparator = new TextNodeComparator (newHandler, locale);
HtmlSaxDiffOutput output = new HtmlSaxDiffOutput (postProcess, prefix);
HTMLDiffer differ = new HTMLDiffer(output);
differ.diff(leftComparator, rightComparator);

How to Change the Y axis of an Primefaces 7.0 ChartJS Linechart with Java?

With the new version of Primefaces (7.0) the jqplot-charts got replaced by ChartJS Charts. Now I want the Y-Axis of my chart to be longer. With the old charts this was easily possible in Java but now I don't know how to do it. If it isn't possible in Java is there an alternative way to change the Y-Axis of an existing chart?
It all right in the showcase in the 2nd example for Cartesian Line Model.
https://www.primefaces.org/showcase/ui/chartjs/line.xhtml
public void createCartesianLinerModel() {
cartesianLinerModel = new LineChartModel();
ChartData data = new ChartData();
LineChartDataSet dataSet = new LineChartDataSet();
List<Number> values = new ArrayList<>();
values.add(20);
values.add(50);
values.add(100);
values.add(75);
values.add(25);
values.add(0);
dataSet.setData(values);
dataSet.setLabel("Left Dataset");
dataSet.setYaxisID("left-y-axis");
LineChartDataSet dataSet2 = new LineChartDataSet();
List<Number> values2 = new ArrayList<>();
values2.add(0.1);
values2.add(0.5);
values2.add(1.0);
values2.add(2.0);
values2.add(1.5);
values2.add(0);
dataSet2.setData(values2);
dataSet2.setLabel("Right Dataset");
dataSet2.setYaxisID("right-y-axis");
data.addChartDataSet(dataSet);
data.addChartDataSet(dataSet2);
List<String> labels = new ArrayList<>();
labels.add("Jan");
labels.add("Feb");
labels.add("Mar");
labels.add("Apr");
labels.add("May");
labels.add("Jun");
data.setLabels(labels);
cartesianLinerModel.setData(data);
//Options
LineChartOptions options = new LineChartOptions();
CartesianScales cScales = new CartesianScales();
CartesianLinearAxes linearAxes = new CartesianLinearAxes();
linearAxes.setId("left-y-axis");
linearAxes.setPosition("left");
CartesianLinearAxes linearAxes2 = new CartesianLinearAxes();
linearAxes2.setId("right-y-axis");
linearAxes2.setPosition("right");
cScales.addYAxesData(linearAxes);
cScales.addYAxesData(linearAxes2);
options.setScales(cScales);
Title title = new Title();
title.setDisplay(true);
title.setText("Cartesian Linear Chart");
options.setTitle(title);
cartesianLinerModel.setOptions(options);
}

NativeScript JobScheduler JobService.class is undefined

I have weird error while i'm trying to create component in the JobScheduler
At the first line when setting a component value i get this error:
ERROR TypeError: Cannot read property 'MyJobService' of undefined
Both of the files are in the same folder, and its all worked yesterday.
I cleaned up the platforms folder just to be sure, because i dragged some pics to the drawble folders in the app_Resources and i had to build the project again and maybe something has changed. but it did not helped.
What can cause this problem ? am i missing something ?
JobScheduler.js :
function scheduleJob(context) {
var component = new android.content.ComponentName(context, com.tns.notifications.MyJobService.class);
const builder = new android.app.job.JobInfo.Builder(1, component);
builder.setPeriodic(15 * 60 * 1000);
builder.setOverrideDeadline(0);
const jobScheduler = context.getSystemService(android.content.Context.JOB_SCHEDULER_SERVICE);
console.log("Job Scheduled: " + jobScheduler.schedule(builder.build()));
}
module.exports.scheduleJob = scheduleJob;
MyJobService.js :
android.app.job.JobService.extend("com.tns.notifications.MyJobService", {
onStartJob: function(params) {
console.log("Job execution ...");
var utils = require("utils/utils");
var context = utils.ad.getApplicationContext();
var builder = new android.app.Notification.Builder(context);
console.log("setting notification head and body")
builder.setContentTitle("notification triggered ")
.setAutoCancel(true)
.setColor(android.R.color.holo_purple)//getResources().getColor(R.color.colorAccent))
.setContentText("body)
.setVibrate([100, 200, 100])
.setSmallIcon(android.R.drawable.btn_star_big_on);
var mainIntent = new android.content.Intent(context, com.tns.NativeScriptActivity.class);
var mNotificationManager = context.getSystemService(android.content.Context.NOTIFICATION_SERVICE);
const channelId = "my_channel_01";
const name = "Channel name";
const description = "Channel description";
const importance = android.app.NotificationManager.IMPORTANCE_LOW;
if (android.os.Build.VERSION.SDK_INT >= 26) {
console.log("api level is good",android.os.Build.VERSION.SDK_INT)
}
const mChannel = new android.app.NotificationChannel(channelId, name,importance);
mChannel.setDescription(description);
mChannel.enableLights(true);
mChannel.enableVibration(true);
mNotificationManager.createNotificationChannel(mChannel);
builder.setChannelId(channelId);
mNotificationManager.notify(1, builder.build());
return false;
},
onStopJob: function() {
console.log("Stopping job ...");
}
});

Icon Field on List

I load label and icon from mysql database.
and i'd like to create a list with label and icon field.
So I try to do something like that but it doesn't work indeed each line contain label but icon is empty.
var xmllisteFamille:XMLList = XML(event.result).famille;
var xmlListCollFami = new XMLListCollection(xmllisteFamille);
for each (var item:Object in xmlListCollFami){
var vbox:VBox = new VBox;
vbox.label = item.sdfNom;
trace(vbox.label);
vbox.percentHeight=100;
vbox.percentWidth=100;
var xmlItem2:XMLList = item.commDent;
if(xmlItem2.length()>0){
/*
var listAcc:List = new List();
listAcc.percentHeight = 100;
listAcc.percentWidth =100;
listAcc.labelField = "name";
listAcc.dataProvider = xmlItem2;
vbox.addChild(listAcc);
accOnglet1.addChild(vbox); */
var urlImageRoot : urlManager = new urlManager();
var urlRootDental:String = urlImageRoot.urlDental();
trace(urlRootDental);
var list:Array = new Array();
var object:Object;
var xmlListdetail:XMLListCollection = new XMLListCollection(xmlItem2);
for each (var item2:Object in xmlListdetail)
{
object = new Object();
// -- --
object.label = item2.name;
var rootIcon:String= "http://127.0.0.1:10088/Sys/OEMySQL/Dental/"+item2.photo;
trace("rootIcon " + rootIcon);
object.icon = rootIcon;
trace("object.icon " + object.icon);
list.push(object);
}
/* var aNode:XML;
for each (aNode in xmlItem2)
{
object = new Object();
// -- --
object.label = aNode.name;
object.icon = new urlManager().urlDental()+aNode.photo;
list.push(object);
} */
var arrList:ArrayList;
arrList = new ArrayList(list);
var listAcc:List = new List();
listAcc.percentHeight = 100;
listAcc.percentWidth =100;
listAcc.labelField = "label";
listAcc.iconField="icon";
//listAcc.dataProvider = xmlItem2;
listAcc.dataProvider = arrList;
vbox.addChild(listAcc);
accOnglet1.addChild(vbox);
}
}
}
}
I hope that you can help me.
Thanks
it may be crossdomain issue
you need to know if flash player requires crossdomain.xml in this case
use charles proxy to check what exactly you are sending to server (request) and getting back from server (response)
charles proxy website
I found the solution.
I had to create an itemrenderer and add it in as3 to my list.
thanks