I have made a asp.net chart with some data from DB on x-axis and y-axis like this.
and now i want to attach a custom value of Current Day with the month of DEC like this
Please any one tell me how can i acheive this . Plz Help !
Here is My chart code
<asp:Chart ID="Chart1" runat="server" DataSourceID="SqlDataSource11" Compression="5"
BackImageAlignment="Top" Palette="None" Width="400px" Height="250px">
<Series>
<asp:Series Name="2011-12" XValueMember="MON" YValueMembers="CRSH_11_12" ChartType="Spline"
YValuesPerPoint="2" IsXValueIndexed="True" MarkerSize="7" MarkerStyle="Square"
ChartArea="ChartArea1" LabelFormat="#,###,###" Color="Black" YValueType="Double"
Legend="Legend1" LegendToolTip="#TOTAL{#,###,###,###}">
<EmptyPointStyle LabelFormat="#,###,###" />
</asp:Series>
<asp:Series Name="2012-13" XValueMember="MON" YValueMembers="CRSH_12_13" ChartType="Spline"
YValuesPerPoint="2" IsXValueIndexed="True" MarkerSize="7" MarkerStyle="Diamond"
ChartArea="ChartArea1" LabelFormat="#,###,###" Color="0, 192, 0" YValueType="Double"
Legend="Legend1" LegendToolTip="#TOTAL{#,###,###,###}">
<EmptyPointStyle LabelFormat="#,###,###" />
</asp:Series>
<asp:Series Name="Target" XValueMember="MON" YValueMembers="CAN_TRG" ChartType="Spline"
YValuesPerPoint="2" IsXValueIndexed="True" MarkerSize="7" MarkerStyle="Triangle"
ChartArea="ChartArea1" LabelFormat="#,###,###" Color="Blue" YValueType="Double"
Legend="Legend1" LegendToolTip="#TOTAL{#,###,###,###}">
<EmptyPointStyle LabelFormat="#,###,###" />
</asp:Series>
<asp:Series Name="Todate" XValueMember="MON" YValueMembers="YTD_CRSH" ChartType="Spline" BorderWidth="1"
YValuesPerPoint="2" IsXValueIndexed="True" MarkerStyle="None"
ChartArea="ChartArea1" Color="Red" YValueType="Double"
Legend="Legend1" >
</asp:Series>
</Series>
<ChartAreas>
<asp:ChartArea Name="ChartArea1" AlignmentOrientation="All">
<AxisY Title="Crushing (MT)" TitleForeColor="3, 91, 172" TitleFont="Arial, 8.25pt">
<MajorGrid LineColor="217, 239, 253" />
<LabelStyle Format="#,###,###" />
</AxisY>
<AxisX LineColor="Maroon" TitleFont="Tahoma, 8pt" Title="Month" TitleForeColor="3, 91, 172">
<MajorGrid LineColor="217, 239, 253" />
</AxisX>
</asp:ChartArea>
</ChartAreas>
<Legends>
<asp:Legend Alignment="Far" Docking="Bottom" Name="Legend1">
</asp:Legend>
</Legends>
<Titles>
<asp:Title Font="Microsoft Sans Serif, 10pt, style=Bold" ForeColor="3, 91, 172" Name="Title1"
Text="Crushing">
</asp:Title>
</Titles>
</asp:Chart>
Handle the Customize event of Chart control.
private void chart1_Customize(object sender, EventArgs e)
{
foreach (var xAxisLabel in chart1.ChartAreas[0].AxisX.CustomLabels)
{
if (// xAxisLabel is Dec)
label.Text = xAxisLabel + /*custom day*/;
}
}
Related
I'm trying to open links from the left frame (accounts) in the right frame (main) but it only opens in a new tab. What am I missing?
Frames:
echo '
<frameset cols = "20%,80%">
<frame name="accounts" src="accounts.php"/>
<frame name="main" src="http://torax.outwar.com/world.php" />
</frameset>
';
Accounts Page:
$accounts = array(191022,699195);
foreach ($accounts as $account) {
echo "<a href='http://torax.outwar.com/world.php?suid=" . $account ."' target='main'>".$account."</a><br>";
}
I am try to convert inputstream to Image
I have tried using the below code.
var img = Image.FromStream(imagePathErrorMessage.StreamObject);
I need to pass the img to mvc view
#foreach (var img in imageSet)
{
<div class="thumbnail thumbnail-inline">
<label class="checkbox-inline">
<input type="checkbox" onchange="DisplayedImageOnchange(this)" value="#img.Id" />
<img src="#img.Url" class="img-thumbnail" />
</label>
<div class="btn-block">
<input type="file" class="replace file-loading" />
<button class="btn btn-xs btn-danger delete">delete</button>
</div>
</div>
}
public JsonResult Upload(object model)
{
var img = Image.FromStream(imagePathErrorMessage.StreamObject);
return Json(new AdCreative { Id = 100, Url = Url.Content("data:image;base64,#System.Convert.ToBase64String('" + img + "')") }, JsonRequestBehavior.AllowGet);
}
it throws the following error :
the above inputstream from amazon s3 response.
Firstly, you may find more information by clicking on 'View Detail' in the exception window, and expanding any InnerException properties.
Have you checked that imagePathErrorMessage.StreamObject is non-null and provides an image in one of the accepted formats?
These are JPG, BMP, TIF, GIF and PNG. If your image contains transparency data, you should convert it to a PNG first. You may not use RAW data, for that I think you'd want BitmapImage instead of Image
If the stream is valid, it will also need to be at position 0 before you start the read, for example:
imagePathErrorMessage.StreamObject.Position = 0;
var img = Image.FromStream(imagePathErrorMessage.StreamObject);
Edit for OP Edit:
Do you need to set the ResponseStream back to position zero after it is converted but before it is copied to destination?
(if at the breakpoint shown in your screenshot, you hovered over destination would it show a stream with 61153 length and CurrentPosition 0?)
Second Edit:
This answered post Loading an image from a stream without keeping the stream open describes why when using Image.FromStream then the stream needs to remain open for the lifetime of the image.
I need to mimic a web/browser based piece of functionality where a blur event is used to trigger some post entry-field handling.
However using a TextField with Nativescript I only have the "returnPress" event (as far as I can see from the UITextFieldDelegateImpl class source). This event works but is not what I need.
There is some interesting code in there though, especially the textFieldDidEndEditing method:
public textFieldDidEndEditing(textField: UITextField) {
let owner = this._owner.get();
if (owner) {
if (owner.updateTextTrigger === UpdateTextTrigger.focusLost) {
owner._onPropertyChangedFromNative(TextBase.textProperty, textField.text);
}
owner.dismissSoftInput();
}
}
It looks like this should be the place to fire a blur event but maybe there is some other way to accomplish what I need without messing with the framework code.
I did a little research and found that you could use Observable.propertyChangeEvent and the GestureModule. The next code snippets showcase the mentioned approach.
main-page.xml
<Page xmlns="http://schemas.nativescript.org/tns.xsd" navigatingTo="navigatingTo" loaded="loaded">
<StackLayout id="stack">
<Label text="Test" textWrap="true" id="label"/>
<TextField returnKeyType="done" updateTextTrigger="focusLost" hint="text" id="textfield" text="{{ textfield }}" autocorrect="false" autocapitalizationType="none" />
<TextField hint="test2" text="{{ }}" id="textfield2"/>
</StackLayout>
</Page>
main-page.js
var observable_1 = require("data/observable");
var gestures_1 = require('ui/gestures');
var textFieldEmail;
function loaded(args) {
var page = args.object;
var textField = page.getViewById("textfield");
var stackLayout = page.getViewById("stack");
var observable = new observable_1.Observable();
observable.addEventListener(observable_1.Observable.propertyChangeEvent, function (pcd) {
console.log(pcd.eventName.toString() + " " + pcd.propertyName.toString() + " " + pcd.value.toString());
});
stackLayout.on(gestures_1.GestureTypes.tap, function (args) {
console.log("Tap");
if (page.ios) {
textField.ios.resignFirstResponder();
}
else {
textField.android.clearFocus();
}
});
page.bindingContext = observable;
}
exports.loaded = loaded;
I overlay chrome://browser/content/browser.xul with an .xul adding a button to the main-menu. clicking it opens another ChromeWindow with a .xul-window.
var ww = Components.classes["#mozilla.org/embedcomp/window-watcher;1"].getService(Components.interfaces.nsIWindowWatcher);
var bgwin = ww.openWindow(null, 'chrome://myextension/content/myBrowser.xul', 'MyName', "chrome, resizable=yes, width=1024, height=600, minimizable, maximizable", []);
chrome://myextension/content/myBrowser.xul:
<?xml version="1.0"?>
<?xml-stylesheet href="chrome://global/skin/" type="text/css"?>
<window id="myextension-my-browser"
xmlns="http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul"
title="mybrowser"
windowtype="mybrowser"
>
<script type="application/x-javascript" src="chrome://myextension/content/myBrowser.js" />
<browser id="browser" type="content" flex="1" src="about:blank" />
</window>
which works fine. but then, i want to hide that window. make it completely invisible, doing (in myBrowser.js). But nothing happens:
var topXulWindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem).treeOwner
.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIXULWindow);
var appShellService = Components.classes["#mozilla.org/appshell/appShellService;1"].getService(Components.interfaces.nsIAppShellService);
appShellService.unregisterTopLevelWindow(topXulWindow);
My Question
What am i doing wrong? Why doesn't the window disappear?
Prepend you code with the following snippet
var basewindow = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
.getInterface(Components.interfaces.nsIWebNavigation)
.QueryInterface(Components.interfaces.nsIDocShell)
.QueryInterface(Components.interfaces.nsIDocShellTreeItem).treeOwner
.QueryInterface(Components.interfaces.nsIBaseWindow);
basewindow.visibility = false;
basewindow.enabled = false;
// now unregister
I'm following Joe Ward's Pixel Bender basics for Flex and AIR tutorial and updating it for Flex 4.5 Flashplayer 11.
While working on the grainBlend section It Works great, if I have an "Alert" message pop up. Otherwise the shader does not refresh/update when the HSlider is changed.
In other word: The script runs IF I have an active Alert message. If I remove the Alert Message, the blendShader only works once, and never updates afterwards.
ScriptFlow:
Init() OK
create shader OK
detect HSlider Change OK
updateFilter() OK
update Shader's turbulace value OK
update image "noise" shader and redraw NOT WORKING
I believe the following excerpt from the tutorial may be the issue. "...Because a shader object is cloned when you set the blendShader property of a display object, you cannot simply change the parameter of the original Shader object. You must also reassign the updated Shade object to the blendShader property...."
shader.data.turbulence.value = [turbulence.value];
noise.blendMode = BlendMode.SHADER;
noise.blendShader = shader;
Flex code
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
contentCreationComplete="init()"
backgroundColor="0x666666">
<fx:Script>
<![CDATA[
import mx.controls.Alert;
import mx.events.SliderEvent;
//Embed the Pixel Bender kernel in the output SWF
[Embed(source="kernels/grainblend.pbj", mimeType="application/octet-stream")]
private var GrainBlendKernel:Class;
//Create the Shader object
[Bindable]
private var shader:Shader = new Shader( new GrainBlendKernel() );
private function init():void
{
//Set the slider values based on the parameter metadata
turbulence.minimum = shader.data.turbulence.minValue;
turbulence.maximum = shader.data.turbulence.maxValue;
turbulence.value = shader.data.turbulence.defaultValue;
turbulence.addEventListener( SliderEvent.CHANGE, updateFilter );
//Apply the blend
noise.blendShader = shader;
}
private function updateFilter( event:Event ):void
{
trace(turbulence.value);//print slider
//Alert.show("Hit");
shader.data.turbulence.value = [turbulence.value];
trace("shader's value: "+shader.data.turbulence.value);
noise.blendMode = BlendMode.SHADER;
noise.blendShader = shader;
}
]]>
</fx:Script>
<s:VGroup width="100%">
<s:HGroup width="100%" height="100%" horizontalAlign="center" verticalAlign="top">
<s:VGroup>
<mx:Canvas width="195" height="194" backgroundColor="#663300"/>
<s:Label text="Background" textAlign="center" width="196"/>
</s:VGroup>
<s:VGroup>
<s:Image source="img/noise.jpg" width="195" height="194"/>
<s:Label text="Perlin noise" width="196" textAlign="center"/>
</s:VGroup>
<s:VGroup>
<mx:Canvas width="195" height="194" backgroundColor="#663300">
<s:Image source="img/noise.jpg" id="noise" width="195" height="194"/>
</mx:Canvas>
<s:Label text="Grain blend" width="196" textAlign="center"/>
</s:VGroup>
</s:HGroup>
<s:HGroup width="100%" horizontalAlign="center" verticalAlign="top">
<s:Label text="{turbulence.value}"/>
<s:HSlider id="turbulence" width="200"/>
</s:HGroup>
</s:VGroup>
Pixel Bender Kernel
<languageVersion: 1.0;>
kernel GrainBlend
< namespace : "com.adobe.example";
vendor : "Adobe Systems Inc.";
version : 1;
description : "Creates a wood grain or marbleing effect"; >
{
input image4 background;
input image4 noise;
output pixel4 dst;
parameter float turbulence
<
maxValue : 500.0;
minValue : 0.0;
defaultValue : 150.0;
>;
void evaluatePixel()
{
pixel4 a = sampleNearest(background, outCoord());
pixel4 b = sampleNearest(noise, outCoord());
float alpha = a.a; //save the original alpha
if( (b.a > 0.0) && (a.a > 0.0)){
float seed = outCoord().x + (((b.r + b.g + b.b)/3.0) * turbulence);
float grain = (0.7 * sin(seed) + 0.3 * sin(2.0 * seed + 0.3) + 0.2 * sin(3.0 * seed + 0.2));
dst = sampleNearest(background, outCoord()) * (grain + 0.5);
dst.a = alpha; //restore the original alpha
}
else {
//Just copy the background pixel outside the area of the noise image
dst = sampleNearest(background, outCoord());
}
}
}
I gave up on blendShader. I recreated it using filters. It works now. Also, I dynamically created the brown background and the perlin noise.
See below!
<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
creationComplete="init()"
backgroundColor="0x666666">
<fx:Script>
<![CDATA[
import mx.events.SliderEvent;
import spark.filters.ShaderFilter;
//Embed the Pixel Bender kernel in the output SWF
[Embed(source="kernels/grainblend.pbj", mimeType="application/octet-stream")]
private var GrainBlendKernel:Class;
//Create the Shader object
private var shader:Shader = new Shader( new GrainBlendKernel() );
private var shaderFilter:ShaderFilter = new ShaderFilter(shader);
private var myBrown:BitmapData;
private var myPerlin:BitmapData;
private function init():void
{
myPerlin = new BitmapData(200, 200, false, 0x00CCCCCC);
myBrown = new BitmapData(200, 200, false, 0x00663300);
//Set the slider values based on the parameter metadata
turbulence.minimum = shader.data.turbulence.minValue;
turbulence.maximum = shader.data.turbulence.maxValue;
turbulence.value = shader.data.turbulence.defaultValue;
turbulence.addEventListener( SliderEvent.CHANGE, updateFilter );
myPerlin.perlinNoise(100, 80, 6, Math.floor(Math.random() * 10), false, true, 7, true, null);
//Set the displayed images to the perlinNoise
perlinNoise.source = myGrain.source =myPerlin;
//Set the background image to Brown
backGround.source = myBrown;
shader.data.background.input = myBrown;
myGrain.filters = [shaderFilter];
}
private function updateFilter( event:Event ):void
{
shader.data.turbulence.value = [turbulence.value];
myGrain.filters = [shaderFilter];
}
]]>
</fx:Script>
<s:VGroup width="100%">
<s:HGroup width="100%" height="100%" horizontalAlign="center" verticalAlign="top">
<s:VGroup>
<s:BitmapImage id="backGround" width="200" height="200"/>
<s:Label text="Background" textAlign="center" width="200"/>
</s:VGroup>
<s:VGroup>
<s:BitmapImage id="perlinNoise" width="200" height="200"/>
<s:Label text="Perlin noise" width="200" textAlign="center"/>
</s:VGroup>
<s:VGroup>
<s:BitmapImage id="myGrain" width="200" height="200" />
<s:Label text="Grain blend" width="200" textAlign="center"/>
</s:VGroup>
</s:HGroup>
<s:HGroup width="100%" horizontalAlign="center" verticalAlign="top">
<s:Label text="{turbulence.value}"/>
<s:HSlider id="turbulence" width="200"/>
</s:HGroup>
</s:VGroup>
</s:Application>`