sencha touch and charts - graph

Has anyone been able to incorporate Charts and graphs into Sencha Touch?
If so, an example would be appreciated.
Thanks

Sencha Touch Charts has just been released

I was under the impression that Raphael (http://raphaeljs.com/) would eventually be incorporated into Sencha Touch for its' graphing component (http://g.raphaeljs.com/). Until then, you can pretty easily just include the extra Raphael .js files and make graphs that way. Something like:
<script src="sencha-touch-1.0/sencha-touch-debug.js" type="text/javascript" charset="utf-8"></script>
<!-- Raphael JS -->
<script src="raphael/raphael-min.js" type="text/javascript" charset="utf-8"></script>
<script src="raphael/g.raphael-min.js" type="text/javascript" charset="utf-8"></script>
<script src="raphael/g.pie-min.js" type="text/javascript" charset="utf-8"></script>
<script src="raphael/g.line-min.js" type="text/javascript" charset="utf-8"></script>
<script src="raphael/g.bar-min.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" charset="utf-8">
Ext.setup({
onReady: function()
{
// Set up main panel!
var tabPanel = new Ext.Panel
({
fullscreen: true,
html: '<div id="graph"></div>'
});
// Try to draw a graph!
var r = Raphael('graph');
r.g.txtattr.font = '12px Helvetica, Arial, sans-serif';
r.g.text(150, 250, "Demo chart with title");
r.g.linechart(10, 10, 300, 220, [[1, 2, 3, 4, 5, 6, 7],[3.5, 4.5, 5.5, 6.5, 7, 8]], [[12, 32, 23, 15, 17, 27, 22], [10, 20, 30, 25, 15, 28]], {nostroke: false, axis: "0 0 1 1", symbol: "o", smooth: true});
}
});
</script>

Take a look at http://code.google.com/p/oppo-touching/. Someone already moved charting to Snecha Touch. Also there is news that next version of Sencha Touch will include charting.

they now have some examples. they should help http://dev.sencha.com/deploy/touch-charts-beta/examples/

Here's the code for a sample chart in Sencha Touch
var SampleLineChart = new Ext.chart.Chart({
fullscreen : true,
iconCls: 'line',
cls: 'chartpanel',
theme: 'Energy',
interactions: [ 'reset',
{
type: 'panzoom',
axes: {
right: {}
}
},
{
type: 'iteminfo',
gesture: 'tap',
listeners: {
show: function(interaction, item, panel) {
// Ext.dispatch({
// controller : 'Users',
// action : 'popupInfoAbtChart',
// data : {item:item, panel:panel}
// });
}
}
}],
animate: false,
store: EnergyApp.stores.ChartStore, //choose for consumption
axes: [{
type: 'Numeric',
position: 'right',
minimum: 0,
majorTickSteps : 10,
minorTickSteps : 5,
fields: ['generatedpv', 'buildcons','excessPV'],
title: 'Y-axis title'
},
{
type: 'Category',
position: 'bottom',
fields: ['day'],
title: 'X-axis title',
label: {
rotate: {
degrees: 45
}
}
}],
legend: {
position: Ext.is.Phone ? 'left' : 'top'
},
series: [{
type: 'line',
highlight: false,
showMarkers: true,
fill: false,
smooth: true,
axis: 'right',
xField: 'day',
yField: 'generatedpv',
title: 'Field 1
},
{
type: 'line',
highlight: false,
showMarkers: true,
fill: false,
smooth: true,
axis: 'right',
xField: 'day',
yField: 'buildcons',
title: 'Field 2
}],
listeners: {
afterrender: function(me) {
me.on('beforerefresh', function() {
if (me.ownerCt.getActiveItem().id !== me.id) {
return false;
}
}, me);
}
}
});
For more code examples take a look at the EnergyApp Example in the Sencha-Touch-Charts example folder. Its been depicted quite well

Here is a link to a Sencha forum with some examples of how to incorporate a chart into an existing Sencha Touch 2.0 application:
http://www.sencha.com/forum/showthread.php?190053-How-to-Integrate-Touch-2-Charts-into-an-existing-Sencha-Touch-2.0-Final-application.

The package with the chart api for Sencha exists ( http://dev.sencha.com/deploy/touch-charts-beta/examples/) but appears very hard to integrate in the sencha touch solution (files dependency, function not defined in some version of the sencha touch package).
The solution I found is to install the trial version of Sencha Architect which already include the graph api, create a mobile project (touch project) and package it. Then I have a whole package with the right dependencies and I can reuse it without depending on Sencha Architect.

Related

Highchart's line color not changing in wordpress page

I have included a stockChart in a wordpress page. Changing the color of the markers of a series works. However, changing the line color does not have any effect. I suppose that this issue is rooted in the interplay between highcharts and wordpress, as the below code displays as expected when opened in a browser. Has anyone run into this problem yet?
Minimal example that shows this behaviour:
<html>
<script src="https://code.highcharts.com/stock/highstock.js"></script>
<script src="https://code.highcharts.com/stock/modules/data.js"></script>
<script src="https://code.highcharts.com/stock/modules/exporting.js"></script>
<script src="https://code.highcharts.com/stock/modules/export-data.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<body>
<div id="container"></div>
</body>
<script>
chart = Highcharts.stockChart(container, {
chart: {
type: 'spline',
},
title: {
text: 'testplot',
},
series: [
{
name: 'testdata',
data: [[1000000, 1],[1010000, 2],[1020000, 3],[1030000, 4]],
color: '#FF0000',
lineColor: '#000000',
},
]
});
</script>
</html>
Please test another config - where the color property defines the line color and marker color will be set in this way:
series: [{
name: 'testdata',
data: [
[1000000, 1],
[1010000, 2],
[1020000, 3],
[1030000, 4]
],
color: '#000000',
marker: {
fillColor: '#FF0000'
}
}]
Demo: https://jsfiddle.net/BlackLabel/74v9xken/
API: https://api.highcharts.com/highcharts/series.line.marker.fillColor
EDIT:
According to the comments: the style was overwritten by SCSS default config - .highcharts-graph { stroke:#FF7096; }.

Is it possible to add a javascript chart in a webview in Xamari.Forms

Hy guys,
I would like to know if is possible to create a line chart like this Linear chart with Chart.js with javascript in a WebView in a Xamarin.Forms page, the values of the lines must be added in code.
I followed this tutorial, to implement a Hybrid WebView
The tutorial is working fine more or less, but I changed the index.htm file and I added the utils.js to have the same chart as in the first link.
The content of index and utils.js is the same as you cand find in the first link with F12.
But I don't know what I need more, my intuition says that the utils.js file is not working fine. This is the result when I run the app, I hope someone has a solution :)
Now I can see the chart fine in the Xamarin.Forms page, to do it I just copied all the files and changed the route in multi-axi.html.
<!doctype html>
<html>
<head>
<title>Line Chart Multiple Axes</title>
<script src="../../../../dist/2.8.0/Chart.min.js"></script>
<script src="../../utils.js"></script>
<style>
canvas {
-moz-user-select: none;
-webkit-user-select: none;
-ms-user-select: none;
}
</style>
</head>
<body>
<div style="width:75%;">
<canvas id="canvas"></canvas>
</div>
<button id="randomizeData">Randomize Data</button>
<script>
var lineChartData = {
labels: ['January', 'February', 'March', 'April', 'May', 'June', 'July'],
datasets: [{
label: 'My First dataset',
borderColor: window.chartColors.red,
backgroundColor: window.chartColors.red,
fill: false,
data: [
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor()
],
yAxisID: 'y-axis-1',
}, {
label: 'My Second dataset',
borderColor: window.chartColors.blue,
backgroundColor: window.chartColors.blue,
fill: false,
data: [
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor(),
randomScalingFactor()
],
yAxisID: 'y-axis-2'
}]
};
window.onload = function() {
var ctx = document.getElementById('canvas').getContext('2d');
window.myLine = Chart.Line(ctx, {
data: lineChartData,
options: {
responsive: true,
hoverMode: 'index',
stacked: false,
title: {
display: true,
text: 'Chart.js Line Chart - Multi Axis'
},
scales: {
yAxes: [{
type: 'linear', // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance
display: true,
position: 'left',
id: 'y-axis-1',
}, {
type: 'linear', // only linear but allow scale type registration. This allows extensions to exist solely for log scale for instance
display: true,
position: 'right',
id: 'y-axis-2',
// grid line settings
gridLines: {
drawOnChartArea: false, // only want the grid lines for one axis to show up
},
}],
}
}
});
};
document.getElementById('randomizeData').addEventListener('click', function() {
lineChartData.datasets.forEach(function(dataset) {
dataset.data = dataset.data.map(function() {
return randomScalingFactor();
});
});
window.myLine.update();
});
</script>
</body>
</html>
The result:
I have one last problem, the lineChartData variable must be created in the .cs file with custom data, how I do that?
I found a ton of people having this issues online of using js charts in Xamarin.Forms so I took some inspiration from HybridWeb view and some Gists online and created a Nuget Package to solve this.
https://github.com/ChristopherMWood/XamarinChartJSPlugin
It will allow you to configure charts in C# and it converts them to chart.js charts in a WebView. As of writing this it's fairly new but it helps solve the main line use cases using CHart.js.

can't display as same as demo code with fullcalendar

I tried to apply fullcalendar to my page.
When I pasted the example code to my page, there's no header buttons and no same event styles, these events can't be drag and drop.
Using: jquery 3.3.0, moment 2.20.1, fullcalendar 3.8.0.
Do I lost some settings? Please help and figure out, thank you all.
$(function() {
$('#calendar').fullCalendar({
header: {
left: 'prev,next today',
center: 'title',
right: 'month,basicWeek,basicDay'
},
defaultDate: '2018-01-12',
navLinks: true, // can click day/week names to navigate views
editable: true,
eventLimit: true, // allow "more" link when too many events
events: [
{
title: 'All Day Event',
start: '2018-01-01'
},
{
id: 999,
title: 'Repeating Event',
start: '2018-01-09T16:00:00'
},
{
id: 999,
title: 'Repeating Event',
start: '2018-01-16T16:00:00'
},
{
title: 'Conference',
start: '2018-01-11',
end: '2018-01-13'
},
{
title: 'Meeting',
start: '2018-01-12T10:30:00',
end: '2018-01-12T12:30:00'
},
{
title: 'Lunch',
start: '2018-01-12T12:00:00'
},
{
title: 'Meeting',
start: '2018-01-12T14:30:00'
},
{
title: 'Dinner',
start: '2018-01-12T20:00:00'
},
{
title: 'Click for Google',
url: 'http://google.com/',
start: '2018-01-28'
}
]
});
});
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.8.0/fullcalendar.min.css" rel="stylesheet"/>
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.8.0/fullcalendar.print.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/moment.js/2.20.1/moment.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.8.0/fullcalendar.min.js"></script>
<div id="calendar">
</div>
I don't know precisely which example code you tried to copy, but unfortunately you didn't copy it exactly right.
This is your problem:
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.8.0/fullcalendar.print.min.css" rel="stylesheet" />
This overrides the default CSS (from fullcalendar.min.css) with the version intended for use when printing the page. Changes here include hiding the headers and buttons and reducing the use of colours.
What you need to do is tell the browser to only use this stylesheet when in print mode. This is done using a media query media="print", as follows:
<link href="https://cdnjs.cloudflare.com/ajax/libs/fullcalendar/3.8.0/fullcalendar.print.min.css" rel="stylesheet" media="print"/>

Receiving "Highcharts is not defined" error when using maps (Highmaps / Highcharts)

I've used Highcharts quite a bit and the charts work great, but I've been stuck trying to make Highmaps work for quite a while now.
I believe I have everything setup correctly with my test map that I'm trying to make work because it works correctly in JSFiddle.
The error I'm receiving in my browser console is this:
"Uncaught ReferenceError: Highcharts is not defined at
https://code.highcharts.com/mapdata/custom/world-highres.js:1:1 (anonymous function) # world-highres.js:1"
The first part of world-highres.js is: Highcharts.maps["custom/world-highres"] = { ...
Does anyone know why Highcharts would be coming back as undefined here?
I'm using Meteor 1.3.5.1 and I have Highcharts 5.0.4 installed through NPM.
Here's how I currently have things setup:
exampleTemplate.js
import Highcharts from 'highcharts';
require('highcharts/modules/map')(Highcharts);
Template.exampleTemplate.onRendered(function() {
// Example data
var mymapdata = [
{
key: "US",
value: 198812
},
{
key: "GB",
value: 52894
},
{
key: "CA",
value: 35572
}
];
// Initiate
Highcharts.mapChart('country-map-container', {
title: {
text: 'Highmaps Example'
},
subtitle: {
text: 'Example'
},
mapNavigation: {
enabled: true,
buttonOptions: {
verticalAlign: 'bottom'
}
},
colorAxis: {
min: 0
},
series: [{
data: mymapdata,
mapData: Highcharts.maps['custom/world-highres'],
joinBy: ['iso-a2', 'key'],
name: 'Random data',
states: {
hover: {
color: '#a4edba'
}
},
dataLabels: {
enabled: true,
format: '{point.name}'
}
}]
});
});
exampleTemplate.html
<template name="exampleTemplate">
<div id="country-map-container" style="width:100%; height:400px;"></div>
</template>
Head tag:
<head>
<script src="https://code.highcharts.com/mapdata/custom/world-highres.js"></script>
</head>
Here's what it looks like with the code above:
I've tried a lot of different things and spent a ton of time on this but nothing I've tried seems to make it work... Any help with this would be extremely appreciated.
Make sure your order is as follows,
<script src="http://code.highcharts.com/maps/highmaps.js"></script>
<script src="http://code.highcharts.com/maps/modules/data.js"></script>
<script src="http://code.highcharts.com/maps/modules/exporting.js"></script>
<script src="http://code.highcharts.com/mapdata/custom/world-highres.js"></script>
JSFIDDLE

Using modified JS version in Highcharts to bring back the pre-3.0 export buttons

There are a few posts on this issue, but only one got me closer to the solution by using a modified Javascript lib.
But, I don't succeed in getting back the two buttons (print, save).
I have the code to get the libs like this:
<script type="text/javascript" src="Highcharts-3/js/highcharts.js"></script>
<script type="text/javascript" src="Highcharts-3/js/modules/exporting-old-look.src.js"></script>
And I have the Highcharts code like this:
exporting:
{
enabled: true,
buttons:
{
exportButton:
{
align: 'right',
verticalAlign: 'bottom',
y: -20
},
printButton:
{
align: 'right',
verticalAlign: 'bottom',
y: -40,
x: -10
}
}
},
But that doesn't do it...
I've put up a fiddle here.
Thanks for any hints!
You need to add exporting.js file, and remove your exporitng optiosn
http://fiddle.jshell.net/wjq9b/8/

Resources